1
0
mirror of https://github.com/HybridDog/nether-pack.git synced 2024-11-14 06:20:21 +01:00

Add .luacheckrc and do some code fixes

This commit is contained in:
HybridDog 2021-12-22 18:16:01 +01:00
parent be64a982f8
commit fb1eca6c11
9 changed files with 83 additions and 49 deletions

View File

@ -5,3 +5,4 @@ https://forum.minetest.net/viewtopic.php?f=9&t=10265
TODO:
* Find a way to get the perlin noise inside [-1; 1] or use another noise
* Add some node which containing items to the simple pyramid "buildings"
* Change the sky background, fog, etc. in the nether

15
nether/.luacheckrc Normal file
View File

@ -0,0 +1,15 @@
read_globals = {
-- Defined by Minetest
"minetest", "vector", "PseudoRandom", "VoxelArea", "ItemStack", "dump",
"string",
-- Mods
"default", "stairs", "creative"
}
globals = {"nether"}
ignore = {
"212",
-- Unused argument
"411", "421", "422", "423", "431", "432",
-- Shadowing
}

View File

@ -257,7 +257,7 @@ minetest.register_abm({
meta:set_float("timedif", timediff-times)
for i = 1,times do
for _ = 1,times do
for _,name in pairs({
"fuel_totaltime",
"fuel_time",
@ -292,7 +292,7 @@ minetest.register_abm({
inv:add_item("dst", cooked.item)
-- take stuff from "src" list
inv:set_stack("src", 1, aftercooked.items[1])
else
--~ else
--print("Could not insert '"..cooked.item:to_string().."'")
end
meta:set_string("src_time", 0)

View File

@ -68,10 +68,13 @@ local guide_infos = {
{"text", "One contains 4 kinds of blocks :"},
{"image", {1, 1, cube("nether_blood.png"), 1}},
{"image", {1, 1,
cube("nether_blood_top.png", "nether_blood.png^nether_blood_side.png", "nether_blood.png^nether_blood_side.png"),
cube("nether_blood_top.png",
"nether_blood.png^nether_blood_side.png",
"nether_blood.png^nether_blood_side.png"),
2}},
{"image", {1, 1, "nether_fruit.png", 3}},
{"image", {1, 1, cube("nether_blood_stem_top.png", "nether_blood_stem.png", "nether_blood_stem.png")}},
{"image", {1, 1, cube("nether_blood_stem_top.png",
"nether_blood_stem.png", "nether_blood_stem.png")}},
{"y", 0.1},
{"text", "Blood stem, blood, blood head and nether fruit"},
{"y", 0.1},
@ -123,10 +126,14 @@ local guide_infos = {
"After that it's recommended to use cooked blood nodes."},
{"y", 0.1},
{"text", "Some nether items can be cooked:"},
{"image", {1, 1, cube("nether_blood_stem_top_cooked.png", "nether_blood_stem_cooked.png", "nether_blood_stem_cooked.png"), 0.35}},
{"image", {1, 1, cube("nether_blood_stem_top_cooked.png",
"nether_blood_stem_cooked.png", "nether_blood_stem_cooked.png"),
0.35}},
{"image", {1, 1, cube("nether_blood_cooked.png"), 1.6}},
{"image", {1, 1,
cube("nether_blood_top_cooked.png", "nether_blood_cooked.png^nether_blood_side_cooked.png", "nether_blood_cooked.png^nether_blood_side_cooked.png"),
cube("nether_blood_top_cooked.png",
"nether_blood_cooked.png^nether_blood_side_cooked.png",
"nether_blood_cooked.png^nether_blood_side_cooked.png"),
2.9}},
{"image", {1, 1, cube("nether_wood_cooked.png"), 4.3}},
{"y", 1.2},
@ -142,14 +149,18 @@ local guide_infos = {
{"text", "Here you can find out information about the nether extractor."},
{"y", 0.2},
{"text", "Here you can see its craft recipe:"},
{"image", {0.5, 0.5, cube("nether_blood_top_cooked.png", "nether_blood_cooked.png^nether_blood_side_cooked.png", "nether_blood_cooked.png^nether_blood_side_cooked.png"), 0.5}},
{"image", {0.5, 0.5, cube("nether_blood_top_cooked.png",
"nether_blood_cooked.png^nether_blood_side_cooked.png",
"nether_blood_cooked.png^nether_blood_side_cooked.png"), 0.5}},
{"image", {0.5, 0.5, cube("nether_netherrack_brick.png"), 1}},
{"image", {0.5, 0.5, cube("nether_netherrack_brick.png")}},
{"image", {0.5, 0.5, cube("nether_blood_extractor.png"), 2.5}},
{"image", {0.5, 0.5, "nether_shroom_stem.png", 0.5}},
{"image", {0.5, 0.5, cube("nether_blood_cooked.png"), 1}},
{"image", {0.5, 0.5, cube("nether_blood_cooked.png")}},
{"image", {0.5, 0.5, cube("nether_blood_stem_top_cooked.png", "nether_blood_stem_cooked.png", "nether_blood_stem_cooked.png"), 0.5}},
{"image", {0.5, 0.5, cube("nether_blood_stem_top_cooked.png",
"nether_blood_stem_cooked.png", "nether_blood_stem_cooked.png"),
0.5}},
{"image", {0.5, 0.5, cube("nether_netherrack_brick.png"), 1}},
{"image", {0.5, 0.5, cube("nether_netherrack_brick.png")}},
{"y", 0.2},
@ -347,11 +358,12 @@ for n,i in ipairs(guide_forms) do
end
-- creates contents formspec
local y = 0
for y,i in ipairs(guide_forms) do
local desc, form = unpack(i)
local s = #desc*1.3/font_size+1.5
guide_forms.contents = guide_forms.contents.."button["..guide_size.cx*12/s-0.5 ..","..guide_size.cy+y/1.3 ..";"..s..",1;name;"..desc.."]"
local desc = i[1]
local s = #desc * 1.3 / font_size + 1.5
guide_forms.contents = guide_forms.contents ..
"button[" .. guide_size.cx * 12 / s - 0.5 .. "," ..
guide_size.cy + y / 1.3 .. ";" .. s .. ",1;name;" .. desc .. "]"
end
-- shows the contents of the formspec
@ -387,7 +399,9 @@ minetest.register_chatcommand("nether_help", {
return false
end
if player:getpos().y > nether.start then
minetest.chat_send_player(name, "Usually you don't neet this guide here. You can view it in the nether.")
minetest.chat_send_player(name,
"Usually you don't neet this guide here. " ..
"You can view it in the nether.")
return false
end
minetest.chat_send_player(name, "Showing guide...")

View File

@ -62,7 +62,7 @@ nether.start = f_h_max+100
local NETHER_HEIGHT = 30
-- Maximum amount of randomness in the map generation
NETHER_RANDOM = 2
local NETHER_RANDOM = 2
-- Frequency of Glowstone on the "roof" of the Nether (higher is less frequent)
local GLOWSTONE_FREQ_ROOF = 500
@ -117,7 +117,7 @@ end
local path = minetest.get_modpath"nether"
dofile(path.."/weird_mapgen_noise.lua")
local nether_weird_noise = dofile(path.."/weird_mapgen_noise.lua")
dofile(path.."/items.lua")
--dofile(path.."/furnace.lua")
dofile(path.."/pearl.lua")

View File

@ -41,11 +41,13 @@ local function digging_allowed(player, v)
if not player then
return false
end
if creative_installed and creative.is_enabled_for(player:get_player_name()) then
if creative_installed
and creative.is_enabled_for(player:get_player_name()) then
return true
end
local tool = player:get_wielded_item():get_name()
tool = minetest.registered_tools[tool] or tool == "" and minetest.registered_items[tool]
tool = minetest.registered_tools[tool] or tool == ""
and minetest.registered_items[tool]
if not tool
or not tool.tool_capabilities then
return false
@ -210,7 +212,8 @@ add_more_nodes("blood_empty")
minetest.register_node("nether:blood_top", {
description = "Nether Blood Head",
tiles = {"nether_blood_top.png", "nether_blood.png", "nether_blood.png^nether_blood_side.png"},
tiles = {"nether_blood_top.png", "nether_blood.png",
"nether_blood.png^nether_blood_side.png"},
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=1},
sounds = default.node_sound_wood_defaults(),
})
@ -218,7 +221,8 @@ add_more_nodes("blood_top")
minetest.register_node("nether:blood_top_cooked", {
description = "Cooked Nether Blood Head",
tiles = {"nether_blood_top_cooked.png", "nether_blood_cooked.png", "nether_blood_cooked.png^nether_blood_side_cooked.png"},
tiles = {"nether_blood_top_cooked.png", "nether_blood_cooked.png",
"nether_blood_cooked.png^nether_blood_side_cooked.png"},
groups = {nether=3},
sounds = nether_sound,
furnace_burntime = 10,
@ -230,7 +234,8 @@ add_more_nodes("blood_top_cooked")
minetest.register_node("nether:blood_top_empty", {
description = "Nether Blood Head Extracted",
tiles = {"nether_blood_top_empty.png", "nether_blood_empty.png", "nether_blood_empty.png^nether_blood_side_empty.png"},
tiles = {"nether_blood_top_empty.png", "nether_blood_empty.png",
"nether_blood_empty.png^nether_blood_side_empty.png"},
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=1},
sounds = default.node_sound_wood_defaults(),
})
@ -239,7 +244,8 @@ add_more_nodes("blood_top_empty")
minetest.register_node("nether:blood_stem", {
description = "Nether Blood Stem",
tiles = {"nether_blood_stem_top.png", "nether_blood_stem_top.png", "nether_blood_stem.png"},
tiles = {"nether_blood_stem_top.png", "nether_blood_stem_top.png",
"nether_blood_stem.png"},
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=1},
sounds = default.node_sound_wood_defaults(),
})
@ -247,7 +253,8 @@ add_more_nodes("blood_stem")
minetest.register_node("nether:blood_stem_cooked", {
description = "Cooked Nether Blood Stem",
tiles = {"nether_blood_stem_top_cooked.png", "nether_blood_stem_top_cooked.png", "nether_blood_stem_cooked.png"},
tiles = {"nether_blood_stem_top_cooked.png",
"nether_blood_stem_top_cooked.png", "nether_blood_stem_cooked.png"},
groups = {nether=3},
sounds = nether_sound,
furnace_burntime = 30,
@ -259,7 +266,8 @@ add_more_nodes("blood_stem_cooked")
minetest.register_node("nether:blood_stem_empty", {
description = "Nether Blood Stem Extracted",
tiles = {"nether_blood_stem_top_empty.png", "nether_blood_stem_top_empty.png", "nether_blood_stem_empty.png"},
tiles = {"nether_blood_stem_top_empty.png",
"nether_blood_stem_top_empty.png", "nether_blood_stem_empty.png"},
groups = {tree=1, choppy=2, oddly_breakable_by_hand=1},
sounds = default.node_sound_wood_defaults(),
})
@ -351,7 +359,9 @@ minetest.override_item("riesenpilz:nether_shroom", {
minetest.register_node("nether:apple", {
description = "Nether Fruit",
drawtype = "nodebox",
tiles = {"nether_fruit_top.png", "nether_fruit_bottom.png", "nether_fruit.png", "nether_fruit.png^[transformFX", "nether_fruit.png^[transformFX", "nether_fruit.png"},
tiles = {"nether_fruit_top.png", "nether_fruit_bottom.png",
"nether_fruit.png", "nether_fruit.png^[transformFX",
"nether_fruit.png^[transformFX", "nether_fruit.png"},
node_box = {
type = "fixed",
fixed = {
@ -379,7 +389,7 @@ minetest.register_node("nether:apple", {
return
end
itemstack:take_item()
if nether_port(user, vector.round(user:getpos())) then
if nether.teleport_player(user) then
return itemstack
end
local amount = math.random(4, 6)
@ -506,8 +516,10 @@ minetest.register_node("nether:tree", {
minetest.register_node("nether:tree_corner", {
description = "Nether Trunk Corner",
tiles = {"nether_tree.png^[transformR180", "nether_tree_top.png", "nether_tree_corner.png^[transformFY",
"nether_tree_corner.png^[transformR180", "nether_tree.png", "nether_tree_top.png"},
tiles = {"nether_tree.png^[transformR180", "nether_tree_top.png",
"nether_tree_corner.png^[transformFY",
"nether_tree_corner.png^[transformR180", "nether_tree.png",
"nether_tree_top.png"},
paramtype2 = "facedir",
is_ground_content = false,
groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,not_in_creative_inventory=1},

View File

@ -1,13 +1,4 @@
local function table_contains(t, v)
for _,i in pairs(t) do
if v == i then
return true
end
end
return false
end
local creative = minetest.settings:get_bool("creative_mode")
local function throw_pearl(item, player)
local playerpos = player:getpos()
playerpos.y = playerpos.y+1.625
@ -15,8 +6,9 @@ local function throw_pearl(item, player)
local dir = player:get_look_dir()
obj:setvelocity(vector.multiply(dir, 30))
obj:setacceleration({x=dir.x*-3, y=-dir.y^8*80-10, z=dir.z*-3})
obj:get_luaentity().player = player:get_player_name()
if not creative then
local pname = player:get_player_name()
obj:get_luaentity().player = pname
if not minetest.is_creative_enabled(pname) then
item:take_item()
return item
end

View File

@ -484,7 +484,7 @@ local function make_portal(pos)
for d=0,3 do
for y=p1.y,p2.y do
local p = {}
local p
if param2 == 0 then
p = {x=p1.x+d, y=y, z=p1.z}
else
@ -580,8 +580,7 @@ end)
-- a not filled square
vector.square = vector.square or
function(r)
local function vector_square(r)
local tab, n = {}, 1
for i = -r+1, r do
for j = -1, 1, 2 do
@ -601,13 +600,13 @@ local function is_netherportal(pos)
return
end
end
for _,sn in pairs(vector.square(1)) do
for _,sn in pairs(vector_square(1)) do
if minetest.get_node({x=x+sn[1], y=y-1, z=z+sn[2]}).name ~= "nether:netherrack"
or minetest.get_node({x=x+sn[1], y=y+3, z=z+sn[2]}).name ~= "nether:blood_cooked" then
return
end
end
for _,sn in pairs(vector.square(2)) do
for _,sn in pairs(vector_square(2)) do
if minetest.get_node({x=x+sn[1], y=y-1, z=z+sn[2]}).name ~= "nether:netherrack_black"
or minetest.get_node({x=x+sn[1], y=y+3, z=z+sn[2]}).name ~= "nether:wood_empty" then
return
@ -651,13 +650,12 @@ local function set_portal(t, z,x, y)
end
-- used when a player eats that fruit in a portal
function nether_port(player, pos)
if not player
or not pos
or not pos.x then
minetest.log("error", "[nether] nether_port: something failed.")
function nether.teleport_player(player)
if not player then
minetest.log("error", "[nether] Missing player.")
return
end
local pos = vector.round(player:getpos())
if not is_netherportal(pos) then
return
end

View File

@ -5,7 +5,7 @@ end
local r_chs = {}
function nether_weird_noise(minp, fct, s, seed, range, scale)
local function nether_weird_noise(minp, fct, s, seed, range, scale)
if not r_chs[s] then
r_chs[s] = math.floor(s/3+0.5)
end
@ -86,3 +86,5 @@ minetest.register_node("ac:wmg", {
end
end,
})]]
return nether_weird_noise