MAJOR: Code quality audit using luacheck.
- Removed lots of unused variables, a few shadowed identifiers. - Removed a few sections of dead code.
This commit is contained in:
parent
939f544eaf
commit
39dea8a2ae
@ -72,7 +72,6 @@ ISSUES: Bugs, Cleanup and Refinements
|
||||
- Separate durability, speed, effects?
|
||||
|
||||
- Code Quality.
|
||||
- Finish setting up LuaCheck, audit code.
|
||||
- Scripts to validate dependency graph.
|
||||
- Tag deps directly in code at place of use.
|
||||
- Auto-generate mod.conf / depends.txt
|
||||
|
@ -21,14 +21,14 @@ function nodecore.digparticles(nodedef, partdef)
|
||||
partdef.amount = partdef.amount and math_ceil(partdef.amount / 4) or 4
|
||||
|
||||
local t = {}
|
||||
for i = 1, 4 do
|
||||
for _ = 1, 4 do
|
||||
partdef.texture = img .. "^[mask:[combine\\:16x16\\:"
|
||||
.. math_floor(math_random() * 12) .. ","
|
||||
.. math_floor(math_random() * 12) .. "=nc_api_pummel.png"
|
||||
t[#t + 1] = minetest.add_particlespawner(partdef)
|
||||
end
|
||||
return function()
|
||||
for k, v in pairs(t) do
|
||||
for _, v in pairs(t) do
|
||||
minetest.delete_particlespawner(v)
|
||||
end
|
||||
end
|
||||
|
@ -8,7 +8,7 @@ local falling = {
|
||||
set_node = function(self, node, meta, ...)
|
||||
meta = meta or {}
|
||||
if type(meta) ~= "table" then meta = meta:to_table() end
|
||||
for k1, v1 in pairs(meta.inventory or {}) do
|
||||
for _, v1 in pairs(meta.inventory or {}) do
|
||||
for k2, v2 in pairs(v1) do
|
||||
if type(v2) == "userdata" then
|
||||
v1[k2] = v2:to_string()
|
||||
|
@ -14,22 +14,6 @@ pummeled.
|
||||
|
||||
local looseimg = "^nc_api_loose.png"
|
||||
|
||||
local function can_repack(level)
|
||||
return function(pos, node, stats)
|
||||
return nodecore.toolspeed(stats.puncher:get_wielded_item(), {thumpy = level})
|
||||
end
|
||||
end
|
||||
|
||||
local function repack_node(mult, replace)
|
||||
if type(replace) ~= "table" then replace = {name = replace} end
|
||||
return function (pos, node, stats)
|
||||
if stats.duration < (mult * stats.check) then return end
|
||||
nodecore.wear_current_tool(stats.puncher, {thumpy = 1})
|
||||
minetest.set_node(pos, replace)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
nodecore.register_on_register_item(function(name, def)
|
||||
if def.type ~= "node" then return end
|
||||
|
||||
@ -42,7 +26,7 @@ nodecore.register_on_register_item(function(name, def)
|
||||
if type(v) == "string" then
|
||||
loose.tiles[k] = v .. looseimg
|
||||
elseif type(v) == "table" then
|
||||
loose.tiles[k] = underride({
|
||||
loose.tiles[k] = nodecore.underride({
|
||||
name = v.name .. looseimg
|
||||
}, v)
|
||||
end
|
||||
|
@ -8,7 +8,7 @@ Nodes with a "drop_in_place" spec transform on node drop by dropping
|
||||
into place of existing node instead of digger inventory.
|
||||
--]]
|
||||
|
||||
nodecore.register_on_register_item(function(name, def)
|
||||
nodecore.register_on_register_item(function(_, def)
|
||||
if def.type ~= "node" then return end
|
||||
local dip = def.drop_in_place
|
||||
if dip then
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local math, minetest, nodecore, pairs, type
|
||||
= math, minetest, nodecore, pairs, type
|
||||
local math, minetest, nodecore, pairs
|
||||
= math, minetest, nodecore, pairs
|
||||
local math_random
|
||||
= math.random
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
@ -18,7 +18,7 @@ function nodecore.falling_repose_drop(posfrom, posto, node)
|
||||
return minetest.check_for_falling(posfrom)
|
||||
end
|
||||
|
||||
nodecore.register_on_register_item(function(name, def)
|
||||
nodecore.register_on_register_item(function(_, def)
|
||||
if def.type ~= "node" then return end
|
||||
|
||||
def.groups = def.groups or {}
|
||||
@ -91,7 +91,7 @@ nodecore.register_limited_abm({
|
||||
neighbors = {"air"},
|
||||
interval = 2,
|
||||
chance = 5,
|
||||
action = function(pos, node)
|
||||
action = function(pos)
|
||||
if not reposeq then
|
||||
reposeq = {}
|
||||
qqty = 0
|
||||
|
@ -89,7 +89,7 @@ function nodecore.visinv_update_ents(pos, node)
|
||||
local max = def.groups and def.groups.visinv and 1 or 0
|
||||
|
||||
local found = {}
|
||||
for k, v in pairs(minetest.get_objects_inside_radius(pos, 0.5)) do
|
||||
for _, v in pairs(minetest.get_objects_inside_radius(pos, 0.5)) do
|
||||
if v and v.get_luaentity and v:get_luaentity()
|
||||
and v:get_luaentity().is_stack then
|
||||
found[#found + 1] = v
|
||||
@ -152,7 +152,7 @@ function nodecore.visinv_after_destruct(pos)
|
||||
end)
|
||||
end
|
||||
|
||||
nodecore.register_on_register_item(function(name, def)
|
||||
nodecore.register_on_register_item(function(_, def)
|
||||
if def.type ~= "node" then return end
|
||||
|
||||
def.groups = def.groups or {}
|
||||
|
@ -5,7 +5,7 @@ local minetest, nodecore, pairs
|
||||
|
||||
nodecore.register_on_register_item(function(name, def)
|
||||
if def.oldnames then
|
||||
for k, v in pairs(def.oldnames) do
|
||||
for _, v in pairs(def.oldnames) do
|
||||
if not minetest.registered_items[v] then
|
||||
minetest.register_alias(v, name)
|
||||
end
|
||||
|
@ -5,7 +5,7 @@ local minetest, nodecore
|
||||
|
||||
local lasthit = {}
|
||||
|
||||
minetest.register_on_punchnode(function(pos, node, puncher, pointed)
|
||||
minetest.register_on_punchnode(function(pos, node, puncher)
|
||||
if not puncher then return end
|
||||
local pname = puncher:get_player_name()
|
||||
local now = minetest.get_us_time() / 1000000
|
||||
|
@ -1,9 +1,9 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local nodecore, type
|
||||
= nodecore, type
|
||||
local nodecore
|
||||
= nodecore
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
nodecore.register_on_register_item(function(name, def)
|
||||
nodecore.register_on_register_item(function(_, def)
|
||||
if def.type == "tool" then
|
||||
def.sound = def.sound or {}
|
||||
def.sound.breaks = def.sound.breaks or {name = "nc_api_toolbreak", gain = 1}
|
||||
|
@ -3,9 +3,9 @@ local ItemStack, minetest, nodecore
|
||||
= ItemStack, minetest, nodecore
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
nodecore.register_on_register_item(function(name, def)
|
||||
nodecore.register_on_register_item(function(_, def)
|
||||
if def.tool_wears_to then
|
||||
def.after_use = def.after_use or function(what, who, node, dp)
|
||||
def.after_use = def.after_use or function(what, who, _, dp)
|
||||
what:add_wear(dp.wear)
|
||||
if what:get_count() == 0 then
|
||||
if def.sound and def.sound.breaks then
|
||||
|
@ -4,7 +4,7 @@ local nodecore, pairs, vector
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local alldirs = {}
|
||||
for k, v in pairs(nodecore.dirs()) do
|
||||
for _, v in pairs(nodecore.dirs()) do
|
||||
alldirs[v.n] = v
|
||||
end
|
||||
|
||||
|
@ -14,8 +14,8 @@ for k, v in pairs(minetest) do
|
||||
end
|
||||
end
|
||||
|
||||
local function underride(t, u, v, ...)
|
||||
if v then underride(u, v, ...) end
|
||||
local function underride(t, u, u2, ...)
|
||||
if u2 then underride(u, u2, ...) end
|
||||
for k, v in pairs(u) do
|
||||
if t[k] == nil then
|
||||
t[k] = v
|
||||
@ -66,7 +66,7 @@ function nodecore.pickrand(tbl, weight)
|
||||
end
|
||||
if max <= 0 then return end
|
||||
max = math_random() * max
|
||||
for i, v in ipairs(t) do
|
||||
for _, v in ipairs(t) do
|
||||
max = max - v.w
|
||||
if max <= 0 then return v.v, v.k end
|
||||
end
|
||||
@ -187,7 +187,7 @@ function nodecore.item_eject(pos, stack, speed, qty, vel)
|
||||
stack:set_count(stack:get_count() * (qty or 1))
|
||||
return nodecore.place_stack(pos, stack)
|
||||
end
|
||||
for i = 1, (qty or 1) do
|
||||
for _ = 1, (qty or 1) do
|
||||
local v = {
|
||||
x = vel.x + (math_random() - 0.5) * speed,
|
||||
y = vel.y + math_random() * speed,
|
||||
@ -220,7 +220,7 @@ function nodecore.node_spin_custom(...)
|
||||
lut[arr[#arr]] = arr[1]
|
||||
local qty = #arr
|
||||
|
||||
return function(pos, node, clicker, itemstack, pointed_thing)
|
||||
return function(pos, node, clicker, itemstack)
|
||||
node = node or minetest.get_node(pos)
|
||||
node.param2 = lut[node.param2] or lut[false]
|
||||
if clicker:is_player() then
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local ipairs, math, minetest, next, nodecore, pairs, table
|
||||
= ipairs, math, minetest, next, nodecore, pairs, table
|
||||
local ipairs, math, minetest, nodecore, pairs, table
|
||||
= ipairs, math, minetest, nodecore, pairs, table
|
||||
local math_random, table_insert
|
||||
= math.random, table.insert
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
@ -11,12 +11,12 @@ function nodecore.scan_flood(pos, range, func)
|
||||
local q = {pos}
|
||||
local seen = { }
|
||||
for d = 0, range do
|
||||
local next = {}
|
||||
for i, p in ipairs(q) do
|
||||
local nxt = {}
|
||||
for _, p in ipairs(q) do
|
||||
local res = func(p, d)
|
||||
if res then return res end
|
||||
if res == nil then
|
||||
for k, v in pairs(dirs) do
|
||||
for _, v in pairs(dirs) do
|
||||
local np = {
|
||||
x = p.x + v.x,
|
||||
y = p.y + v.y,
|
||||
@ -26,16 +26,16 @@ function nodecore.scan_flood(pos, range, func)
|
||||
if not seen[nk] then
|
||||
seen[nk] = true
|
||||
np.dir = v
|
||||
table_insert(next, np)
|
||||
table_insert(nxt, np)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if #next < 1 then break end
|
||||
for i = 1, #next do
|
||||
local j = math_random(1, #next)
|
||||
next[i], next[j] = next[j], next[i]
|
||||
if #nxt < 1 then break end
|
||||
for i = 1, #nxt do
|
||||
local j = math_random(1, #nxt)
|
||||
nxt[i], nxt[j] = nxt[j], nxt[i]
|
||||
end
|
||||
q = next
|
||||
q = nxt
|
||||
end
|
||||
end
|
||||
|
@ -11,8 +11,6 @@ local function family(stack)
|
||||
end
|
||||
function nodecore.stack_merge(dest, src)
|
||||
if dest:is_empty() then return dest:add_item(src) end
|
||||
local df = family(dest)
|
||||
local sf = family(src)
|
||||
if family(src) ~= family(dest) then
|
||||
return dest:add_item(src)
|
||||
end
|
||||
|
@ -36,7 +36,7 @@ minetest.register_globalstep(function()
|
||||
strings_dirty = nil
|
||||
|
||||
local keys = {}
|
||||
for k, v in pairs(strings) do keys[#keys + 1] = k end
|
||||
for k in pairs(strings) do keys[#keys + 1] = k end
|
||||
table_sort(keys)
|
||||
|
||||
local data = "# textdomain: " .. modname .. "\n"
|
||||
|
@ -129,21 +129,21 @@ local function craftcheck(recipe, pos, node, data, xx, xz, zx, zz)
|
||||
end
|
||||
|
||||
local function tryall(rc, pos, node, data)
|
||||
local function go(rc, xx, xz, zx, zz)
|
||||
local function go(xx, xz, zx, zz)
|
||||
return craftcheck(rc, pos, node, data, xx, xz, zx, zz)
|
||||
end
|
||||
local r = go(rc, 1, 0, 0, 1)
|
||||
local r = go(1, 0, 0, 1)
|
||||
if r then return r end
|
||||
if not rc.norotate then
|
||||
r = go(rc, 0, -1, 1, 0)
|
||||
or go(rc, -1, 0, 0, -1)
|
||||
or go(rc, 0, 1, -1, 0)
|
||||
r = go(0, -1, 1, 0)
|
||||
or go(-1, 0, 0, -1)
|
||||
or go(0, 1, -1, 0)
|
||||
if r then return r end
|
||||
if not rc.nomirror then
|
||||
r = go(rc, -1, 0, 0, 1)
|
||||
or go(rc, 0, 1, 1, 0)
|
||||
or go(rc, 1, 0, 0, -1)
|
||||
or go(rc, 0, -1, -1, 0)
|
||||
r = go(-1, 0, 0, 1)
|
||||
or go(0, 1, 1, 0)
|
||||
or go(1, 0, 0, -1)
|
||||
or go(0, -1, -1, 0)
|
||||
end
|
||||
end
|
||||
return r
|
||||
|
@ -3,7 +3,7 @@ local minetest, nodecore, vector
|
||||
= minetest, nodecore, vector
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local function pummelparticles(pos, data)
|
||||
local function pummelparticles(_, data)
|
||||
local pointed = data.pointed
|
||||
local nodedef = data.nodedef
|
||||
local pname = data.pname
|
||||
|
@ -5,7 +5,7 @@ local minetest, nodecore, type
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local function getduration(pos, data)
|
||||
local function getduration(_, data)
|
||||
local meta = minetest.get_meta(data.node)
|
||||
|
||||
local md = meta:get_string(modname) or ""
|
||||
|
@ -43,7 +43,7 @@ nodecore.register_craft({
|
||||
dirs[#dirs + 1] = {pos = p, qty = 0}
|
||||
end
|
||||
end
|
||||
for n = 1, 8 do
|
||||
for _ = 1, 8 do
|
||||
local p = dirs[math_random(1, #dirs)]
|
||||
p.qty = p.qty + 1
|
||||
end
|
||||
|
@ -34,7 +34,7 @@ function nodecore.operate_door(pos, node, dir)
|
||||
|
||||
local found = {}
|
||||
local hinge = hingeaxis(pos, node)
|
||||
if nodecore.scan_flood(pos, 128, function(p, d)
|
||||
if nodecore.scan_flood(pos, 128, function(p)
|
||||
local n = minetest.get_node_or_nil(p)
|
||||
if not n then return true end
|
||||
if (not nodecore.match(n, is_door))
|
||||
@ -45,8 +45,8 @@ function nodecore.operate_door(pos, node, dir)
|
||||
|
||||
local toop = {}
|
||||
for k, v in pairs(found) do
|
||||
local fd = nodecore.facedirs[v.node.param2 or 0]
|
||||
local to = vector.add(v.pos, fd[rotdir])
|
||||
local ffd = nodecore.facedirs[v.node.param2 or 0]
|
||||
local to = vector.add(v.pos, ffd[rotdir])
|
||||
|
||||
if (not found[minetest.pos_to_string(to)])
|
||||
and (not nodecore.buildable_to(to))
|
||||
@ -57,15 +57,15 @@ function nodecore.operate_door(pos, node, dir)
|
||||
|
||||
v.str = str
|
||||
v.to = to
|
||||
v.fd = fd
|
||||
v.fd = ffd
|
||||
|
||||
toop[k .. "l"] = {
|
||||
pos = vector.add(v.pos, fd.l),
|
||||
dir = rotdir == "r" and fd.k or fd.f
|
||||
pos = vector.add(v.pos, ffd.l),
|
||||
dir = rotdir == "r" and ffd.k or ffd.f
|
||||
}
|
||||
toop[k .. "k"] = {
|
||||
pos = vector.add(v.pos, fd.k),
|
||||
dir = rotdir == "r" and fd.r or fd.l
|
||||
pos = vector.add(v.pos, ffd.k),
|
||||
dir = rotdir == "r" and ffd.r or ffd.l
|
||||
}
|
||||
end
|
||||
|
||||
@ -75,10 +75,10 @@ function nodecore.operate_door(pos, node, dir)
|
||||
squelch[k] = true
|
||||
squelch[v.str] = true
|
||||
end
|
||||
for k, v in pairs(found) do
|
||||
for i, fd in pairs(nodecore.facedirs) do
|
||||
if vector.equals(fd.t, v.fd.t)
|
||||
and vector.equals(fd.r, rotdir == "r" and v.fd.f or v.fd.k) then
|
||||
for _, v in pairs(found) do
|
||||
for i, xfd in pairs(nodecore.facedirs) do
|
||||
if vector.equals(xfd.t, v.fd.t)
|
||||
and vector.equals(xfd.r, rotdir == "r" and v.fd.f or v.fd.k) then
|
||||
toset[minetest.pos_to_string(v.to)] = {
|
||||
pos = v.to,
|
||||
name = v.node.name,
|
||||
@ -89,7 +89,7 @@ function nodecore.operate_door(pos, node, dir)
|
||||
end
|
||||
end
|
||||
|
||||
for k, v in pairs(toset) do
|
||||
for _, v in pairs(toset) do
|
||||
minetest.set_node(v.pos, v)
|
||||
if v.name ~= "air" then
|
||||
local p = vector.round(vector.multiply(v.pos, 0.25))
|
||||
@ -101,7 +101,7 @@ function nodecore.operate_door(pos, node, dir)
|
||||
end
|
||||
end
|
||||
end
|
||||
for k, v in pairs(toop) do
|
||||
for _, v in pairs(toop) do
|
||||
nodecore.operate_door(v.pos, nil, v.dir)
|
||||
end
|
||||
end
|
||||
|
@ -46,7 +46,7 @@ function nodecore.register_door(basemod, basenode, desc, pin)
|
||||
local t = minetest.registered_items[pin].tiles
|
||||
t = t[3] or t[2] or t[1]
|
||||
t = t.name or t
|
||||
local tiles = nodecore.underride({}, tiles)
|
||||
tiles = nodecore.underride({}, tiles)
|
||||
for _, v in pairs(tilemods) do
|
||||
tiles[v.idx] = tiles[v.idx] .. "^((" .. t .. ")^[mask:nc_doors_hinge_" .. v.part
|
||||
.. "_mask.png^[transform" .. v.tran .. ")"
|
||||
@ -84,7 +84,7 @@ function nodecore.register_door(basemod, basenode, desc, pin)
|
||||
|
||||
nodecore.register_craft({
|
||||
label = "lubricate door " .. basenode:lower(),
|
||||
check = function(pos, data)
|
||||
check = function(_, data)
|
||||
return minetest.get_meta(data.rel(0, -1, 0))
|
||||
:get_float("doorlube") ~= 1
|
||||
end,
|
||||
@ -121,7 +121,7 @@ function nodecore.register_door(basemod, basenode, desc, pin)
|
||||
action = "pummel",
|
||||
toolgroups = {thumpy = 1},
|
||||
normal = {y = 1},
|
||||
check = function(pos, data)
|
||||
check = function(_, data)
|
||||
return minetest.get_meta(data.rel(0, -1, 0))
|
||||
:get_float("doorlube") == 1
|
||||
end,
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local math, minetest, nodecore, type
|
||||
= math, minetest, nodecore, type
|
||||
local math, minetest, nodecore
|
||||
= math, minetest, nodecore
|
||||
local math_floor, math_sqrt
|
||||
= math.floor, math.sqrt
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
@ -15,7 +15,7 @@ minetest.register_node(modname .. ":fire", {
|
||||
{
|
||||
name = "nc_fire_fire.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
["type"] = "vertical_frames",
|
||||
aspect_w = 24,
|
||||
aspect_h = 24,
|
||||
length = 4
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local ItemStack, math, minetest, nodecore, setmetatable, type, vector
|
||||
= ItemStack, math, minetest, nodecore, setmetatable, type, vector
|
||||
local ItemStack, math, minetest, nodecore, setmetatable, vector
|
||||
= ItemStack, math, minetest, nodecore, setmetatable, vector
|
||||
local math_random
|
||||
= math.random
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
@ -31,7 +31,7 @@ minetest.register_node(modname .. ":stack", {
|
||||
},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
repose_drop = function(posfrom, posto, node)
|
||||
repose_drop = function(posfrom, posto)
|
||||
local stack = nodecore.stack_get(posfrom)
|
||||
if stack and not stack:is_empty() then
|
||||
nodecore.item_eject(posto, stack)
|
||||
@ -57,7 +57,6 @@ minetest.register_node(modname .. ":stack", {
|
||||
|
||||
function nodecore.place_stack(pos, stack, placer, pointed_thing)
|
||||
stack = ItemStack(stack)
|
||||
local name = stack:get_name()
|
||||
|
||||
local below = {x = pos.x, y = pos.y - 1, z = pos.z}
|
||||
if minetest.get_node(below).name == modname .. ":stack" then
|
||||
@ -79,7 +78,7 @@ function nodecore.place_stack(pos, stack, placer, pointed_thing)
|
||||
end
|
||||
|
||||
local bii = minetest.registered_entities["__builtin:item"]
|
||||
local item = {
|
||||
local newbii = {
|
||||
on_step = function(self, dtime, ...)
|
||||
bii.on_step(self, dtime, ...)
|
||||
|
||||
@ -109,7 +108,7 @@ local item = {
|
||||
end,
|
||||
on_punch = function(self, whom, ...)
|
||||
if not nodecore.interact(whom) then return end
|
||||
local r = bii.on_punch(self, whom, ...)
|
||||
bii.on_punch(self, whom, ...)
|
||||
if self.itemstring ~= "" then
|
||||
local v = self.object:get_velocity()
|
||||
v.x = v.x + math_random() * 5 - 2.5
|
||||
@ -119,8 +118,8 @@ local item = {
|
||||
end
|
||||
end
|
||||
}
|
||||
setmetatable(item, bii)
|
||||
minetest.register_entity(":__builtin:item", item)
|
||||
setmetatable(newbii, bii)
|
||||
minetest.register_entity(":__builtin:item", newbii)
|
||||
|
||||
local bifn = minetest.registered_entities["__builtin:falling_node"]
|
||||
local falling = {
|
||||
@ -172,7 +171,7 @@ if nodecore.loaded_mods().nc_fire then
|
||||
chance = 1,
|
||||
nodenames = {modname .. ":stack"},
|
||||
neighbors = {"group:igniter"},
|
||||
action = function(pos, node)
|
||||
action = function(pos)
|
||||
local stack = nodecore.stack_get(pos)
|
||||
return nodecore.fire_check_ignite(pos, {name = stack:get_name()})
|
||||
end
|
||||
@ -201,7 +200,7 @@ if minetest.raycast then
|
||||
|
||||
local dummyent = {}
|
||||
setmetatable(dummyent, {
|
||||
__index = function(t, k)
|
||||
__index = function()
|
||||
return function() return {} end
|
||||
end
|
||||
})
|
||||
|
@ -143,7 +143,7 @@ for _, id in pairs({
|
||||
end
|
||||
end
|
||||
|
||||
nodecore.register_mapgen_shared(function(minp, maxp, area, data, vm, emin, emax)
|
||||
nodecore.register_mapgen_shared(function(minp, maxp, area, data)
|
||||
local function bad(x, y, z)
|
||||
local c = data[area:index(x, y, z)]
|
||||
return not stoneids[c]
|
||||
|
@ -1,12 +1,12 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local minetest, nodecore, type
|
||||
= minetest, nodecore, type
|
||||
local minetest, nodecore
|
||||
= minetest, nodecore
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
nodecore.register_lode("Bar", {
|
||||
type = "node",
|
||||
["type"] = "node",
|
||||
description = "## Lode Bar",
|
||||
drawtype = "nodebox",
|
||||
node_box = nodecore.fixedbox(-1/16, -0.5, -1/16, 1/16, 0, 1/16),
|
||||
@ -62,7 +62,7 @@ nodecore.register_craft({
|
||||
})
|
||||
|
||||
nodecore.register_lode("Rod", {
|
||||
type = "node",
|
||||
["type"] = "node",
|
||||
description = "## Lode Rod",
|
||||
drawtype = "nodebox",
|
||||
node_box = nodecore.fixedbox(-1/16, -0.5, -1/16, 1/16, 0.5, 1/16),
|
||||
|
@ -9,9 +9,9 @@ local function toolhead(name, groups, prills)
|
||||
local n = name:lower()
|
||||
|
||||
if type(groups) == "string" then groups = {groups} end
|
||||
local function toolcap(n)
|
||||
local function toolcap(nn)
|
||||
local t = {}
|
||||
for _, k in ipairs(groups) do t[k] = n end
|
||||
for _, k in ipairs(groups) do t[k] = nn end
|
||||
return nodecore.toolcaps(t)
|
||||
end
|
||||
|
||||
|
@ -40,7 +40,7 @@ for i = 1, 8 do
|
||||
end
|
||||
|
||||
local strata = {}
|
||||
local stone = minetest.register_node(modname .. ":stone", {
|
||||
minetest.register_node(modname .. ":stone", {
|
||||
drawtype = "glasslike",
|
||||
description = "Stone",
|
||||
tiles = {"nc_terrain_stone.png"},
|
||||
@ -56,7 +56,6 @@ local stone = minetest.register_node(modname .. ":stone", {
|
||||
|
||||
strata[1] = modname .. ":stone"
|
||||
for i = 1, nodecore.hard_stone_strata do
|
||||
local hst = nodecore.hard_stone_tile(i)
|
||||
strata[i + 1] = modname .. ":stone_" .. i
|
||||
minetest.register_node(modname .. ":stone_" .. i, {
|
||||
drawtype = "glasslike",
|
||||
|
@ -5,8 +5,6 @@ local math_ceil
|
||||
= math.ceil
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local function stackgroup(stack, grp)
|
||||
stack = ItemStack(stack)
|
||||
if stack:is_empty() then return end
|
||||
|
@ -3,8 +3,6 @@ local minetest, nodecore, pairs, vector
|
||||
= minetest, nodecore, pairs, vector
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local fallname = "__builtin:falling_node"
|
||||
local fallnode = minetest.registered_entities[fallname]
|
||||
|
||||
@ -22,9 +20,9 @@ fallnode.on_step = function(self, dtime, ...)
|
||||
local vel = self.object:get_velocity()
|
||||
local v = vector.length(vel)
|
||||
local q = v * v * dtime * self.crush_damage
|
||||
for k, v in pairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||
if v:is_player() then
|
||||
nodecore.addphealth(v, -q)
|
||||
for _, o in pairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||
if o:is_player() then
|
||||
nodecore.addphealth(o, -q)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -46,7 +46,7 @@ end
|
||||
local function queuechecks(qty, name, pos)
|
||||
if qty < 1 then return end
|
||||
minetest.after(0, function()
|
||||
for i = 1, qty do
|
||||
for _ = 1, qty do
|
||||
fallcheck(name, pos)
|
||||
end
|
||||
end)
|
||||
@ -55,7 +55,7 @@ end
|
||||
local oldpos = {}
|
||||
local qtys = {}
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for i, v in ipairs(minetest.get_connected_players()) do
|
||||
for _, v in ipairs(minetest.get_connected_players()) do
|
||||
local name = v:get_player_name()
|
||||
|
||||
local pos = v:get_pos()
|
||||
@ -72,7 +72,7 @@ minetest.register_globalstep(function(dtime)
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_dignode(function(pos, oldnode, digger)
|
||||
minetest.register_on_dignode(function(pos, _, digger)
|
||||
local name = "(unknown)"
|
||||
if digger and digger.get_player_name then name = digger:get_player_name() end
|
||||
queuechecks(4, name, pos)
|
||||
|
@ -17,7 +17,7 @@ end
|
||||
|
||||
local function scan(pos, dir)
|
||||
local p = {x = pos.x, y = pos.y, z = pos.z}
|
||||
for i = 1, 16 do
|
||||
for _ = 1, 16 do
|
||||
p = vector.add(p, dir)
|
||||
local node = minetest.get_node(p)
|
||||
if node.name == "ignore" then return false, node end
|
||||
@ -56,11 +56,10 @@ local function optic_process(trans, pos)
|
||||
local ignored
|
||||
if def and def.optic_check then
|
||||
local func = function(dir)
|
||||
local hit, node = scan_recv(pos, dir)
|
||||
local hit, hnode = scan_recv(pos, dir)
|
||||
ignored = ignored or hit == false
|
||||
return hit, node
|
||||
return hit, hnode
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local nn, res = def.optic_check(pos, node, func, def)
|
||||
if (not ignored) and nn then
|
||||
trans[minetest.hash_node_position(pos)] = {
|
||||
@ -86,8 +85,8 @@ local function optic_commit(v)
|
||||
end
|
||||
|
||||
local data = {}
|
||||
for k, v in pairs(v.data or {}) do
|
||||
data[dirname(v)] = 1
|
||||
for _, vv in pairs(v.data or {}) do
|
||||
data[dirname(vv)] = 1
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(v.pos)
|
||||
|
@ -19,8 +19,8 @@ local function lens_check(pos, node, check)
|
||||
if node and node.name == modname .. ":lens_on" then lt = 14 end
|
||||
local on = ll >= lt and face.f.y == 1
|
||||
if not on then
|
||||
local node = minetest.get_node(fore)
|
||||
local def = minetest.registered_items[node.name] or {}
|
||||
local nnode = minetest.get_node(fore)
|
||||
local def = minetest.registered_items[nnode.name] or {}
|
||||
on = def.light_source and def.light_source > 4
|
||||
end
|
||||
if on then
|
||||
|
@ -5,7 +5,7 @@ local minetest, nodecore, vector
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local function prism_check(pos, node, check)
|
||||
local function prism_check(_, node, check)
|
||||
local face = nodecore.facedirs[node.param2]
|
||||
|
||||
local power = (check(face.f) or check(face.r))
|
||||
|
@ -76,13 +76,13 @@ nodecore.register_inventory_tab({
|
||||
}
|
||||
})
|
||||
|
||||
for k, v in pairs(nodecore.registered_inventory_tabs) do
|
||||
for _, v in pairs(nodecore.registered_inventory_tabs) do
|
||||
nct(v.title)
|
||||
for i = 1, #v.content do nct(v.content[i]) end
|
||||
end
|
||||
|
||||
local pad = " "
|
||||
for i = 1, 8 do pad = pad .. pad end
|
||||
for _ = 1, 8 do pad = pad .. pad end
|
||||
|
||||
local fse = minetest.formspec_escape
|
||||
function nodecore.inventory_formspec(player, curtab)
|
||||
|
@ -1,10 +1,10 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local minetest, nodecore, type
|
||||
= minetest, nodecore, type
|
||||
local minetest, nodecore
|
||||
= minetest, nodecore
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
minetest.register_item(":", {
|
||||
type = "none",
|
||||
["type"] = "none",
|
||||
wield_image = "nc_player_hand.png",
|
||||
wield_scale = {x = 4, y = 8, z = 3},
|
||||
tool_capabilities = nodecore.toolcaps({
|
||||
|
@ -60,7 +60,6 @@ local function checkinv(player)
|
||||
|
||||
local fill = size - slots
|
||||
if #inj > fill then
|
||||
local pos = player:get_pos()
|
||||
for i = 1, #inj / 2 do
|
||||
inj[i], inj[#inj + 1 - i] = inj[#inj + 1 - i], inj[i]
|
||||
end
|
||||
|
@ -47,7 +47,7 @@ local function breathhud(player)
|
||||
return player:hud_change(hud.id, "text", i)
|
||||
end
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
minetest.register_globalstep(function()
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
breathhud(player)
|
||||
end
|
||||
|
@ -54,7 +54,6 @@ minetest.after(0, function()
|
||||
end
|
||||
end)
|
||||
local function swimming(player)
|
||||
local found = 0
|
||||
local pos = player:get_pos()
|
||||
local r = 0.6
|
||||
for dz = -r, r, r do
|
||||
@ -147,7 +146,7 @@ minetest.register_on_joinplayer(function(player)
|
||||
updatevisuals(player)
|
||||
end)
|
||||
|
||||
minetest.register_globalstep(function(dt)
|
||||
minetest.register_globalstep(function()
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
updatevisuals(player)
|
||||
end
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local math, minetest, pairs, tonumber, type
|
||||
= math, minetest, pairs, tonumber, type
|
||||
local math, minetest, pairs, tonumber
|
||||
= math, minetest, pairs, tonumber
|
||||
local math_sqrt
|
||||
= math.sqrt
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
@ -33,7 +33,7 @@ minetest.register_on_leaveplayer(function(player)
|
||||
|
||||
-- Remove HUDs for this player's name
|
||||
-- from other players
|
||||
for k, v in pairs(huds) do
|
||||
for _, v in pairs(huds) do
|
||||
local i = v[pn]
|
||||
if i then
|
||||
i.o:hud_remove(i.i)
|
||||
@ -55,7 +55,7 @@ end
|
||||
|
||||
-- Determine if player 1 can see player 2's face, including
|
||||
-- checks for distance, line-of-sight, and facing direction.
|
||||
local function canseeface(p1, n1, p2, n2)
|
||||
local function canseeface(p1, p2)
|
||||
if p1:get_hp() <= 0 or p2:get_hp() <= 0 then return end
|
||||
if p1:get_attach() or p2:get_attach() then return end
|
||||
|
||||
@ -134,7 +134,7 @@ minetest.register_globalstep(function()
|
||||
if p2 ~= p1 then
|
||||
local n2 = p2:get_player_name()
|
||||
local i = h[n2]
|
||||
if canseeface(p1, n1, p2, n2) then
|
||||
if canseeface(p1, p2) then
|
||||
local p = p2:get_pos()
|
||||
p.y = p.y + 1.25
|
||||
|
||||
|
@ -7,7 +7,7 @@ local function wrapinv(inv, player)
|
||||
if not inv then return inv end
|
||||
local t = {}
|
||||
setmetatable(t, {__index = inv})
|
||||
function t:add_item(list, stack)
|
||||
function t.add_item(_, list, stack)
|
||||
return nodecore.give_item(player, stack, list, inv)
|
||||
end
|
||||
return t
|
||||
@ -17,7 +17,7 @@ local function wrapplayer(player)
|
||||
if not player then return player end
|
||||
local t = {}
|
||||
setmetatable(t, {__index = player})
|
||||
function t:get_inventory()
|
||||
function t.get_inventory()
|
||||
return wrapinv(player:get_inventory(), player)
|
||||
end
|
||||
return t
|
||||
@ -57,11 +57,11 @@ for _, cmd in ipairs({"give", "giveme"}) do
|
||||
return ...
|
||||
end
|
||||
minetest.get_player_by_name = function(...)
|
||||
local function helper(p, ...)
|
||||
local function helpest(p, ...)
|
||||
p = wrapplayer(p)
|
||||
return p, ...
|
||||
end
|
||||
return helper(oldgpbn(...))
|
||||
return helpest(oldgpbn(...))
|
||||
end
|
||||
return helper(oldfunc(...))
|
||||
end
|
||||
|
@ -28,8 +28,8 @@ local function handlepickups(player)
|
||||
local oc = old:get_count()
|
||||
if cc > oc then
|
||||
cur:set_count(cc - oc)
|
||||
for i = 1, #excess do
|
||||
cur = nodecore.stack_merge(excess[i], cur)
|
||||
for j = 1, #excess do
|
||||
cur = nodecore.stack_merge(excess[j], cur)
|
||||
end
|
||||
if not cur:is_empty() then
|
||||
excess[#excess + 1] = cur
|
||||
|
@ -26,7 +26,7 @@ local function hotpotatoes(player)
|
||||
dir.x = dir.x * 5
|
||||
dir.y = dir.y * 5 + 3
|
||||
dir.z = dir.z * 5
|
||||
for k, v in pairs(throw) do
|
||||
for _, v in pairs(throw) do
|
||||
local obj = minetest.add_item(pos, v)
|
||||
obj:set_velocity(dir)
|
||||
obj:get_luaentity().dropped_by = pname
|
||||
@ -36,7 +36,7 @@ local function hotpotatoes(player)
|
||||
end
|
||||
|
||||
minetest.register_globalstep(function()
|
||||
for k, v in pairs(minetest.get_connected_players()) do
|
||||
for _, v in pairs(minetest.get_connected_players()) do
|
||||
hotpotatoes(v)
|
||||
end
|
||||
end)
|
||||
|
@ -1,8 +1,8 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local math, minetest, table
|
||||
= math, minetest, table
|
||||
local math_random, table_remove
|
||||
= math.random, table.remove
|
||||
local minetest, table
|
||||
= minetest, table
|
||||
local table_remove
|
||||
= table.remove
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
@ -37,23 +37,10 @@ local attq = {}
|
||||
|
||||
minetest.register_entity(modname .. ":ent", {
|
||||
initial_properties = entprops(),
|
||||
on_step = function(self, dtime)
|
||||
on_step = function(self)
|
||||
local conf = self.conf
|
||||
if not conf then return self.object:remove() end
|
||||
|
||||
-- Destroy wield nodes and regenerate periodically.
|
||||
-- This fixes the view for other players in MP, but
|
||||
-- BREAKS the view for own player in 3rd-person views.
|
||||
--[[
|
||||
if self.ttl then
|
||||
self.ttl = self.ttl - dtime
|
||||
if self.ttl <= 0 then
|
||||
attq[#attq + 1] = conf
|
||||
return self.object:remove()
|
||||
end
|
||||
else self.ttl = math_random() * 5 + 5 end
|
||||
--]]
|
||||
|
||||
local player = minetest.get_player_by_name(conf.pname)
|
||||
if not player then return self.object:remove() end
|
||||
|
||||
|
@ -29,12 +29,12 @@ nodecore.register_limited_abm({
|
||||
action = function(pos)
|
||||
minetest.set_node(pos, {name = modname .. ":sponge_wet"})
|
||||
nodecore.node_sound(pos, "place")
|
||||
for _, pos in pairs(minetest.find_nodes_in_area(
|
||||
for _, p in pairs(minetest.find_nodes_in_area(
|
||||
{x = pos.x - 1, y = pos.y - 1, z = pos.z - 1},
|
||||
{x = pos.x + 1, y = pos.y + 1, z = pos.z + 1},
|
||||
{"group:water"})) do
|
||||
nodecore.node_sound(pos, "dig")
|
||||
minetest.remove_node(pos)
|
||||
nodecore.node_sound(p, "dig")
|
||||
minetest.remove_node(p)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
@ -14,7 +14,7 @@ local c_sand = minetest.get_content_id("nc_terrain:sand")
|
||||
local c_water = minetest.get_content_id("nc_terrain:water_source")
|
||||
local c_sponge = minetest.get_content_id(modname .. ":sponge_living")
|
||||
|
||||
nodecore.register_mapgen_shared(function(minp, maxp, area, data, vm, emin, emax)
|
||||
nodecore.register_mapgen_shared(function(minp, maxp, area, data)
|
||||
if minp.y > maxy or maxp.y < miny then return end
|
||||
|
||||
local function spawn(x, y, z)
|
||||
@ -28,7 +28,7 @@ nodecore.register_mapgen_shared(function(minp, maxp, area, data, vm, emin, emax)
|
||||
|
||||
local qty = math_floor(math_random() * (maxp.x - minp.x)
|
||||
* (maxp.z - minp.z) / (64 * 64))
|
||||
for n = 1, qty do
|
||||
for _ = 1, qty do
|
||||
local x = math_floor(math_random() * (maxp.x - minp.x)) + minp.x
|
||||
local z = math_floor(math_random() * (maxp.z - minp.z)) + minp.z
|
||||
local starty = maxp.y
|
||||
|
@ -75,7 +75,7 @@ nodecore.register_craft({
|
||||
|
||||
minetest.set_node(p, {name = "nc_terrain:water_source"})
|
||||
nodecore.node_sound(p, "place")
|
||||
local obj = minetest.add_entity(p, modname .. ":waterguard",
|
||||
minetest.add_entity(p, modname .. ":waterguard",
|
||||
minetest.serialize({ttl = 3}))
|
||||
end
|
||||
})
|
||||
|
@ -11,8 +11,8 @@ local modstore = minetest.get_mod_storage()
|
||||
------------------------------------------------------------------------
|
||||
-- DATABASE SETUP
|
||||
|
||||
local db = {}
|
||||
nodecore.statsdb = db
|
||||
local statsdb = {}
|
||||
nodecore.statsdb = statsdb
|
||||
|
||||
local function load_check(s)
|
||||
s = s and s ~= "" and minetest.deserialize(s)
|
||||
@ -20,7 +20,7 @@ local function load_check(s)
|
||||
end
|
||||
do
|
||||
local s = load_check(modstore:get_string(modname))
|
||||
db[false] = s
|
||||
statsdb[false] = s
|
||||
s.firstseen = s.firstseen or os_date("!*t")
|
||||
s.startup = (s.startup or 0) + 1
|
||||
end
|
||||
@ -41,21 +41,21 @@ local function dbadd_nav(qty, dirty, db, root, key, ...)
|
||||
end
|
||||
local function dbadd(qty, root, ...)
|
||||
if qty == 0 then return end
|
||||
return dbadd_nav(qty, true, db, root, ...)
|
||||
return dbadd_nav(qty, true, statsdb, root, ...)
|
||||
end
|
||||
|
||||
local function playeradd(qty, player, ...)
|
||||
if not player then return end
|
||||
local pname = (type(player) == "string") and player or player:get_player_name()
|
||||
if not pname then return end
|
||||
local data = db[pname]
|
||||
local data = statsdb[pname]
|
||||
if not data then
|
||||
data = load_check(player:get_meta():get_string(modname))
|
||||
db[pname] = data
|
||||
statsdb[pname] = data
|
||||
end
|
||||
dbadd(qty, pname, ...)
|
||||
if not db[pname].firstseen then
|
||||
db[pname].firstseen = os_date("!*t")
|
||||
if not statsdb[pname].firstseen then
|
||||
statsdb[pname].firstseen = os_date("!*t")
|
||||
end
|
||||
dbadd(qty, false, "players", ...)
|
||||
end
|
||||
@ -120,7 +120,7 @@ local function invscan(dt, player)
|
||||
t[stack:get_name()] = true
|
||||
end
|
||||
end
|
||||
for k, v in pairs(t) do
|
||||
for k in pairs(t) do
|
||||
playeradd(dt, player, "inv", k)
|
||||
end
|
||||
end
|
||||
@ -189,7 +189,7 @@ minetest.register_globalstep(function(dt)
|
||||
local opq = {}
|
||||
|
||||
local function flushkey(k)
|
||||
local v = db[k]
|
||||
local v = statsdb[k]
|
||||
if not v or not v.dirty then return end
|
||||
v.dirty = nil
|
||||
|
||||
@ -202,11 +202,11 @@ local function flushkey(k)
|
||||
local old = q[n]
|
||||
if old then
|
||||
q[n] = {}
|
||||
for k, v in pairs(old) do
|
||||
if type(v) == "number" then
|
||||
dbadd_nav(v, nil, q[n], unpackreason(k))
|
||||
for xk, xv in pairs(old) do
|
||||
if type(xv) == "number" then
|
||||
dbadd_nav(xv, nil, q[n], unpackreason(xk))
|
||||
else
|
||||
q[n][k] = v
|
||||
q[n][xk] = xv
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -233,7 +233,7 @@ end
|
||||
local function flushenq()
|
||||
minetest.after(20, flushenq)
|
||||
if #opq > 0 then return end
|
||||
for k, v in pairs(db) do
|
||||
for k in pairs(statsdb) do
|
||||
opq[#opq + 1] = k
|
||||
end
|
||||
for i = 1, #opq do
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local ipairs, minetest, nodecore, type
|
||||
= ipairs, minetest, nodecore, type
|
||||
local ipairs, minetest, nodecore
|
||||
= ipairs, minetest, nodecore
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
@ -17,7 +17,7 @@ nodecore.extend_item(chip, function(copy, orig)
|
||||
if not nodecore.interact(placer) then return end
|
||||
if itemstack:get_name() == chip and pointed_thing.type == "node" then
|
||||
local pos = pointed_thing.under
|
||||
for i, v in ipairs(nodecore.registered_stone_tip_tools) do
|
||||
for _, v in ipairs(nodecore.registered_stone_tip_tools) do
|
||||
if nodecore.match(pos, {
|
||||
name = v.from,
|
||||
wear = 0.05
|
||||
|
@ -37,15 +37,13 @@ local function grassable(above)
|
||||
if ld >= 10 then return end
|
||||
end
|
||||
|
||||
local function liquid(def) return def and def.liquidtype and def.liquidtype ~= "none" end
|
||||
|
||||
nodecore.register_limited_abm({
|
||||
label = "Grass Spread",
|
||||
nodenames = {dirt, "nc_terrain:dirt_loose"},
|
||||
neighbors = {grass},
|
||||
interval = 6,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
action = function(pos)
|
||||
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||
if not grassable(above) then return end
|
||||
return minetest.set_node(pos, {name = grass})
|
||||
@ -57,7 +55,7 @@ nodecore.register_limited_abm({
|
||||
nodenames = {grass},
|
||||
interval = 8,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
action = function(pos)
|
||||
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||
if grassable(above) ~= false then return end
|
||||
return minetest.set_node(pos, {name = dirt})
|
||||
|
@ -23,7 +23,7 @@ local function regterrain(def)
|
||||
|
||||
minetest.register_node(def.fullname, def)
|
||||
|
||||
for k, v in pairs(def.mapgen) do
|
||||
for _, v in pairs(def.mapgen) do
|
||||
minetest.register_alias("mapgen_" .. v, def.fullname)
|
||||
end
|
||||
end
|
||||
|
@ -5,8 +5,6 @@ local math_floor, math_random
|
||||
= math.floor, math.random
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local thickness = 128
|
||||
|
||||
nodecore.stratadata = nodecore.memoize(function()
|
||||
@ -31,7 +29,7 @@ nodecore.stratadata = nodecore.memoize(function()
|
||||
return data
|
||||
end)
|
||||
|
||||
nodecore.register_mapgen_shared(function(minp, maxp, area, data, vm, emin, emax)
|
||||
nodecore.register_mapgen_shared(function(minp, maxp, area, data)
|
||||
if minp.y > -64 then return end
|
||||
|
||||
local ai = area.index
|
||||
|
@ -5,12 +5,6 @@ local ItemStack, ipairs, minetest, nodecore, pairs, type
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local function meta(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
|
||||
return node, meta
|
||||
end
|
||||
|
||||
local metadescs = {
|
||||
"Tote (1 Slot)",
|
||||
"Tote (2 Slots)",
|
||||
@ -22,7 +16,7 @@ local metadescs = {
|
||||
"Tote (8 Slots)",
|
||||
}
|
||||
|
||||
local function totedug(pos, node, meta, digger)
|
||||
local function totedug(pos, _, _, digger)
|
||||
local dump
|
||||
for dx = -1, 1 do
|
||||
for dz = -1, 1 do
|
||||
@ -31,7 +25,7 @@ local function totedug(pos, node, meta, digger)
|
||||
local d = minetest.registered_items[n.name] or {}
|
||||
if d and d.groups and d.groups.totable then
|
||||
local m = minetest.get_meta(p):to_table()
|
||||
for k1, v1 in pairs(m.inventory or {}) do
|
||||
for _, v1 in pairs(m.inventory or {}) do
|
||||
for k2, v2 in pairs(v1) do
|
||||
if type(v2) == "userdata" then
|
||||
v1[k2] = v2:to_string()
|
||||
@ -58,7 +52,7 @@ local function totedug(pos, node, meta, digger)
|
||||
minetest.handle_node_drops(pos, {drop}, digger)
|
||||
end
|
||||
|
||||
local function toteplace(stack, placer, pointed)
|
||||
local function toteplace(stack, _, pointed)
|
||||
local pos = nodecore.buildable_to(pointed.under) and pointed.under
|
||||
or nodecore.buildable_to(pointed.above) and pointed.above
|
||||
if not pos then return stack end
|
||||
|
@ -9,7 +9,7 @@ nodecore.register_leaf_drops, nodecore.registered_leaf_drops
|
||||
function nodecore.leaf_decay(pos, node)
|
||||
node = node or minetest.get_node(pos)
|
||||
local t = {}
|
||||
for i, v in ipairs(nodecore.registered_leaf_drops) do
|
||||
for _, v in ipairs(nodecore.registered_leaf_drops) do
|
||||
t = v(pos, node, t) or t
|
||||
end
|
||||
local p = nodecore.pickrand(t, function(x) return x.prob end)
|
||||
|
@ -28,7 +28,7 @@ minetest.register_node(modname .. ":eggcorn", {
|
||||
node_placement_prediction = "",
|
||||
place_as_item = true,
|
||||
sounds = nodecore.sounds("nc_tree_corny"),
|
||||
stack_rightclick = function(pos, node, whom, stack)
|
||||
stack_rightclick = function(pos, _, whom, stack)
|
||||
if nodecore.stack_get(pos):get_count() ~= 1 then return end
|
||||
if stack:get_name() ~= ldname then return end
|
||||
|
||||
@ -56,7 +56,7 @@ nodecore.register_limited_abm({
|
||||
end
|
||||
})
|
||||
|
||||
nodecore.register_leaf_drops(function(pos, node, list)
|
||||
nodecore.register_leaf_drops(function(_, node, list)
|
||||
list[#list + 1] = {
|
||||
name = "air",
|
||||
item = modname .. ":eggcorn",
|
||||
@ -73,7 +73,7 @@ nodecore.register_limited_abm({
|
||||
nodenames = {epname},
|
||||
interval = 10,
|
||||
chance = 1,
|
||||
action = function(pos, node)
|
||||
action = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local d = 0
|
||||
local w = 1
|
||||
|
@ -1,6 +1,6 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local minetest, nodecore, type
|
||||
= minetest, nodecore, type
|
||||
local minetest, nodecore
|
||||
= minetest, nodecore
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
@ -65,9 +65,7 @@ minetest.register_node(modname .. ":leaves", {
|
||||
},
|
||||
sounds = nodecore.sounds("nc_terrain_swishy")
|
||||
})
|
||||
nodecore.register_leaf_drops(function(pos, node, list)
|
||||
nodecore.register_leaf_drops(function(_, _, list)
|
||||
list[#list + 1] = {name = modname .. ":leaves_loose", prob = 0.5}
|
||||
list[#list + 1] = {name = "air"}
|
||||
end)
|
||||
|
||||
local function fixed(t) return {type = "fixed", fixed = t} end
|
||||
|
@ -25,7 +25,7 @@ minetest.register_node(modname .. ":stick", {
|
||||
sounds = nodecore.sounds("nc_tree_sticky")
|
||||
})
|
||||
|
||||
nodecore.register_leaf_drops(function(pos, node, list)
|
||||
nodecore.register_leaf_drops(function(_, node, list)
|
||||
list[#list + 1] = {
|
||||
name = modname .. ":stick",
|
||||
prob = 0.2 * (node.param2 * node.param2)}
|
||||
|
@ -39,7 +39,7 @@ minetest.register_node(modname .. ":shelf", {
|
||||
inv:set_size("solo", 1)
|
||||
nodecore.visinv_update_ents(pos)
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker, stack, pointed_thing)
|
||||
on_rightclick = function(pos, _, clicker, stack, pointed_thing)
|
||||
if not nodecore.interact(clicker) then return end
|
||||
if pointed_thing.above.y ~= pointed_thing.under.y then return end
|
||||
if not stack or stack:is_empty() then return end
|
||||
@ -60,7 +60,7 @@ minetest.register_node(modname .. ":shelf", {
|
||||
return minetest.node_dig(pos, node, digger, ...)
|
||||
end
|
||||
end,
|
||||
stack_allow = function(pos, node, stack)
|
||||
stack_allow = function(_, _, stack)
|
||||
local def = minetest.registered_items[stack:get_name()] or {}
|
||||
if def.groups and def.groups.container then return false end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user