diff --git a/.luacheckrc b/.luacheckrc index 113c600..d28b414 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,4 +1,4 @@ -max_line_length = 180 +max_line_length = 200 globals = { "digtron", @@ -17,7 +17,7 @@ read_globals = { "dump", "VoxelArea", -- Deps - "default", "awards", "pipeworks", "hopper", "technic" + "default", "awards", "pipeworks", "hopper", "technic", "doc", "intllib" } files = { diff --git a/class_fakeplayer.lua b/class_fakeplayer.lua index cc6e4d9..91c8d32 100644 --- a/class_fakeplayer.lua +++ b/class_fakeplayer.lua @@ -116,7 +116,7 @@ function digtron.DigtronFakePlayer.create(pos, player_name) self.hud_remove = return_nil self.hud_change = return_nil self.hud_get = return_nil -- possibly important return value? - self.hud_set_flags = return_nil + self.hud_set_flags = return_nil self.hud_get_flags = return_value({ hotbar=true, healthbar=true, crosshair=true, wielditem=true, breathbar=true, minimap=true }) self.hud_set_hotbar_itemcount = return_nil self.hud_get_hotbar_itemcount = return_zero diff --git a/class_layout.lua b/class_layout.lua index c6289ae..678aed2 100644 --- a/class_layout.lua +++ b/class_layout.lua @@ -61,7 +61,9 @@ function digtron.DigtronLayout.create(pos, player) self.contains_protected_node = false -- used to indicate if at least one node in this digtron array is protected from the player. self.controller = {x=pos.x, y=pos.y, z=pos.z} --Make a deep copy of the pos parameter just in case the calling code wants to play silly buggers with it - table.insert(self.all, get_node_image(pos, minetest.get_node(pos))) -- We never visit the source node, so insert it into the all table a priori. Revisit this design decision if a controller node is created that contains fuel or inventory or whatever. + -- We never visit the source node, so insert it into the all table a priori. + -- Revisit this design decision if a controller node is created that contains fuel or inventory or whatever. + table.insert(self.all, get_node_image(pos, minetest.get_node(pos))) self.extents_max_x = pos.x self.extents_min_x = pos.x @@ -354,7 +356,7 @@ end -- Writing to world function digtron.DigtronLayout.can_write_layout_image(self) - for k, node_image in pairs(self.all) do + for _, node_image in pairs(self.all) do --check if we're moving into a protected node if self.protected:get(node_image.pos.x, node_image.pos.y, node_image.pos.z) then return false @@ -470,7 +472,7 @@ function digtron.DigtronLayout.write_layout_image(self, player) end -- create the new one - for k, node_image in pairs(self.all) do + for _, node_image in pairs(self.all) do local new_pos = node_image.pos local new_node = node_image.node local old_node = minetest.get_node(new_pos) @@ -503,7 +505,7 @@ end function digtron.DigtronLayout.serialize(self) -- serialize can't handle ItemStack objects, convert them to strings. for _, node_image in pairs(self.all) do - for k, inv in pairs(node_image.meta.inventory) do + for _, inv in pairs(node_image.meta.inventory) do for index, item in pairs(inv) do inv[index] = item:to_string() end diff --git a/class_pointset.lua b/class_pointset.lua index d8dfcc9..032555b 100644 --- a/class_pointset.lua +++ b/class_pointset.lua @@ -19,7 +19,7 @@ end function digtron.Pointset:clear() local points = self.points - for k, v in pairs(points) do + for k in pairs(points) do points[k] = nil end end @@ -59,7 +59,7 @@ function digtron.Pointset:pop() local hash, value = next(self.points) if hash == nil then return nil end local pos = minetest.get_position_from_hash(hash) - self.points[hash] = nil + self.points[hash] = nil return pos, value end diff --git a/doc.lua b/doc.lua index e645695..d7857bf 100644 --- a/doc.lua +++ b/doc.lua @@ -14,7 +14,7 @@ local battery_ratio = (10000/digtron.config.power_ratio) / coal_fuel -- internationalization boilerplate local MP = minetest.get_modpath(minetest.get_current_modname()) -local S, NS = dofile(MP.."/intllib.lua") +local S = dofile(MP.."/intllib.lua") local pipeworks_enabled = minetest.get_modpath("pipeworks") ~= nil local hoppers_enabled = minetest.get_modpath("hopper") and hopper ~= nil and hopper.add_container ~= nil diff --git a/entities.lua b/entities.lua index 25add45..13d6bba 100644 --- a/entities.lua +++ b/entities.lua @@ -7,19 +7,19 @@ minetest.register_entity("digtron:marker", { physical = false, }, - on_activate = function(self, staticdata) + on_activate = function(self) minetest.after(5.0, - function(self) + function() self.object:remove() end, self) end, - on_rightclick=function(self, clicker) + on_rightclick=function(self) self.object:remove() end, - on_punch = function(self, hitter) + on_punch = function(self) self.object:remove() end, }) @@ -28,24 +28,31 @@ minetest.register_entity("digtron:marker_vertical", { initial_properties = { visual = "cube", visual_size = {x=1.05, y=1.05}, - textures = {"digtron_marker.png","digtron_marker.png","digtron_marker_side.png^[transformR90","digtron_marker_side.png^[transformR90","digtron_marker_side.png^[transformR90","digtron_marker_side.png^[transformR90"}, + textures = { + "digtron_marker.png", + "digtron_marker.png", + "digtron_marker_side.png^[transformR90", + "digtron_marker_side.png^[transformR90", + "digtron_marker_side.png^[transformR90", + "digtron_marker_side.png^[transformR90" + }, collisionbox = {-0.525, -0.525, -0.525, 0.525, 0.525, 0.525}, physical = false, }, - on_activate = function(self, staticdata) + on_activate = function(self) minetest.after(5.0, - function(self) + function() self.object:remove() end, self) end, - on_rightclick=function(self, clicker) + on_rightclick=function(self) self.object:remove() end, - on_punch = function(self, hitter) + on_punch = function(self) self.object:remove() end, }) @@ -59,19 +66,19 @@ minetest.register_entity("digtron:marker_crate_good", { physical = false, }, - on_activate = function(self, staticdata) + on_activate = function(self) minetest.after(digtron.config.marker_crate_good_duration, - function(self) + function() self.object:remove() end, self) end, - on_rightclick=function(self, clicker) + on_rightclick=function(self) self.object:remove() end, - on_punch = function(self, hitter) + on_punch = function(self) self.object:remove() end, }) @@ -85,19 +92,19 @@ minetest.register_entity("digtron:marker_crate_bad", { physical = false, }, - on_activate = function(self, staticdata) + on_activate = function(self) minetest.after(digtron.config.marker_crate_bad_duration, - function(self) + function() self.object:remove() end, self) end, - on_rightclick=function(self, clicker) + on_rightclick=function(self) self.object:remove() end, - on_punch = function(self, hitter) + on_punch = function(self) self.object:remove() end, }) @@ -133,7 +140,7 @@ minetest.register_entity("digtron:builder_item", { digtron.create_builder_item = nil else self.object:remove() - end + end end, get_staticdata = function(self) diff --git a/nodes/node_axle.lua b/nodes/node_axle.lua index d732ad3..d43bd60 100644 --- a/nodes/node_axle.lua +++ b/nodes/node_axle.lua @@ -1,6 +1,6 @@ -- internationalization boilerplate local MP = minetest.get_modpath(minetest.get_current_modname()) -local S, NS = dofile(MP.."/intllib.lua") +local S = dofile(MP.."/intllib.lua") minetest.register_node("digtron:axle", { description = S("Digtron Rotation Axle"), @@ -38,7 +38,7 @@ minetest.register_node("digtron:axle", { - on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + on_rightclick = function(pos, node, clicker) local meta = minetest.get_meta(pos) -- new delay code without nodetimer (lost on crating) @@ -77,7 +77,7 @@ minetest.register_node("digtron:axle", { end end, - on_timer = function(pos, elapsed) + on_timer = function(pos) minetest.get_meta(pos):set_string("waiting", nil) end, }) \ No newline at end of file diff --git a/nodes/node_battery_holder.lua b/nodes/node_battery_holder.lua index 553a69b..4582a35 100644 --- a/nodes/node_battery_holder.lua +++ b/nodes/node_battery_holder.lua @@ -1,6 +1,6 @@ -- internationalization boilerplate local MP = minetest.get_modpath(minetest.get_current_modname()) -local S, NS = dofile(MP.."/intllib.lua") +local S = dofile(MP.."/intllib.lua") -- Battery storage. Controller node draws electrical power from here. @@ -18,7 +18,7 @@ local battery_holder_formspec_string = "size[8,9.3]" .. "listring[current_player;main]" .. default.get_hotbar_bg(0,5.15) -local battery_holder_formspec = function(pos, meta) +local battery_holder_formspec = function() return battery_holder_formspec_string end @@ -64,7 +64,7 @@ minetest.register_node("digtron:battery_holder", { end, -- Allow all items with energy storage to be placed in the inventory - allow_metadata_inventory_put = function(pos, listname, index, stack, player) + allow_metadata_inventory_put = function(_, listname, _, stack) if listname == "batteries" then local node_name = stack:get_name() @@ -88,7 +88,7 @@ minetest.register_node("digtron:battery_holder", { end, - can_dig = function(pos,player) + can_dig = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() return inv:is_empty("batteries") @@ -99,18 +99,18 @@ minetest.register_node("digtron:battery_holder", { ----------------------------------------------------------------- tube = (function() if minetest.get_modpath("pipeworks") then return { - insert_object = function(pos, node, stack, direction) + insert_object = function(pos, _, stack) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() return inv:add_item("batteries", stack) end, - can_insert = function(pos, node, stack, direction) + can_insert = function(pos, _, stack) local meta = stack:get_metadata() local md = minetest.deserialize(meta) -- And specifically if they hold any charge -- Disregard empty batteries, the player should know better if md and md.charge > 0 then - local meta = minetest.get_meta(pos) + meta = minetest.get_meta(pos) local inv = meta:get_inventory() return inv:room_for_item("batteries", stack) end diff --git a/nodes/node_builders.lua b/nodes/node_builders.lua index f7151f5..aacc40c 100644 --- a/nodes/node_builders.lua +++ b/nodes/node_builders.lua @@ -1,6 +1,6 @@ -- internationalization boilerplate local MP = minetest.get_modpath(minetest.get_current_modname()) -local S, NS = dofile(MP.."/intllib.lua") +local S = dofile(MP.."/intllib.lua") -- Note: builders go in group 4 and have both test_build and execute_build methods. @@ -19,15 +19,18 @@ local builder_formspec_string = "list[current_name;main;".. tostring(displace_due_to_help_button/2) ..",0;1,1;]" .. "label[" .. tostring(displace_due_to_help_button/2).. ",0.8;" .. S("Block to build") .. "]" .. "field[" .. tostring(displace_due_to_help_button + 1.3) ..",0.8;1,0.1;extrusion;" .. S("Extrusion") .. ";${extrusion}]" .. - "tooltip[extrusion;" .. S("Builder will extrude this many blocks in the direction it is facing.\nCan be set from 1 to @1.\nNote that Digtron won't build into unloaded map regions.", digtron.config.maximum_extrusion) .. "]" .. + "tooltip[extrusion;" .. S("Builder will extrude this many blocks in the direction it is facing.\nCan be set from 1 to @1.\nNote that Digtron won't build into unloaded map regions.", + digtron.config.maximum_extrusion) .. "]" .. "field[" .. tostring(displace_due_to_help_button + 2.3) ..",0.8;1,0.1;period;" .. S("Periodicity") .. ";${period}]" .. "tooltip[period;" .. S("Builder will build once every n steps.\nThese steps are globally aligned, so all builders with the\nsame period and offset will build on the same location.") .. "]" .. "field[" .. tostring(displace_due_to_help_button + 3.3) ..",0.8;1,0.1;offset;" .. S("Offset") .. ";${offset}]" .. - "tooltip[offset;" .. S("Offsets the start of periodicity counting by this amount.\nFor example, a builder with period 2 and offset 0 builds\nevery even-numbered block and one with period 2 and\noffset 1 builds every odd-numbered block.") .. "]" .. + "tooltip[offset;" .. S("Offsets the start of periodicity counting by this amount.\nFor example, a builder with period 2 and offset 0 builds\nevery even-numbered block and one with period 2 and\n" .. + "offset 1 builds every odd-numbered block.") .. "]" .. "button_exit[" .. tostring(displace_due_to_help_button + 4.0) ..",0.5;1,0.1;set;" .. S("Save &\nShow") .. "]" .. "tooltip[set;" .. S("Saves settings") .. "]" .. "field[" .. tostring(displace_due_to_help_button + 5.3) .. ",0.8;1,0.1;build_facing;" .. S("Facing") .. ";${build_facing}]" .. - "tooltip[build_facing;" .. S("Value from 0-23. Not all block types make use of this.\nUse the 'Read & Save' button to copy the facing of the block\ncurrently in the builder output location.") .. "]" .. + "tooltip[build_facing;" .. S("Value from 0-23. Not all block types make use of this.\nUse the 'Read & Save' button to copy the facing of the block\n" .. + "currently in the builder output location.") .. "]" .. "button_exit[" .. tostring(displace_due_to_help_button + 6.0) ..",0.5;1,0.1;read;" .. S("Read &\nSave") .. "]" .. "tooltip[read;" .. S("Reads the facing of the block currently in the build location,\nthen saves all settings.") .. "]" .. "list[current_player;main;0,1.3;8,1;]" .. @@ -43,7 +46,6 @@ if minetest.get_modpath("doc") then end local builder_formspec = function(pos, meta) - local nodemeta = "nodemeta:"..pos.x .. "," .. pos.y .. "," ..pos.z return builder_formspec_string :gsub("${extrusion}", meta:get_int("extrusion"), 1) :gsub("${period}", meta:get_int("period"), 1) @@ -52,7 +54,7 @@ local builder_formspec = function(pos, meta) :gsub("current_name", "nodemeta:"..pos.x .. "," .. pos.y .. "," ..pos.z, 2) end -local builder_on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) +local builder_on_rightclick = function(pos, _, clicker, itemstack, pointed_thing) local item_def = itemstack:get_definition() if item_def.type == "node" and minetest.get_item_group(itemstack:get_name(), "digtron") > 0 then local returnstack, success = minetest.item_place_node(itemstack, clicker, pointed_thing) @@ -61,7 +63,7 @@ local builder_on_rightclick = function(pos, node, clicker, itemstack, pointed_th end return returnstack, success end - local meta = minetest.get_meta(pos) + local meta = minetest.get_meta(pos) minetest.show_formspec(clicker:get_player_name(), "digtron:builder"..minetest.pos_to_string(pos), builder_formspec(pos, meta)) @@ -104,8 +106,6 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields) end if extrusion and extrusion > 0 and extrusion <= digtron.config.maximum_extrusion then meta:set_int("extrusion", math.floor(tonumber(fields.extrusion))) - else - extrusion = meta:get_int("extrusion") end local nodename = minetest.get_node_or_nil(pos).name @@ -125,9 +125,8 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields) if target_item_name ~= "air" and minetest.get_item_group(target_item_name, "digtron") == 0 then - for k, location in pairs(layout.builders) do + for _, location in pairs(layout.builders) do - local target = minetest.get_node(location.pos) local target_meta = minetest.get_meta(location.pos) target_meta:set_int("period", meta:get_int("period")) target_meta:set_int("offset", meta:get_int("offset")) @@ -148,14 +147,13 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields) local layout = digtron.DigtronLayout.create(pos, sender) if layout.builders ~= nil then - for k, location in pairs(layout.builders) do + for _, location in pairs(layout.builders) do - local target = minetest.get_node(location.pos) local facing = minetest.get_node(location.pos).param2 local buildpos = digtron.find_new_pos(location.pos, facing) local target_node = minetest.get_node(buildpos) if target_node.name ~= "air" and minetest.get_item_group(target_node.name, "digtron") == 0 then - local meta = minetest.get_meta(location.pos) + meta = minetest.get_meta(location.pos) local inv = meta:get_inventory() local target_name = digtron.builder_read_item_substitutions[target_node.name] or target_node.name inv:set_stack("main", 1, target_name) @@ -180,7 +178,7 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields) local buildpos = digtron.find_new_pos(pos, facing) local target_node = minetest.get_node(buildpos) if target_node.name ~= "air" and minetest.get_item_group(target_node.name, "digtron") == 0 then - local meta = minetest.get_meta(pos) + meta = minetest.get_meta(pos) local inv = meta:get_inventory() local target_name = digtron.builder_read_item_substitutions[target_node.name] or target_node.name inv:set_stack("main", 1, target_name) @@ -260,12 +258,12 @@ minetest.register_node("digtron:builder", { digtron.update_builder_item(pos) end, - allow_metadata_inventory_put = function(pos, listname, index, stack, player) + allow_metadata_inventory_put = function(pos, listname, index, stack) local stack_name = stack:get_name() if minetest.get_item_group(stack_name, "digtron") ~= 0 then return 0 -- don't allow builders to be set to build Digtron nodes, they'll just clog the output. - end + end local stack_def = minetest.registered_nodes[stack_name] if not stack_def and not digtron.whitelisted_on_place(stack_name) then @@ -285,7 +283,7 @@ minetest.register_node("digtron:builder", { return 0 end, - allow_metadata_inventory_take = function(pos, listname, index, stack, player) + allow_metadata_inventory_take = function(pos, listname, index) node_inventory_table.pos = pos local inv = minetest.get_inventory(node_inventory_table) inv:set_stack(listname, index, ItemStack("")) @@ -302,7 +300,7 @@ minetest.register_node("digtron:builder", { -- 1, {{itemstack, source inventory pos}, ...} -- can build, took items from inventory -- 2, {{itemstack, source inventory pos}, ...}, itemstack -- was supposed to build, but couldn't get the item from inventory -- 3, {} -- builder configuration error - test_build = function(pos, test_pos, inventory_positions, protected_nodes, nodes_dug, controlling_coordinate, controller_pos) + test_build = function(pos, test_pos, inventory_positions, protected_nodes, nodes_dug, controlling_coordinate) local meta = minetest.get_meta(pos) local facing = minetest.get_node(pos).param2 local buildpos = digtron.find_new_pos(test_pos, facing) @@ -386,9 +384,10 @@ minetest.register_node("digtron:builder", { local oldnode = minetest.get_node(buildpos) if not digtron.config.uses_resources then - local returned_stack, success = digtron.item_place_node(item_stack, player, buildpos, build_facing) + local _, success = digtron.item_place_node(item_stack, player, buildpos, build_facing) if success == true then - minetest.log("action", string.format("%s uses Digtron to build %s at (%d, %d, %d), displacing %s", player:get_player_name(), item_stack:get_name(), buildpos.x, buildpos.y, buildpos.z, oldnode.name)) + minetest.log("action", + string.format("%s uses Digtron to build %s at (%d, %d, %d), displacing %s", player:get_player_name(), item_stack:get_name(), buildpos.x, buildpos.y, buildpos.z, oldnode.name)) nodes_dug:set(buildpos.x, buildpos.y, buildpos.z, false) built_count = built_count + 1 else @@ -401,9 +400,10 @@ minetest.register_node("digtron:builder", { -- item not in inventory! Need to sound the angry buzzer to let the player know, so return a negative number. return (built_count + 1) * -1 end - local returned_stack, success = digtron.item_place_node(ItemStack(item_stack), player, buildpos, build_facing) + local _, success = digtron.item_place_node(ItemStack(item_stack), player, buildpos, build_facing) if success == true then - minetest.log("action", string.format("%s uses Digtron to build %s at (%d, %d, %d), displacing %s", player:get_player_name(), item_stack:get_name(), buildpos.x, buildpos.y, buildpos.z, oldnode.name)) + minetest.log("action", + string.format("%s uses Digtron to build %s at (%d, %d, %d), displacing %s", player:get_player_name(), item_stack:get_name(), buildpos.x, buildpos.y, buildpos.z, oldnode.name)) --flag this node as *not* to be dug. nodes_dug:set(buildpos.x, buildpos.y, buildpos.z, false) digtron.award_item_built(item_stack:get_name(), player) @@ -489,12 +489,12 @@ minetest.register_node("digtron:master_builder", { digtron.update_builder_item(pos) end, - allow_metadata_inventory_put = function(pos, listname, index, stack, player) + allow_metadata_inventory_put = function(pos, listname, index, stack) local stack_name = stack:get_name() if minetest.get_item_group(stack_name, "digtron") ~= 0 then return 0 -- don't allow builders to be set to build Digtron nodes, they'll just clog the output. - end + end local stack_def = minetest.registered_nodes[stack_name] if not stack_def and not digtron.whitelisted_on_place(stack_name) then @@ -514,7 +514,7 @@ minetest.register_node("digtron:master_builder", { return 0 end, - allow_metadata_inventory_take = function(pos, listname, index, stack, player) + allow_metadata_inventory_take = function(pos, listname, index) node_inventory_table.pos = pos local inv = minetest.get_inventory(node_inventory_table) inv:set_stack(listname, index, ItemStack("")) diff --git a/nodes/node_controllers.lua b/nodes/node_controllers.lua index 5b24eb3..f7503a7 100644 --- a/nodes/node_controllers.lua +++ b/nodes/node_controllers.lua @@ -1,6 +1,6 @@ -- internationalization boilerplate local MP = minetest.get_modpath(minetest.get_current_modname()) -local S, NS = dofile(MP.."/intllib.lua") +local S = dofile(MP.."/intllib.lua") local controller_nodebox ={ {-0.3125, -0.3125, -0.3125, 0.3125, 0.3125, 0.3125}, -- Core @@ -52,7 +52,7 @@ minetest.register_node("digtron:controller", { meta:set_string("infotext", S("Heat remaining in controller furnace: @1", 0)) end, - on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + on_rightclick = function(pos, _, clicker) local meta = minetest.get_meta(pos) -- new delay code without nodetimer (lost on crating) @@ -62,14 +62,14 @@ minetest.register_node("digtron:controller", { -- if meta:get_string("waiting") == "true" then if last_time + digtron.config.cycle_time > now then -- Been too soon since last time the digtron did a cycle. - + -- added for clarity meta:set_string("infotext", S("repetition delay")) - + return end - local newpos, status, return_code = digtron.execute_dig_cycle(pos, clicker) + local newpos, status = digtron.execute_dig_cycle(pos, clicker) meta = minetest.get_meta(newpos) if status ~= nil then @@ -83,7 +83,7 @@ minetest.register_node("digtron:controller", { meta:set_string("last_time",tostring(minetest.get_gametime())) end, - on_timer = function(pos, elapsed) + on_timer = function(pos) minetest.get_meta(pos):set_string("waiting", nil) end, }) @@ -97,15 +97,18 @@ local auto_formspec = "size[8,6.2]" .. default.gui_slots .. "container[2.0,0]" .. "field[0.0,0.8;1,0.1;cycles;" .. S("Cycles").. ";${cycles}]" .. - "tooltip[cycles;" .. S("When triggered, this controller will try to run for the given number of cycles.\nThe cycle count will decrement as it runs, so if it gets halted by a problem\nyou can fix the problem and restart.").. "]" .. + "tooltip[cycles;" .. S("When triggered, this controller will try to run for the given number of cycles.\nThe cycle count will decrement as it runs, so if it gets halted by a problem\n" .. + "you can fix the problem and restart.").. "]" .. "button_exit[0.7,0.5;1,0.1;set;" .. S("Set").. "]" .. "tooltip[set;" .. S("Saves the cycle setting without starting the controller running").. "]" .. "button_exit[1.7,0.5;1,0.1;execute;" .. S("Set &\nExecute").. "]" .. "tooltip[execute;" .. S("Begins executing the given number of cycles").. "]" .. "field[0.0,2.0;1,0.1;slope;" .. S("Slope").. ";${slope}]" .. - "tooltip[slope;" .. S("For diagonal digging. After moving forward this number of nodes the auto controller\nwill add an additional cycle moving the digtron laterally in the\ndirection of the arrows on the side of this controller.\nSet to 0 for no lateral digging.").. "]" .. + "tooltip[slope;" .. S("For diagonal digging. After moving forward this number of nodes the auto controller\nwill add an additional cycle moving the digtron laterally in the\n" .. + "direction of the arrows on the side of this controller.\nSet to 0 for no lateral digging.").. "]" .. "field[1.0,2.0;1,0.1;offset;" .. S("Offset").. ";${offset}]" .. - "tooltip[offset;" .. S("Sets the offset of the lateral motion defined in the Slope field.\nNote: this offset is relative to the controller's location.\nThe controller will move laterally when it reaches the indicated point.").. "]" .. + "tooltip[offset;" .. S("Sets the offset of the lateral motion defined in the Slope field.\nNote: this offset is relative to the controller's location.\n" .. + "The controller will move laterally when it reaches the indicated point.").. "]" .. "field[2.0,2.0;1,0.1;period;" .. S("Delay").. ";${period}]" .. "tooltip[period;" .. S("Number of seconds to wait between each cycle").. "]" .. "list[current_name;stop;3.0,0.7;1,1;]" .. @@ -121,7 +124,7 @@ if minetest.get_modpath("doc") then auto_formspec = auto_formspec .. "button_exit[7.0,0.5;1,0.1;help;" .. S("Help") .. "]" .. "tooltip[help;" .. S("Show documentation about this block").. "]" -end +end local function auto_cycle(pos) local node = minetest.get_node(pos) @@ -233,24 +236,24 @@ minetest.register_node("digtron:auto_controller", { inv:set_size("stop", 1) end, - allow_metadata_inventory_put = function(pos, listname, index, stack, player) + allow_metadata_inventory_put = function(pos, listname, index, stack) if minetest.get_item_group(stack:get_name(), "digtron") ~= 0 then return 0 -- pointless setting a Digtron node as a stop block - end + end node_inventory_table.pos = pos local inv = minetest.get_inventory(node_inventory_table) inv:set_stack(listname, index, stack:take_item(1)) return 0 end, - allow_metadata_inventory_take = function(pos, listname, index, stack, player) + allow_metadata_inventory_take = function(pos, listname, index) node_inventory_table.pos = pos local inv = minetest.get_inventory(node_inventory_table) inv:set_stack(listname, index, ItemStack("")) return 0 end, - on_receive_fields = function(pos, formname, fields, sender) + on_receive_fields = function(pos, _, fields, sender) local meta = minetest.get_meta(pos) local offset = tonumber(fields.offset) local period = tonumber(fields.period) @@ -299,14 +302,14 @@ minetest.register_node("digtron:auto_controller", { markerpos[controlling_coordinate] = x_pos + slope minetest.add_entity(markerpos, "digtron:marker_vertical") end - end + end if fields.help and minetest.get_modpath("doc") then --check for mod in case someone disabled it after this digger was built minetest.after(0.5, doc.show_entry, sender:get_player_name(), "nodes", "digtron:auto_controller", true) end - end, + end, - on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + on_rightclick = function(pos) local meta = minetest.get_meta(pos) meta:set_string("infotext", meta:get_string("infotext") .. "\n" .. S("Interrupted!")) meta:set_string("waiting", "true") @@ -345,14 +348,14 @@ minetest.register_node("digtron:pusher", { fixed = controller_nodebox, }, - on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + on_rightclick = function(pos, _, clicker) local meta = minetest.get_meta(pos) if meta:get_string("waiting") == "true" then -- Been too soon since last time the digtron did a cycle. return end - local newpos, status_text, return_code = digtron.execute_move_cycle(pos, clicker) + local newpos, status_text = digtron.execute_move_cycle(pos, clicker) meta = minetest.get_meta(newpos) meta:set_string("infotext", status_text) @@ -361,7 +364,7 @@ minetest.register_node("digtron:pusher", { minetest.get_node_timer(newpos):start(digtron.config.cycle_time) end, - on_timer = function(pos, elapsed) + on_timer = function(pos) minetest.get_meta(pos):set_string("waiting", nil) end, }) diff --git a/nodes/node_crate.lua b/nodes/node_crate.lua index ffeb459..e64e8f2 100644 --- a/nodes/node_crate.lua +++ b/nodes/node_crate.lua @@ -1,6 +1,6 @@ -- internationalization boilerplate local MP = minetest.get_modpath(minetest.get_current_modname()) -local S, NS = dofile(MP.."/intllib.lua") +local S = dofile(MP.."/intllib.lua") local modpath_awards = minetest.get_modpath("awards") @@ -68,7 +68,7 @@ local store_digtron = function(pos, clicker, loaded_node_name, protected) local pos_copy = {x=old_pos.x, y=old_pos.y, z=old_pos.z} local oldnode_copy = {name=old_node.name, param1=old_node.param1, param2=old_node.param2} callback(pos_copy, oldnode_copy, clicker) - end + end end -- Create the loaded crate node @@ -112,7 +112,7 @@ minetest.register_node("digtron:empty_crate", { return player and not minetest.is_protected(pos, player:get_player_name()) end, - on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + on_rightclick = function(pos, _, clicker) store_digtron(pos, clicker, "digtron:loaded_crate") end }) @@ -147,7 +147,7 @@ minetest.register_node("digtron:empty_locked_crate", { can_dig = function(pos,player) return player and not minetest.is_protected(pos, player:get_player_name()) and player_permitted(pos, player) end, - on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + on_rightclick = function(pos, _, clicker) if player_permitted(pos,clicker) then store_digtron(pos, clicker, "digtron:loaded_locked_crate", true) end @@ -186,7 +186,7 @@ else "tooltip[unpack;" .. S("Attempts to unpack the Digtron on this location") .. "]" end -local loaded_formspec = function(pos, meta) +local loaded_formspec = function() return loaded_formspec_string end @@ -219,7 +219,7 @@ local loaded_on_recieve = function(pos, fields, sender, protected) if layout == nil then meta:set_string("infotext", infotext .. "\n" .. S("Unable to read layout from crate metadata, regrettably this Digtron may be corrupted.")) - minetest.sound_play("buzzer", {gain=0.5, pos=pos}) + minetest.sound_play("buzzer", {gain=0.5, pos=pos}) -- Something went horribly wrong return end @@ -273,12 +273,12 @@ local loaded_on_dig = function(pos, player, loaded_node_name) stack_meta:set_string("crated_layout", meta:get_string("crated_layout")) stack_meta:set_string("description", meta:get_string("title")) local inv = player:get_inventory() - local stack = inv:add_item("main", stack) + stack = inv:add_item("main", stack) if stack:get_count() > 0 then -- prevent crash by not dropping loaded crate (see #44) -- minetest.add_item(pos, stack) return false - end + end -- call on_dignodes callback minetest.remove_node(pos) end @@ -326,20 +326,20 @@ minetest.register_node("digtron:loaded_crate", { meta:set_string("formspec", loaded_formspec(pos, meta)) end, - on_receive_fields = function(pos, formname, fields, sender) + on_receive_fields = function(pos, _, fields, sender) return loaded_on_recieve(pos, fields, sender) end, - on_dig = function(pos, node, player) + on_dig = function(pos, _, player) if player and not minetest.is_protected(pos, player:get_player_name()) then return loaded_on_dig(pos, player, "digtron:loaded_crate") end end, - after_place_node = function(pos, placer, itemstack, pointed_thing) + after_place_node = function(pos, _, itemstack) loaded_after_place(pos, itemstack) end, - on_drop = function(a, b, c) end -- prevent dropping loaded digtrons, causing server to crash (see #44) + on_drop = function() end -- prevent dropping loaded digtrons, causing server to crash (see #44) }) minetest.register_node("digtron:loaded_locked_crate", { @@ -349,17 +349,21 @@ minetest.register_node("digtron:loaded_locked_crate", { groups = {cracky = 3, oddly_breakable_by_hand=3, not_in_creative_inventory=1, digtron_protected=1}, stack_max = 1, sounds = default.node_sound_wood_defaults(), - tiles = {"digtron_plate.png^digtron_crate.png","digtron_plate.png^digtron_crate.png","digtron_plate.png^digtron_crate.png^digtron_lock.png","digtron_plate.png^digtron_crate.png^digtron_lock.png","digtron_plate.png^digtron_crate.png^digtron_lock.png","digtron_plate.png^digtron_crate.png^digtron_lock.png"}, + tiles = { + "digtron_plate.png^digtron_crate.png", + "digtron_plate.png^digtron_crate.png", + "digtron_plate.png^digtron_crate.png^digtron_lock.png", + "digtron_plate.png^digtron_crate.png^digtron_lock.png", + "digtron_plate.png^digtron_crate.png^digtron_lock.png", + "digtron_plate.png^digtron_crate.png^digtron_lock.png" + }, is_ground_content = false, on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("owner", "") end, --- can_dig = function(pos,node,player) --- return player and not minetest.is_protected(pos, player:get_player_name()) and player_permitted(pos,player) --- end, - on_dig = function(pos, node, player) + on_dig = function(pos, _, player) if player and not minetest.is_protected(pos, player:get_player_name()) and player_permitted(pos,player) then return loaded_on_dig(pos, player, "digtron:loaded_locked_crate") else @@ -367,14 +371,14 @@ minetest.register_node("digtron:loaded_locked_crate", { end end, - after_place_node = function(pos, placer, itemstack, pointed_thing) + after_place_node = function(pos, placer, itemstack) local meta = minetest.get_meta(pos) meta:set_string("owner", placer:get_player_name() or "") loaded_after_place(pos, itemstack) meta:set_string("infotext", meta:get_string("infotext") .. "\n" .. S("Owned by @1", meta:get_string("owner"))) end, - on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + on_rightclick = function(pos, _, clicker) if player_permitted(pos,clicker) then local meta = minetest.get_meta(pos) minetest.show_formspec( @@ -383,7 +387,7 @@ minetest.register_node("digtron:loaded_locked_crate", { loaded_formspec_string:gsub("${title}", meta:get_string("title"), 1)) end end, - on_drop = function(a, b, c) end -- prevent dropping loaded digtrons, causing server to crash + on_drop = function() end -- prevent dropping loaded digtrons, causing server to crash }) minetest.register_on_player_receive_fields(function(player, formname, fields) diff --git a/nodes/node_diggers.lua b/nodes/node_diggers.lua index 48cf8b5..85f4620 100644 --- a/nodes/node_diggers.lua +++ b/nodes/node_diggers.lua @@ -1,6 +1,6 @@ -- internationalization boilerplate local MP = minetest.get_modpath(minetest.get_current_modname()) -local S, NS = dofile(MP.."/intllib.lua") +local S = dofile(MP.."/intllib.lua") -- Note: diggers go in group 3 and have an execute_dig method. @@ -36,7 +36,8 @@ local intermittent_formspec_string = default.gui_bg .. "field[0.5,0.8;1,0.1;period;" .. S("Periodicity") .. ";${period}]" .. "tooltip[period;" .. S("Digger will dig once every n steps.\nThese steps are globally aligned, all diggers with\nthe same period and offset will dig on the same location.") .. "]" .. "field[1.5,0.8;1,0.1;offset;" .. S("Offset") .. ";${offset}]" .. - "tooltip[offset;" .. S("Offsets the start of periodicity counting by this amount.\nFor example, a digger with period 2 and offset 0 digs\nevery even-numbered block and one with period 2 and\noffset 1 digs every odd-numbered block.") .. "]" .. + "tooltip[offset;" .. S("Offsets the start of periodicity counting by this amount.\nFor example, a digger with period 2 and offset 0 digs\nevery even-numbered block and one with period 2 and\n" .. + "offset 1 digs every odd-numbered block.") .. "]" .. "button_exit[2.2,0.5;1,0.1;set;" .. S("Save &\nShow") .. "]" .. "tooltip[set;" .. S("Saves settings") .. "]" @@ -48,7 +49,7 @@ if modpath_doc then intermittent_formspec_string = "size[3.5,1]" .. intermittent_formspec_string end -local intermittent_formspec = function(pos, meta) +local intermittent_formspec = function(_, meta) return intermittent_formspec_string :gsub("${period}", meta:get_int("period"), 1) :gsub("${offset}", meta:get_int("offset"), 1) @@ -60,7 +61,7 @@ local intermittent_on_construct = function(pos) meta:set_int("offset", 0) end -local intermittent_on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) +local intermittent_on_rightclick = function(pos, _, clicker, itemstack, pointed_thing) local item_def = itemstack:get_definition() if item_def.type == "node" and minetest.get_item_group(itemstack:get_name(), "digtron") > 0 then local returnstack, success = minetest.item_place_node(itemstack, clicker, pointed_thing) @@ -69,7 +70,7 @@ local intermittent_on_rightclick = function(pos, node, clicker, itemstack, point end return returnstack, success end - local meta = minetest.get_meta(pos) + local meta = minetest.get_meta(pos) minetest.show_formspec(clicker:get_player_name(), "digtron:intermittent_digger"..minetest.pos_to_string(pos), intermittent_formspec(pos, meta)) @@ -111,7 +112,7 @@ minetest.register_node("digtron:digger", { sounds = digtron.metal_sounds, paramtype = "light", paramtype2= "facedir", - is_ground_content = false, + is_ground_content = false, drawtype="nodebox", node_box = { type = "fixed", @@ -137,7 +138,7 @@ minetest.register_node("digtron:digger", { }, -- returns fuel_cost, item_produced - execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate, lateral_dig, player) + execute_dig = function(pos, protected_nodes, nodes_dug, _, _, player) local facing = minetest.get_node(pos).param2 local digpos = digtron.find_new_pos(pos, facing) @@ -148,7 +149,7 @@ minetest.register_node("digtron:digger", { return digtron.mark_diggable(digpos, nodes_dug, player) end, - damage_creatures = function(player, pos, controlling_coordinate, items_dropped) + damage_creatures = function(player, pos, _, items_dropped) local facing = minetest.get_node(pos).param2 digtron.damage_creatures(player, pos, digtron.find_new_pos(pos, facing), damage_hp, items_dropped) end, @@ -165,7 +166,7 @@ minetest.register_node("digtron:intermittent_digger", { sounds = digtron.metal_sounds, paramtype = "light", paramtype2= "facedir", - is_ground_content = false, + is_ground_content = false, drawtype="nodebox", node_box = { type = "fixed", @@ -261,7 +262,7 @@ minetest.register_node("digtron:soft_digger", { "digtron_plate.png^digtron_motor.png^[colorize:" .. digtron.soft_digger_colorize, }, - execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate, lateral_dig, player) + execute_dig = function(pos, protected_nodes, nodes_dug, _, _, player) local facing = minetest.get_node(pos).param2 local digpos = digtron.find_new_pos(pos, facing) @@ -276,7 +277,7 @@ minetest.register_node("digtron:soft_digger", { return 0 end, - damage_creatures = function(player, pos, controlling_coordinate, items_dropped) + damage_creatures = function(player, pos, _, items_dropped) local facing = minetest.get_node(pos).param2 digtron.damage_creatures(player, pos, digtron.find_new_pos(pos, facing), damage_hp_half, items_dropped) end, @@ -349,7 +350,7 @@ minetest.register_node("digtron:intermittent_soft_digger", { damage_creatures = function(player, pos, controlling_coordinate, items_dropped) local meta = minetest.get_meta(pos) local facing = minetest.get_node(pos).param2 - local targetpos = digtron.find_new_pos(pos, facing) + local targetpos = digtron.find_new_pos(pos, facing) if (targetpos[controlling_coordinate] + meta:get_int("offset")) % meta:get_int("period") == 0 then digtron.damage_creatures(player, pos, targetpos, damage_hp_half, items_dropped) end @@ -366,7 +367,7 @@ minetest.register_node("digtron:dual_digger", { sounds = digtron.metal_sounds, paramtype = "light", paramtype2= "facedir", - is_ground_content = false, + is_ground_content = false, drawtype="nodebox", node_box = { type = "fixed", @@ -400,7 +401,7 @@ minetest.register_node("digtron:dual_digger", { }, -- returns fuel_cost, items_produced - execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate, lateral_dig, player) + execute_dig = function(pos, protected_nodes, nodes_dug, _, _, player) local facing = minetest.get_node(pos).param2 local digpos = digtron.find_new_pos(pos, facing) local digdown = digtron.find_new_pos_downward(pos, facing) @@ -430,7 +431,7 @@ minetest.register_node("digtron:dual_digger", { return cost, items end, - damage_creatures = function(player, pos, controlling_coordinate, items_dropped) + damage_creatures = function(player, pos, _, items_dropped) local facing = minetest.get_node(pos).param2 digtron.damage_creatures(player, pos, digtron.find_new_pos(pos, facing), damage_hp, items_dropped) digtron.damage_creatures(player, pos, digtron.find_new_pos_downward(pos, facing), damage_hp, items_dropped) @@ -448,7 +449,7 @@ minetest.register_node("digtron:dual_soft_digger", { use_texture_alpha = use_texture_alpha, paramtype = "light", paramtype2= "facedir", - is_ground_content = false, + is_ground_content = false, drawtype="nodebox", node_box = { type = "fixed", @@ -482,7 +483,7 @@ minetest.register_node("digtron:dual_soft_digger", { }, -- returns fuel_cost, items_produced - execute_dig = function(pos, protected_nodes, nodes_dug, controlling_coordinate, lateral_dig, player) + execute_dig = function(pos, protected_nodes, nodes_dug, _, _, player) local facing = minetest.get_node(pos).param2 local digpos = digtron.find_new_pos(pos, facing) local digdown = digtron.find_new_pos_downward(pos, facing) @@ -512,7 +513,7 @@ minetest.register_node("digtron:dual_soft_digger", { return cost, items end, - damage_creatures = function(player, pos, controlling_coordinate, items_dropped) + damage_creatures = function(player, pos, _, items_dropped) local facing = minetest.get_node(pos).param2 digtron.damage_creatures(player, pos, digtron.find_new_pos(pos, facing), damage_hp_half, items_dropped) digtron.damage_creatures(player, pos, digtron.find_new_pos_downward(pos, facing), damage_hp_half, items_dropped) diff --git a/nodes/node_duplicator.lua b/nodes/node_duplicator.lua index 841ca49..95f12bb 100644 --- a/nodes/node_duplicator.lua +++ b/nodes/node_duplicator.lua @@ -1,6 +1,6 @@ -- internationalization boilerplate local MP = minetest.get_modpath(minetest.get_current_modname()) -local S, NS = dofile(MP.."/intllib.lua") +local S = dofile(MP.."/intllib.lua") local inventory_formspec_string = "size[9,9.3]" .. @@ -29,7 +29,8 @@ minetest.register_node("digtron:duplicator", { _doc_items_usagehelp = digtron.doc.duplicator_usagehelp, groups = {cracky = 3, oddly_breakable_by_hand=3}, sounds = digtron.metal_sounds, - tiles = {"digtron_plate.png^(digtron_axel_side.png^[transformR90)", + tiles = { + "digtron_plate.png^(digtron_axel_side.png^[transformR90)", "digtron_plate.png^(digtron_axel_side.png^[transformR270)", "digtron_plate.png^digtron_axel_side.png", "digtron_plate.png^(digtron_axel_side.png^[transformR180)", @@ -68,13 +69,13 @@ minetest.register_node("digtron:duplicator", { inv:set_size("main", 8*4) end, - can_dig = function(pos,player) + can_dig = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() return inv:is_empty("main") end, - allow_metadata_inventory_put = function(pos, listname, index, stack, player) + allow_metadata_inventory_put = function(_, _, _, stack) if minetest.get_item_group(stack:get_name(), "digtron") > 0 then return stack:get_count() else @@ -82,7 +83,7 @@ minetest.register_node("digtron:duplicator", { end end, - on_receive_fields = function(pos, formname, fields, sender) + on_receive_fields = function(pos, _, fields, sender) local player_name = sender:get_player_name() if fields.help then minetest.after(0.5, doc.show_entry, player_name, "nodes", "digtron:duplicator", true) diff --git a/nodes/node_item_ejector.lua b/nodes/node_item_ejector.lua index 8178389..1bee4b8 100644 --- a/nodes/node_item_ejector.lua +++ b/nodes/node_item_ejector.lua @@ -1,6 +1,6 @@ -- internationalization boilerplate local MP = minetest.get_modpath(minetest.get_current_modname()) -local S, NS = dofile(MP.."/intllib.lua") +local S = dofile(MP.."/intllib.lua") --Build up the formspec, somewhat complicated due to multiple mod options local pipeworks_path = minetest.get_modpath("pipeworks") @@ -19,9 +19,9 @@ if doc_path then formspec_width = formspec_width + 1.5 end -local ejector_formspec_string = "size[".. formspec_width .. ",1]" .. ejector_formspec_string +ejector_formspec_string = "size[".. formspec_width .. ",1]" .. ejector_formspec_string -local ejector_formspec = function(pos, meta) +local ejector_formspec = function(_, meta) local return_string = ejector_formspec_string if pipeworks_path then return_string = return_string .. "checkbox[0,0.5;nonpipe;"..S("Eject into world")..";"..meta:get_string("nonpipe").."]" .. @@ -52,7 +52,7 @@ local function eject_items(pos, node, player, eject_even_without_pipeworks, layo end else return false - end + end if layout == nil then layout = digtron.DigtronLayout.create(pos, player) @@ -149,7 +149,7 @@ minetest.register_node("digtron:inventory_ejector", { eject_items(pos, node, player, meta:get_string("nonpipe") == "true", layout) end, - on_receive_fields = function(pos, formname, fields, sender) + on_receive_fields = function(pos, _, fields, sender) local meta = minetest.get_meta(pos) if fields.help and minetest.get_modpath("doc") then --check for mod in case someone disabled it after this digger was built diff --git a/nodes/node_misc.lua b/nodes/node_misc.lua index cea823e..fbf15bb 100644 --- a/nodes/node_misc.lua +++ b/nodes/node_misc.lua @@ -1,6 +1,6 @@ -- internationalization boilerplate local MP = minetest.get_modpath(minetest.get_current_modname()) -local S, NS = dofile(MP.."/intllib.lua") +local S = dofile(MP.."/intllib.lua") -- A do-nothing "structural" node, to ensure all digtron nodes that are supposed to be connected to each other can be connected to each other. minetest.register_node("digtron:structure", { diff --git a/nodes/node_power_connector.lua b/nodes/node_power_connector.lua index 8eec875..4347233 100644 --- a/nodes/node_power_connector.lua +++ b/nodes/node_power_connector.lua @@ -1,6 +1,6 @@ -- internationalization boilerplate local MP = minetest.get_modpath(minetest.get_current_modname()) -local S, NS = dofile(MP.."/intllib.lua") +local S = dofile(MP.."/intllib.lua") local size = 3/16 @@ -28,10 +28,14 @@ minetest.register_node("digtron:power_connector", { _doc_items_longdesc = digtron.doc.power_connector_longdesc, _doc_items_usagehelp = digtron.doc.power_connector_usagehelp, groups = connector_groups, - tiles = {"digtron_plate.png^digtron_power_connector_top.png^digtron_digger_yb_frame.png", "digtron_plate.png^digtron_digger_yb_frame.png", - "digtron_plate.png^digtron_digger_yb_frame.png^digtron_power_connector_side.png", "digtron_plate.png^digtron_digger_yb_frame.png^digtron_power_connector_side.png", - "digtron_plate.png^digtron_digger_yb_frame.png^digtron_power_connector_side.png", "digtron_plate.png^digtron_digger_yb_frame.png^digtron_power_connector_side.png", - }, + tiles = { + "digtron_plate.png^digtron_power_connector_top.png^digtron_digger_yb_frame.png", + "digtron_plate.png^digtron_digger_yb_frame.png", + "digtron_plate.png^digtron_digger_yb_frame.png^digtron_power_connector_side.png", + "digtron_plate.png^digtron_digger_yb_frame.png^digtron_power_connector_side.png", + "digtron_plate.png^digtron_digger_yb_frame.png^digtron_power_connector_side.png", + "digtron_plate.png^digtron_digger_yb_frame.png^digtron_power_connector_side.png", + }, connect_sides = {"bottom", "top", "left", "right", "front", "back"}, drawtype = "nodebox", sounds = digtron.metal_sounds, @@ -59,14 +63,14 @@ minetest.register_node("digtron:power_connector", { meta:set_string("formspec", get_formspec_string(0,0)) end, - technic_run = function(pos, node) + technic_run = function(pos) local meta = minetest.get_meta(pos) local eu_input = meta:get_int("HV_EU_input") local demand = meta:get_int("HV_EU_demand") meta:set_string("infotext", S("Digtron Power @1/@2", eu_input, demand)) end, - on_receive_fields = function(pos, formname, fields, sender) + on_receive_fields = function(pos, _, fields, sender) local layout = digtron.DigtronLayout.create(pos, sender) local max_cost = 0 if layout.builders ~= nil then @@ -75,7 +79,7 @@ minetest.register_node("digtron:power_connector", { end end if layout.diggers ~= nil then - for _, node_image in pairs(layout.diggers) do + for _ in pairs(layout.diggers) do max_cost = max_cost + max_dig_cost end end @@ -87,7 +91,7 @@ minetest.register_node("digtron:power_connector", { meta:set_int("HV_EU_demand", current_max) elseif fields.value ~= nil then local number = tonumber(fields.value) or 0 - local number = math.min(math.max(number, 0), current_max) + number = math.min(math.max(number, 0), current_max) meta:set_int("HV_EU_demand", number) end diff --git a/nodes/node_storage.lua b/nodes/node_storage.lua index f6a8f96..f13d81e 100644 --- a/nodes/node_storage.lua +++ b/nodes/node_storage.lua @@ -1,6 +1,6 @@ -- internationalization boilerplate local MP = minetest.get_modpath(minetest.get_current_modname()) -local S, NS = dofile(MP.."/intllib.lua") +local S = dofile(MP.."/intllib.lua") local pipeworks_path = minetest.get_modpath("pipeworks") @@ -17,7 +17,7 @@ local inventory_formspec_string = "listring[current_player;main]" .. default.get_hotbar_bg(0,5.15) -local inventory_formspec = function(pos, meta) +local inventory_formspec = function() return inventory_formspec_string end @@ -57,7 +57,7 @@ minetest.register_node("digtron:inventory", { inv:set_size("main", 8*4) end, - can_dig = function(pos,player) + can_dig = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() return inv:is_empty("main") @@ -67,12 +67,12 @@ minetest.register_node("digtron:inventory", { ---------------------------------------------------------------- tube = (function() if pipeworks_path then return { - insert_object = function(pos, node, stack, direction) + insert_object = function(pos, _, stack) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() return inv:add_item("main", stack) end, - can_insert = function(pos, node, stack, direction) + can_insert = function(pos, _, stack) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() return inv:room_for_item("main", stack) @@ -98,7 +98,7 @@ local fuelstore_formspec_string = "listring[current_player;main]" .. default.get_hotbar_bg(0,5.15) -local fuelstore_formspec = function(pos, meta) +local fuelstore_formspec = function() return fuelstore_formspec_string end @@ -139,7 +139,7 @@ minetest.register_node("digtron:fuelstore", { end, -- Only allow fuel items to be placed in fuel - allow_metadata_inventory_put = function(pos, listname, index, stack, player) + allow_metadata_inventory_put = function(_, listname, _, stack) if listname == "fuel" then if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then return stack:get_count() @@ -150,7 +150,7 @@ minetest.register_node("digtron:fuelstore", { return 0 end, - can_dig = function(pos,player) + can_dig = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() return inv:is_empty("fuel") @@ -160,7 +160,7 @@ minetest.register_node("digtron:fuelstore", { ---------------------------------------------------------------- tube = (function() if pipeworks_path then return { - insert_object = function(pos, node, stack, direction) + insert_object = function(pos, _, stack) if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -168,7 +168,7 @@ minetest.register_node("digtron:fuelstore", { end return stack end, - can_insert = function(pos, node, stack, direction) + can_insert = function(pos, _, stack) if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -199,7 +199,7 @@ local combined_storage_formspec_string = "listring[current_player;main]" .. default.get_hotbar_bg(0,5.75) -local combined_storage_formspec = function(pos, meta) +local combined_storage_formspec = function() return combined_storage_formspec_string end @@ -224,7 +224,8 @@ minetest.register_node("digtron:combined_storage", { is_ground_content = false, tiles = { "digtron_plate.png^digtron_crossbrace.png^digtron_flammable_small.png^[transformR180^digtron_flammable_small.png", - "digtron_plate.png^digtron_crossbrace.png^digtron_flammable_small.png^[transformR180^digtron_flammable_small.png", "digtron_plate.png^digtron_crossbrace.png^digtron_flammable_small.png^digtron_storage.png", + "digtron_plate.png^digtron_crossbrace.png^digtron_flammable_small.png^[transformR180^digtron_flammable_small.png", + "digtron_plate.png^digtron_crossbrace.png^digtron_flammable_small.png^digtron_storage.png", "digtron_plate.png^digtron_crossbrace.png^digtron_flammable_small.png^digtron_storage.png", "digtron_plate.png^digtron_crossbrace.png^digtron_flammable_small.png^digtron_storage.png", "digtron_plate.png^digtron_crossbrace.png^digtron_flammable_small.png^digtron_storage.png", @@ -238,7 +239,7 @@ minetest.register_node("digtron:combined_storage", { end, -- Only allow fuel items to be placed in fuel - allow_metadata_inventory_put = function(pos, listname, index, stack, player) + allow_metadata_inventory_put = function(_, listname, _, stack) if listname == "fuel" then if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then return stack:get_count() @@ -249,7 +250,7 @@ minetest.register_node("digtron:combined_storage", { return stack:get_count() -- otherwise, allow all drops end, - allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, _, count) if to_list == "main" then return count end @@ -263,7 +264,7 @@ minetest.register_node("digtron:combined_storage", { return 0 end, - can_dig = function(pos,player) + can_dig = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() return inv:is_empty("fuel") and inv:is_empty("main") @@ -272,7 +273,7 @@ minetest.register_node("digtron:combined_storage", { -- Pipeworks compatibility ---------------------------------------------------------------- tube = (function() if pipeworks_path then return { - insert_object = function(pos, node, stack, direction) + insert_object = function(pos, _, stack, direction) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 and direction.y == 1 then @@ -280,7 +281,7 @@ minetest.register_node("digtron:combined_storage", { end return inv:add_item("main", stack) end, - can_insert = function(pos, node, stack, direction) + can_insert = function(pos, _, stack, direction) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 and direction.y == 1 then diff --git a/nodes/recipes.lua b/nodes/recipes.lua index 7d21ec8..ce10303 100644 --- a/nodes/recipes.lua +++ b/nodes/recipes.lua @@ -1,6 +1,6 @@ -- internationalization boilerplate local MP = minetest.get_modpath(minetest.get_current_modname()) -local S, NS = dofile(MP.."/intllib.lua") +local S = dofile(MP.."/intllib.lua") minetest.register_craftitem("digtron:digtron_core", { description = S("Digtron Core"), diff --git a/upgrades.lua b/upgrades.lua index dc19053..fb289e5 100644 --- a/upgrades.lua +++ b/upgrades.lua @@ -28,19 +28,19 @@ minetest.register_lbm({ minetest.register_lbm({ name = "digtron:fuelstore_upgrade", nodenames = {"digtron:fuelstore"}, - action = function(pos, node) + action = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() local list = inv:get_list("main") inv:set_list("main", {}) - inv:set_list("fuel", list) + inv:set_list("fuel", list) end }) minetest.register_lbm({ name = "digtron:autocontroller_lateral_upgrade", nodenames = {"digtron:auto_controller"}, - action = function(pos, node) + action = function(pos) local meta = minetest.get_meta(pos) local cycles = meta:get_int("offset") meta:set_int("cycles", cycles) @@ -52,7 +52,7 @@ minetest.register_lbm({ minetest.register_lbm({ name = "digtron:builder_extrusion_upgrade", nodenames = {"digtron:builder"}, - action = function(pos, node) + action = function(pos) local meta = minetest.get_meta(pos) meta:set_int("extrusion", 1) end