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

@ -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