Fix most luacheck issues.

There are 3 false positives remaining after this patch, so
the bulk of the issues are fixed now.
This commit is contained in:
Auke Kok 2016-12-15 14:24:11 -08:00 committed by Auke Kok
parent 138e078f1b
commit 923198a2dd
20 changed files with 73 additions and 91 deletions

View File

@ -12,5 +12,12 @@ read_globals = {
"default",
"stairsplus",
"signs_lib",
"beds",
"technic",
"mesecon",
}
globals = {
"armor",
}

View File

@ -2,19 +2,18 @@ computer = {}
screwdriver = screwdriver or {}
computer.register = function (name, def)
local nodename = name
if (name:sub(1, 1) == ":") then name = name:sub(2) end
local modname, basename = name:match("^([^:]+):(.*)")
local TEXPFX = modname.."_"..basename.."_"
local ONSTATE = modname..":"..basename
local OFFSTATE = modname..":"..basename.."_off"
local def = def
local cdef = table.copy(def)
minetest.register_node(ONSTATE, {
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
description = def.description,
inventory_image = def.inventory_image,
description = cdef.description,
inventory_image = cdef.inventory_image,
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
tiles = {
TEXPFX.."tp.png",
@ -24,10 +23,10 @@ computer.register = function (name, def)
TEXPFX.."bk.png",
TEXPFX.."ft.png"
},
node_box = def.node_box,
selection_box = def.node_box,
node_box = cdef.node_box,
selection_box = cdef.node_box,
on_rightclick = function (pos, node, clicker, itemstack)
if def.on_turn_off and def.on_turn_off(pos, node, clicker, itemstack) then
if cdef.on_turn_off and cdef.on_turn_off(pos, node, clicker, itemstack) then
return itemstack
end
node.name = OFFSTATE
@ -41,17 +40,17 @@ computer.register = function (name, def)
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
tiles = {
(TEXPFX.."tp"..(def.tiles_off.top and "_off" or "")..".png"),
(TEXPFX.."bt"..(def.tiles_off.bottom and "_off" or "")..".png"),
(TEXPFX.."rt"..(def.tiles_off.right and "_off" or "")..".png"),
(TEXPFX.."lt"..(def.tiles_off.left and "_off" or "")..".png"),
(TEXPFX.."bk"..(def.tiles_off.back and "_off" or "")..".png"),
(TEXPFX.."ft"..(def.tiles_off.front and "_off" or "")..".png")
(TEXPFX.."tp"..(cdef.tiles_off.top and "_off" or "")..".png"),
(TEXPFX.."bt"..(cdef.tiles_off.bottom and "_off" or "")..".png"),
(TEXPFX.."rt"..(cdef.tiles_off.right and "_off" or "")..".png"),
(TEXPFX.."lt"..(cdef.tiles_off.left and "_off" or "")..".png"),
(TEXPFX.."bk"..(cdef.tiles_off.back and "_off" or "")..".png"),
(TEXPFX.."ft"..(cdef.tiles_off.front and "_off" or "")..".png")
},
node_box = def.node_box_off or def.node_box,
selection_box = def.node_box_off or def.node_box,
node_box = cdef.node_box_off or cdef.node_box,
selection_box = cdef.node_box_off or cdef.node_box,
on_rightclick = function (pos, node, clicker, itemstack)
if def.on_turn_on and def.on_turn_on(pos, node, clicker, itemstack) then
if cdef.on_turn_on and cdef.on_turn_on(pos, node, clicker, itemstack) then
return itemstack
end
node.name = ONSTATE
@ -63,13 +62,10 @@ computer.register = function (name, def)
end
computer.register_handheld = function (name, def)
local nodename = name
if (name:sub(1, 1) == ":") then name = name:sub(2) end
local modname, basename = name:match("^([^:]+):(.*)")
local TEXPFX = modname.."_"..basename.."_inv"
local ONSTATE = modname..":"..basename
local OFFSTATE = modname..":"..basename.."_off"
local on_use = def.on_use
minetest.register_craftitem(ONSTATE, {
description = def.description,
inventory_image = TEXPFX..".png",
@ -79,8 +75,7 @@ end
computer.pixelnodebox = function (size, boxes)
local fixed = { }
local i, box
for i, box in ipairs(boxes) do
for _, box in ipairs(boxes) do
local x, y, z, w, h, l = unpack(box)
fixed[#fixed + 1] = {
(x / size) - 0.5,

View File

@ -71,7 +71,7 @@ local function step(pos, fields)
local meta = minetest.get_meta(pos)
local t = minetest.deserialize(meta:get_string("tetris"))
local function new_game(pos)
local function new_game(p)
local nex = math.random(7)
t = {
@ -84,7 +84,7 @@ local function step(pos, fields)
x=4, y=0, rot=1
}
local timer = minetest.get_node_timer(pos)
local timer = minetest.get_node_timer(p)
timer:set(0.3, 0)
end

View File

@ -8,8 +8,8 @@ local function start_smoke(pos, node, clicker, chimney)
if id ~= 0 then
if s_handle then
minetest.after(0, function(s_handle)
minetest.sound_stop(s_handle)
minetest.after(0, function(handle)
minetest.sound_stop(handle)
end, s_handle)
end
minetest.delete_particlespawner(id)
@ -30,7 +30,6 @@ local function start_smoke(pos, node, clicker, chimney)
texture = "smoke_particle.png",
})
if chimney == 1 then
s_handle = nil
this_spawner_meta:set_int("smoky", id)
this_spawner_meta:set_int("sound", nil)
else
@ -42,7 +41,7 @@ local function start_smoke(pos, node, clicker, chimney)
this_spawner_meta:set_int("smoky", id)
this_spawner_meta:set_int("sound", s_handle)
end
return end
end
end
local function stop_smoke(pos)
@ -55,8 +54,8 @@ local function stop_smoke(pos)
end
if s_handle then
minetest.after(0, function(s_handle)
minetest.sound_stop(s_handle)
minetest.after(0, function(handle)
minetest.sound_stop(handle)
end, s_handle)
end

View File

@ -78,7 +78,6 @@ homedecor.register("desk_fan", {
entity_remove[1]:setyaw(0)
end
end
local entity_anim = minetest.get_objects_inside_radius(pos, 0.1)
if minetest.get_meta(pos):get_string("active") == "no" then
entity_anim[1]:set_animation({x=0,y=0}, 1, 0)
elseif minetest.get_meta(pos):get_string("active") == "yes" then

View File

@ -4,8 +4,8 @@ local S = homedecor.gettext
-- doors
local function isSolid(pos,adj)
local adj = {x=adj[1],y=adj[2],z=adj[3]}
local function isSolid(pos, adjust)
local adj = {x = adjust[1], y = adjust[2], z = adjust[3]}
local node = minetest.get_node(vector.add(pos,adj))
if node then
local idef = minetest.registered_nodes[minetest.get_node(vector.add(pos,adj)).name]
@ -42,14 +42,12 @@ local function calculateClosed(pos)
local node = minetest.get_node(pos)
-- the door is considered closed if it is closing off something.
local solids = 0
local direction = node.param2 % 6
local isTrap = direction == 0 or direction == 5
if isTrap then
-- the trap door is considered closed when all nodes on its sides are solid
-- or all nodes in the 3x3 above/below it are solid except the center
for level = 0, 1 do
local fail = false
local solids = countSolids(pos,node,level)
if solids == 8 then
return true
@ -99,7 +97,6 @@ local function calculateClosed(pos)
end
return false
end
error("What direction is this???",direction)
end
end
@ -448,8 +445,8 @@ function homedecor.flip_door(pos, node, player, name, side, isClosed)
-- and if not isClosed, a closed door
isClosed = not isClosed
local rside = nil
local nfdir = nil
local rside
local nfdir
local ofdir = node.param2 or 0
if side == "left" then
rside = "right"
@ -485,7 +482,7 @@ function homedecor.flip_gate(pos, node, player, gate, oc)
-- since right facing gates use "open" nodes for closed, we need an
-- isClosed flag to tell if it's "really" closed.
local gateresult = nil
local gateresult
if oc == "closed" then
gateresult = "homedecor:gate_"..gate.."_open"
else

View File

@ -268,8 +268,6 @@ homedecor.register("swing", {
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
for j = 0, height do -- then fill that space with ropes...
local testpos = { x=pos.x, y=pos.y-j, z=pos.z }
local testnode = minetest.get_node(testpos)
local testreg = core.registered_nodes[testnode.name]
minetest.set_node(testpos, { name = "homedecor:swing_rope", param2 = fdir })
end

View File

@ -1,4 +1,3 @@
local S = homedecor.gettext
homedecor.register("coatrack_wallmount", {
tiles = { homedecor.plain_wood },

View File

@ -1,4 +1,3 @@
local S = homedecor.gettext
local cutlery_cbox = {
type = "fixed",

View File

@ -1,4 +1,3 @@
local S = homedecor.gettext
-- vectors to place one node next to or behind another
@ -67,8 +66,8 @@ end
local function stack(itemstack, placer, fdir, pos, def, pos2, node1, node2)
local placer_name = placer:get_player_name() or ""
if is_buildable_to(placer_name, pos, pos2) then
local fdir = fdir or minetest.dir_to_facedir(placer:get_look_dir())
minetest.set_node(pos, { name = node1, param2 = fdir })
local lfdir = fdir or minetest.dir_to_facedir(placer:get_look_dir())
minetest.set_node(pos, { name = node1, param2 = lfdir })
node2 = node2 or "air" -- this can be used to clear buildable_to nodes even though we are using a multinode mesh
-- do not assume by default, as we still might want to allow overlapping in some cases
local has_facedir = node2 ~= "air"
@ -76,7 +75,7 @@ local function stack(itemstack, placer, fdir, pos, def, pos2, node1, node2)
has_facedir = false
node2 = placeholder_node
end
minetest.set_node(pos2, { name = node2, param2 = (has_facedir and fdir) or nil })
minetest.set_node(pos2, { name = node2, param2 = (has_facedir and lfdir) or nil })
-- call after_place_node of the placed node if available
local ctrl_node_def = minetest.registered_nodes[node1]
@ -228,7 +227,7 @@ function homedecor.place_banister(itemstack, placer, pointed_thing)
local rightclick_result = rightclick_pointed_thing(pointed_thing.under, placer, itemstack)
if rightclick_result then return rightclick_result end
local pos, def = select_node(pointed_thing)
local pos, _ = select_node(pointed_thing)
if not pos then return itemstack end
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
@ -270,20 +269,19 @@ function homedecor.place_banister(itemstack, placer, pointed_thing)
local left_fwd_below_pos = { x=pos.x+lxd+fxd, y=pos.y-1, z=pos.z+lzd+fzd }
local below_node = minetest.get_node(below_pos)
local fwd_node = minetest.get_node(fwd_pos)
--local fwd_node = minetest.get_node(fwd_pos)
local left_node = minetest.get_node(left_pos)
local right_node = minetest.get_node(right_pos)
local left_fwd_node = minetest.get_node(left_fwd_pos)
local right_fwd_node = minetest.get_node(right_fwd_pos)
local left_below_node = minetest.get_node({x=left_pos.x, y=left_pos.y-1, z=left_pos.z})
local right_below_node = minetest.get_node({x=right_pos.x, y=right_pos.y-1, z=right_pos.z})
local right_fwd_above_node = minetest.get_node(right_fwd_above_pos)
local left_fwd_above_node = minetest.get_node(left_fwd_above_pos)
--local right_fwd_above_node = minetest.get_node(right_fwd_above_pos)
--local left_fwd_above_node = minetest.get_node(left_fwd_above_pos)
local right_fwd_below_node = minetest.get_node(right_fwd_below_pos)
local left_fwd_below_node = minetest.get_node(left_fwd_below_pos)
local new_place_name = itemstack:get_name()
local n = 0
-- try to place a diagonal one on the side of blocks stacked like stairs
-- or follow an existing diagonal with another.

View File

@ -171,28 +171,28 @@ function homedecor.register_furnace(name, furnacedef)
end
end
local name_active = name.."_active"
local n_active = name.."_active"
homedecor.register(name, def)
homedecor.register(name_active, def_active)
homedecor.register(n_active, def_active)
local name, name_active = "homedecor:"..name, "homedecor:"..name_active
local nname, name_active = "homedecor:"..name, "homedecor:"..n_active
minetest.register_abm({
nodenames = {name, name_active, name.."_locked", name_active.."_locked"},
nodenames = {nname, name_active, nname.."_locked", name_active.."_locked"},
label = "furnaces",
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
for i, name in ipairs({
for i, pname in ipairs({
"fuel_totaltime",
"fuel_time",
"src_totaltime",
"src_time"
}) do
if meta:get_string(name) == "" then
meta:set_float(name, 0.0)
if meta:get_string(pname) == "" then
meta:set_float(pname, 0.0)
end
end
@ -239,9 +239,9 @@ function homedecor.register_furnace(name, furnacedef)
local fuel = nil
local afterfuel
local cooked = nil
cooked = nil
local fuellist = inv:get_list("fuel")
local srclist = inv:get_list("src")
srclist = inv:get_list("src")
if srclist then
cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
@ -252,7 +252,7 @@ function homedecor.register_furnace(name, furnacedef)
if (not fuel) or (fuel.time <= 0) then
meta:set_string("infotext",desc..S(": Out of fuel"))
swap_node(pos, name..locked)
swap_node(pos, nname..locked)
meta:set_string("formspec", make_formspec(furnacedef, 0))
return
end
@ -260,7 +260,7 @@ function homedecor.register_furnace(name, furnacedef)
if cooked.item:is_empty() then
if was_active then
meta:set_string("infotext",S("%s is empty"):format(desc))
swap_node(pos, name..locked)
swap_node(pos, nname..locked)
meta:set_string("formspec", make_formspec(furnacedef, 0))
end
return
@ -268,7 +268,7 @@ function homedecor.register_furnace(name, furnacedef)
if not inv:room_for_item("dst", cooked.item) then
meta:set_string("infotext", desc..S(": output bins are full"))
swap_node(pos, name..locked)
swap_node(pos, nname..locked)
meta:set_string("formspec", make_formspec(furnacedef, 0))
return
end

View File

@ -1,5 +1,5 @@
homedecor = homedecor or {}
local S = homedecor.gettext
local placeholder_node = "homedecor:expansion_placeholder"
--wrapper around minetest.register_node that sets sane defaults and interprets some specialized settings

View File

@ -1,5 +1,6 @@
function homedecor.sit(pos, node, clicker)
do return end -- delete it when the engine is stabler for the player's physics
return -- delete it when the engine is stabler for the player's physics
--[[
local meta = minetest.get_meta(pos)
local param2 = node.param2
local name = clicker:get_player_name()
@ -29,4 +30,5 @@ function homedecor.sit(pos, node, clicker)
clicker:set_look_yaw(4.75)
else return end
end
--]]
end

View File

@ -25,8 +25,8 @@ function homedecor.start_particle_spawner(pos, node, particledef, soundname)
if id ~= 0 then
if s_handle then
minetest.after(0, function(s_handle)
minetest.sound_stop(s_handle)
minetest.after(0, function(handle)
minetest.sound_stop(handle)
end, s_handle)
end
minetest.delete_particlespawner(id)
@ -104,8 +104,8 @@ function homedecor.stop_particle_spawner(pos)
end
if s_handle then
minetest.after(0, function(s_handle)
minetest.sound_stop(s_handle)
minetest.after(0, function(handle)
minetest.sound_stop(handle)
end, s_handle)
end

View File

@ -32,9 +32,6 @@ function homedecor.find_ceiling(itemstack, placer, pointed_thing)
itemstack, pointed_thing)
return
end
local pitch = placer:get_look_pitch()
local fdir = core.dir_to_facedir(placer:get_look_dir())
local wield_name = itemstack:get_name()
local above = pointed_thing.above
local under = pointed_thing.under
@ -50,7 +47,6 @@ function homedecor.find_ceiling(itemstack, placer, pointed_thing)
if undef and undef.buildable_to then
pos = pointed_thing.under
node = unode
iswall = false
end
if core.is_protected(pos, placer:get_player_name()) then

View File

@ -1,6 +1,5 @@
-- This file supplies glowlights
local dirs1 = { 20, 23, 22, 21 }
local dirs2 = { 9, 18, 7, 12 }
local S = homedecor.gettext
@ -394,8 +393,6 @@ homedecor.register("lattice_lantern_small", {
local repl = { off="low", low="med", med="hi", hi="max", max="off", }
local brights_tab = { 0, 50, 100, 150, 200 }
local lamp_colors = {
{"white", "#ffffffe0:175"},
{"blue", "#2626c6e0:200"},

View File

@ -1,7 +1,7 @@
-- Various kinds of tables
local S = homedecor.gettext
-- Various kinds of tables
local materials = {
{"glass","Glass"},
{"wood","Wood"}
@ -15,7 +15,7 @@ local tables_cbox = {
for i in ipairs(materials) do
local m = materials[i][1]
local d = materials[i][2]
local s = nil
local s
if m == "glass" then
s = default.node_sound_glass_defaults()
@ -154,7 +154,7 @@ homedecor.register("utility_table_top", {
-- Various kinds of table legs
local materials = {"brass", "wrought_iron"}
materials = {"brass", "wrought_iron"}
for _, t in ipairs(materials) do
homedecor.register("table_legs_"..t, {

View File

@ -1,4 +1,3 @@
local S = homedecor.gettext
local tg_cbox = {
type = "fixed",

View File

@ -1,4 +1,3 @@
local S = homedecor.gettext
local wd_cbox = {
type = "fixed",
@ -43,7 +42,6 @@ homedecor.register("wardrobe", {
"listring[]")
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
local skins = {"male1", "male2", "male3", "male4", "male5"}
local playerName = sender:get_player_name()
local armor_mod = minetest.get_modpath("3d_armor")

View File

@ -45,7 +45,6 @@ minetest.register_node("inbox:empty", {
local meta = minetest.get_meta(pos)
local player = clicker:get_player_name()
local owner = meta:get_string("owner")
local meta = minetest.get_meta(pos)
if owner == player then
minetest.show_formspec(
clicker:get_player_name(),