diff --git a/worldedit/primitives.lua b/worldedit/primitives.lua index 0a7d175..0a73f7f 100644 --- a/worldedit/primitives.lua +++ b/worldedit/primitives.lua @@ -278,7 +278,7 @@ function worldedit.spiral(pos, length, height, spacer, node_name) -- Add first column local count = height local column = i - for y = 1, height do + for _ = 1, height do data[column] = node_id column = column + stride.y end @@ -296,12 +296,12 @@ function worldedit.spiral(pos, length, height, spacer, node_name) segment_length = segment_length + spacer end -- Fill segment - for index = 1, segment_length do + for _ = 1, segment_length do -- Move along the direction of the segment i = i + stride_axis * sign local column = i -- Add column - for y = 1, height do + for _ = 1, height do data[column] = node_id column = column + stride.y end @@ -312,11 +312,11 @@ function worldedit.spiral(pos, length, height, spacer, node_name) -- Add shorter final segment sign = -sign - for index = 1, segment_length do + for _ = 1, segment_length do i = i + stride_axis * sign local column = i -- Add column - for y = 1, height do + for _ = 1, height do data[column] = node_id column = column + stride.y end diff --git a/worldedit/serialization.lua b/worldedit/serialization.lua index c3793b2..02ef44e 100644 --- a/worldedit/serialization.lua +++ b/worldedit/serialization.lua @@ -165,7 +165,7 @@ local function load_schematic(value) nodes = tables[1] if version == 1 then --original flat table format - for i, entry in ipairs(nodes) do + for _, entry in ipairs(nodes) do local pos = entry[1] entry.x, entry.y, entry.z = pos.x, pos.y, pos.z entry[1] = nil @@ -214,7 +214,7 @@ function worldedit.allocate_with_nodes(origin_pos, nodes) local pos1x, pos1y, pos1z = huge, huge, huge local pos2x, pos2y, pos2z = -huge, -huge, -huge local origin_x, origin_y, origin_z = origin_pos.x, origin_pos.y, origin_pos.z - for i, entry in ipairs(nodes) do + for _, entry in ipairs(nodes) do local x, y, z = origin_x + entry.x, origin_y + entry.y, origin_z + entry.z if x < pos1x then pos1x = x end if y < pos1y then pos1y = y end @@ -242,7 +242,7 @@ function worldedit.deserialize(origin_pos, value) local origin_x, origin_y, origin_z = origin_pos.x, origin_pos.y, origin_pos.z local count = 0 local add_node, get_meta = minetest.add_node, minetest.get_meta - for i, entry in ipairs(nodes) do + for _, entry in ipairs(nodes) do entry.x, entry.y, entry.z = origin_x + entry.x, origin_y + entry.y, origin_z + entry.z -- Entry acts as both position and node add_node(entry, entry) diff --git a/worldedit_brush/init.lua b/worldedit_brush/init.lua index 78c1bd1..2637844 100644 --- a/worldedit_brush/init.lua +++ b/worldedit_brush/init.lua @@ -65,7 +65,7 @@ minetest.register_tool(":worldedit:brush", { inventory_image = "worldedit_brush.png", stack_max = 1, -- no need to stack these (metadata prevents this anyway) range = 0, - on_use = function(itemstack, placer, pointed_thing) + on_use = function(itemstack, placer) brush_on_use(itemstack, placer) return itemstack -- nothing consumed, nothing changed end, diff --git a/worldedit_commands/cuboid.lua b/worldedit_commands/cuboid.lua index 93e45fa..eb3f327 100644 --- a/worldedit_commands/cuboid.lua +++ b/worldedit_commands/cuboid.lua @@ -239,7 +239,7 @@ worldedit.register_command("cubeapply", { end return true, sidex, sidey, sidez, cmd, parsed end, - nodes_needed = function(name, sidex, sidey, sidez, cmd, parsed) + nodes_needed = function(_, sidex, sidey, sidez) -- its not possible to defer to the target command at this point return sidex * sidey * sidez end, diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua index 1cdb107..61103dd 100644 --- a/worldedit_commands/init.lua +++ b/worldedit_commands/init.lua @@ -88,7 +88,7 @@ function worldedit.register_command(name, def) def.require_pos = def.require_pos or 0 assert(def.require_pos >= 0 and def.require_pos < 3) if def.params == "" and not def.parse then - def.parse = function(param) return true end + def.parse = function() return true end else assert(def.parse) end @@ -470,7 +470,7 @@ worldedit.register_command("fixedpos", { end, }) -minetest.register_on_punchnode(function(pos, node, puncher) +minetest.register_on_punchnode(function(pos, _, puncher) local name = puncher:get_player_name() if name ~= "" and worldedit.set_pos[name] ~= nil then --currently setting position if worldedit.set_pos[name] == "pos1" then --setting position 1 @@ -579,7 +579,7 @@ worldedit.register_command("mix", { for nodename in param:gmatch("[^%s]+") do if tonumber(nodename) ~= nil and #nodes > 0 then local last_node = nodes[#nodes] - for i = 1, tonumber(nodename) do + for _ = 1, tonumber(nodename) do nodes[#nodes + 1] = last_node end else @@ -665,7 +665,7 @@ worldedit.register_command("hollowcube", { privs = {worldedit=true}, require_pos = 1, parse = check_cube, - nodes_needed = function(name, w, h, l, node) + nodes_needed = function(_, w, h, l) return w * h * l end, func = function(name, w, h, l, node) @@ -680,7 +680,7 @@ worldedit.register_command("cube", { privs = {worldedit=true}, require_pos = 1, parse = check_cube, - nodes_needed = function(name, w, h, l, node) + nodes_needed = function(_, w, h, l) return w * h * l end, func = function(name, w, h, l, node) @@ -707,7 +707,7 @@ worldedit.register_command("hollowsphere", { privs = {worldedit=true}, require_pos = 1, parse = check_sphere, - nodes_needed = function(name, radius, node) + nodes_needed = function(_, radius) return math.ceil((4 * math.pi * (radius ^ 3)) / 3) --volume of sphere end, func = function(name, radius, node) @@ -722,7 +722,7 @@ worldedit.register_command("sphere", { privs = {worldedit=true}, require_pos = 1, parse = check_sphere, - nodes_needed = function(name, radius, node) + nodes_needed = function(_, radius) return math.ceil((4 * math.pi * (radius ^ 3)) / 3) --volume of sphere end, func = function(name, radius, node) @@ -749,7 +749,7 @@ worldedit.register_command("hollowdome", { privs = {worldedit=true}, require_pos = 1, parse = check_dome, - nodes_needed = function(name, radius, node) + nodes_needed = function(_, radius) return math.ceil((2 * math.pi * (radius ^ 3)) / 3) --volume of dome end, func = function(name, radius, node) @@ -764,7 +764,7 @@ worldedit.register_command("dome", { privs = {worldedit=true}, require_pos = 1, parse = check_dome, - nodes_needed = function(name, radius, node) + nodes_needed = function(_, radius) return math.ceil((2 * math.pi * (radius ^ 3)) / 3) --volume of dome end, func = function(name, radius, node) @@ -797,7 +797,7 @@ worldedit.register_command("hollowcylinder", { privs = {worldedit=true}, require_pos = 1, parse = check_cylinder, - nodes_needed = function(name, axis, length, radius1, radius2, node) + nodes_needed = function(_, _, length, radius1, radius2) local radius = math.max(radius1, radius2) return math.ceil(math.pi * (radius ^ 2) * length) end, @@ -818,7 +818,7 @@ worldedit.register_command("cylinder", { privs = {worldedit=true}, require_pos = 1, parse = check_cylinder, - nodes_needed = function(name, axis, length, radius1, radius2, node) + nodes_needed = function(_, _, length, radius1, radius2) local radius = math.max(radius1, radius2) return math.ceil(math.pi * (radius ^ 2) * length) end, @@ -851,7 +851,7 @@ worldedit.register_command("hollowpyramid", { privs = {worldedit=true}, require_pos = 1, parse = check_pyramid, - nodes_needed = function(name, axis, height, node) + nodes_needed = function(_, _, height) return math.ceil(((height * 2 + 1) ^ 2) * height / 3) end, func = function(name, axis, height, node) @@ -871,7 +871,7 @@ worldedit.register_command("pyramid", { privs = {worldedit=true}, require_pos = 1, parse = check_pyramid, - nodes_needed = function(name, axis, height, node) + nodes_needed = function(_, _, height) return math.ceil(((height * 2 + 1) ^ 2) * height / 3) end, func = function(name, axis, height, node) @@ -901,7 +901,7 @@ worldedit.register_command("spiral", { end return true, tonumber(length), tonumber(height), tonumber(space), node end, - nodes_needed = function(name, length, height, space, node) + nodes_needed = function(_, length, height, space) return (length + space) * height -- TODO: this is not the upper bound end, func = function(name, length, height, space, node) @@ -922,7 +922,7 @@ worldedit.register_command("copy", { end return true, axis, tonumber(amount) end, - nodes_needed = function(name, axis, amount) + nodes_needed = function(name) return check_region(name) * 2 end, func = function(name, axis, amount) @@ -949,7 +949,7 @@ worldedit.register_command("move", { end return true, axis, tonumber(amount) end, - nodes_needed = function(name, axis, amount) + nodes_needed = function(name) return check_region(name) * 2 end, func = function(name, axis, amount) @@ -981,7 +981,7 @@ worldedit.register_command("stack", { end return true, axis, tonumber(repetitions) end, - nodes_needed = function(name, axis, repetitions) + nodes_needed = function(name, _, repetitions) return check_region(name) * math.abs(repetitions) end, func = function(name, axis, repetitions) @@ -1016,7 +1016,7 @@ worldedit.register_command("stack2", { return true, tonumber(repetitions), {x=tonumber(x), y=tonumber(y), z=tonumber(z)} end, - nodes_needed = function(name, repetitions, offset) + nodes_needed = function(name, repetitions) return check_region(name) * repetitions end, func = function(name, repetitions, offset) @@ -1480,7 +1480,7 @@ worldedit.register_command("load", { minetest.get_worldpath() .. "/schems/" .. param .. ".wem", } local file, err - for index, path in ipairs(testpaths) do + for _, path in ipairs(testpaths) do file, err = io.open(path, "rb") if not err then break @@ -1633,7 +1633,7 @@ worldedit.register_command("mtschemprob", { if problist == nil then return end - for k,v in pairs(problist) do + for _,v in pairs(problist) do local prob = math.floor(((v.prob / 256) * 100) * 100 + 0.5) / 100 text = text .. minetest.pos_to_string(v.pos) .. ": " .. prob .. "% | " end diff --git a/worldedit_commands/mark.lua b/worldedit_commands/mark.lua index a195280..d43e8fc 100644 --- a/worldedit_commands/mark.lua +++ b/worldedit_commands/mark.lua @@ -134,17 +134,17 @@ minetest.register_entity(":worldedit:pos1", { physical = false, static_save = false, }, - on_activate = function(self, staticdata, dtime_s) + on_activate = function(self, staticdata) if staticdata ~= init_sentinel then -- we were loaded from before static_save = false was added self.object:remove() end end, - on_punch = function(self, hitter) + on_punch = function(self) self.object:remove() worldedit.marker1[self.player_name] = nil end, - on_blast = function(self, damage) + on_blast = function() return false, false, {} -- don't damage or knockback end, }) @@ -160,17 +160,17 @@ minetest.register_entity(":worldedit:pos2", { physical = false, static_save = false, }, - on_activate = function(self, staticdata, dtime_s) + on_activate = function(self, staticdata) if staticdata ~= init_sentinel then -- we were loaded from before static_save = false was added self.object:remove() end end, - on_punch = function(self, hitter) + on_punch = function(self) self.object:remove() worldedit.marker2[self.player_name] = nil end, - on_blast = function(self, damage) + on_blast = function() return false, false, {} -- don't damage or knockback end, }) @@ -183,13 +183,13 @@ minetest.register_entity(":worldedit:region_cube", { physical = false, static_save = false, }, - on_activate = function(self, staticdata, dtime_s) + on_activate = function(self, staticdata) if staticdata ~= init_sentinel then -- we were loaded from before static_save = false was added self.object:remove() end end, - on_punch = function(self, hitter) + on_punch = function(self) local markers = worldedit.marker_region[self.player_name] if not markers then return @@ -199,7 +199,7 @@ minetest.register_entity(":worldedit:region_cube", { end worldedit.marker_region[self.player_name] = nil end, - on_blast = function(self, damage) + on_blast = function() return false, false, {} -- don't damage or knockback end, }) diff --git a/worldedit_commands/wand.lua b/worldedit_commands/wand.lua index faa77ff..37b9f31 100644 --- a/worldedit_commands/wand.lua +++ b/worldedit_commands/wand.lua @@ -14,7 +14,7 @@ minetest.register_tool(":worldedit:wand", { stack_max = 1, -- there is no need to have more than one liquids_pointable = true, -- ground with only water on can be selected as well - on_use = function(itemstack, placer, pointed_thing) + on_use = function(_, placer, pointed_thing) if placer == nil or pointed_thing == nil then return end local name = placer:get_player_name() if pointed_thing.type == "node" then diff --git a/worldedit_gui/functionality.lua b/worldedit_gui/functionality.lua index 2efbf9a..84016e2 100644 --- a/worldedit_gui/functionality.lua +++ b/worldedit_gui/functionality.lua @@ -39,7 +39,7 @@ setmetatable(angle_values, {__index = function () return 90 end}) -- given multiple sets of privileges, produces a single set of privs that would have the same effect as requiring all of them at the same time local combine_privs = function(...) local result = {} - for i, privs in ipairs({...}) do + for _, privs in ipairs({...}) do for name, value in pairs(privs) do if result[name] ~= nil and result[name] ~= value then --the priv must be both true and false, which can never happen return {__fake_priv_that_nobody_has__=true} --privilege table that can never be satisfied diff --git a/worldedit_gui/init.lua b/worldedit_gui/init.lua index 08ecc1b..3aab382 100644 --- a/worldedit_gui/init.lua +++ b/worldedit_gui/init.lua @@ -41,7 +41,7 @@ Example: worldedit.register_gui_handler = function(identifier, handler) local enabled = true - minetest.register_on_player_receive_fields(function(player, formname, fields) + minetest.register_on_player_receive_fields(function(player, _, fields) if not enabled then return false end enabled = false minetest.after(0.2, function() enabled = true end) @@ -85,7 +85,7 @@ if minetest.global_exists("unified_inventory") then -- unified inventory install end, }) - minetest.register_on_player_receive_fields(function(player, formname, fields) + minetest.register_on_player_receive_fields(function(player, _, fields) local name = player:get_player_name() if fields.worldedit_gui then --main page worldedit.show_page(name, "worldedit_gui") @@ -116,7 +116,7 @@ elseif minetest.global_exists("inventory_plus") then -- inventory++ installed --show the form when the button is pressed and hide it when done local gui_player_formspecs = {} - minetest.register_on_player_receive_fields(function(player, formname, fields) + minetest.register_on_player_receive_fields(function(player, _, fields) local name = player:get_player_name() if fields.worldedit_gui then --main page gui_player_formspecs[name] = player:get_inventory_formspec() @@ -158,7 +158,7 @@ elseif minetest.global_exists("smart_inventory") then -- smart_inventory install codebox:set_we_formspec("worldedit_gui") -- process input (the back button) - state:onInput(function(state, fields, player) + state:onInput(function(state, fields) if fields.worldedit_gui then --main page state:get("code"):set_we_formspec("worldedit_gui") elseif fields.worldedit_gui_exit then --return to original page @@ -198,7 +198,7 @@ elseif minetest.global_exists("sfinv") then -- sfinv installed }) --show the form when the button is pressed and hide it when done - minetest.register_on_player_receive_fields(function(player, formname, fields) + minetest.register_on_player_receive_fields(function(player, _, fields) if fields.worldedit_gui then --main page worldedit.show_page(player:get_player_name(), "worldedit_gui") return true @@ -228,12 +228,12 @@ end worldedit.register_gui_function("worldedit_gui", { name = "WorldEdit GUI", privs = {interact=true}, - get_formspec = function(name) + get_formspec = function() --create a form with all the buttons arranged in a grid local buttons, x, y, index = {}, 0, 1, 0 local width, height = 3, 0.8 local columns = 5 - for i, identifier in pairs(identifiers) do + for _, identifier in pairs(identifiers) do if identifier ~= "worldedit_gui" then local entry = worldedit.pages[identifier] table.insert(buttons, string.format((entry.get_formspec and "button" or "button_exit") ..