From c2e3d7c4e58b2563e79aead60c6efedf27c786cf Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sun, 15 Jan 2017 11:53:49 +0100 Subject: [PATCH] Fix most of the namespace pollutions reported in #311 --- mesecons_delayer/init.lua | 6 ++++-- mesecons_extrawires/crossover.lua | 2 +- mesecons_gates/init.lua | 2 +- mesecons_insulated/init.lua | 2 +- mesecons_lamp/init.lua | 2 +- mesecons_pistons/init.lua | 27 +++++++++++++++------------ mesecons_pressureplates/init.lua | 2 +- mesecons_wires/init.lua | 2 +- 8 files changed, 25 insertions(+), 20 deletions(-) diff --git a/mesecons_delayer/init.lua b/mesecons_delayer/init.lua index da576ad..7c480c1 100644 --- a/mesecons_delayer/init.lua +++ b/mesecons_delayer/init.lua @@ -47,7 +47,8 @@ elseif i == 2 then delaytime = 0.3 elseif i == 3 then delaytime = 0.5 elseif i == 4 then delaytime = 1.0 end -boxes = {{ -6/16, -8/16, -6/16, 6/16, -7/16, 6/16 }, -- the main slab +local boxes = { + { -6/16, -8/16, -6/16, 6/16, -7/16, 6/16 }, -- the main slab { -2/16, -7/16, -4/16, 2/16, -26/64, -3/16 }, -- the jeweled "on" indicator { -3/16, -7/16, -3/16, 3/16, -26/64, -2/16 }, @@ -57,7 +58,8 @@ boxes = {{ -6/16, -8/16, -6/16, 6/16, -7/16, 6/16 }, -- the main slab { -6/16, -7/16, -6/16, -4/16, -27/64, -4/16 }, -- the timer indicator { -8/16, -8/16, -1/16, -6/16, -7/16, 1/16 }, -- the two wire stubs - { 6/16, -8/16, -1/16, 8/16, -7/16, 1/16 }} + { 6/16, -8/16, -1/16, 8/16, -7/16, 1/16 } +} minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), { description = "Delayer", diff --git a/mesecons_extrawires/crossover.lua b/mesecons_extrawires/crossover.lua index bbf00ff..7dc35f2 100644 --- a/mesecons_extrawires/crossover.lua +++ b/mesecons_extrawires/crossover.lua @@ -1,4 +1,4 @@ -function crossover_get_rules(node) +local function crossover_get_rules(node) return { {--first wire {x=-1,y=0,z=0}, diff --git a/mesecons_gates/init.lua b/mesecons_gates/init.lua index f3d6f09..57815ef 100644 --- a/mesecons_gates/init.lua +++ b/mesecons_gates/init.lua @@ -54,7 +54,7 @@ local function update_gate(pos, node, link, newstate) end end -function register_gate(name, inputnumber, assess, recipe) +local function register_gate(name, inputnumber, assess, recipe) local get_inputrules = inputnumber == 2 and gate_get_input_rules_twoinputs or gate_get_input_rules_oneinput local description = "Mesecons Logic Gate: "..name diff --git a/mesecons_insulated/init.lua b/mesecons_insulated/init.lua index c6fc05e..15b916b 100644 --- a/mesecons_insulated/init.lua +++ b/mesecons_insulated/init.lua @@ -1,4 +1,4 @@ -function insulated_wire_get_rules(node) +local function insulated_wire_get_rules(node) local rules = {{x = 1, y = 0, z = 0}, {x =-1, y = 0, z = 0}} if node.param2 == 1 or node.param2 == 3 then diff --git a/mesecons_lamp/init.lua b/mesecons_lamp/init.lua index 362453c..811e659 100644 --- a/mesecons_lamp/init.lua +++ b/mesecons_lamp/init.lua @@ -2,7 +2,7 @@ -- A lamp is "is an electrical device used to create artificial light" (wikipedia) -- guess what? -mesecon_lamp_box = { +local mesecon_lamp_box = { type = "wallmounted", wall_top = {-0.3125,0.375,-0.3125,0.3125,0.5,0.3125}, wall_bottom = {-0.3125,-0.5,-0.3125,0.3125,-0.375,0.3125}, diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index 474f621..a52c802 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -1,6 +1,6 @@ -- Get mesecon rules of pistons -piston_rules = -{{x=0, y=0, z=1}, --everything apart from z- (pusher side) +local piston_rules = { + {x=0, y=0, z=1}, --everything apart from z- (pusher side) {x=1, y=0, z=0}, {x=-1, y=0, z=0}, {x=1, y=1, z=0}, @@ -8,29 +8,32 @@ piston_rules = {x=-1, y=1, z=0}, {x=-1, y=-1, z=0}, {x=0, y=1, z=1}, - {x=0, y=-1, z=1}} + {x=0, y=-1, z=1} +} -local piston_up_rules = -{{x=0, y=0, z=-1}, --everything apart from y+ (pusher side) +local piston_up_rules = { + {x=0, y=0, z=-1}, --everything apart from y+ (pusher side) {x=1, y=0, z=0}, {x=-1, y=0, z=0}, {x=0, y=0, z=1}, {x=1, y=-1, z=0}, {x=-1, y=-1, z=0}, {x=0, y=-1, z=1}, - {x=0, y=-1, z=-1}} + {x=0, y=-1, z=-1} +} -local piston_down_rules = -{{x=0, y=0, z=-1}, --everything apart from y- (pusher side) +local piston_down_rules = { + {x=0, y=0, z=-1}, --everything apart from y- (pusher side) {x=1, y=0, z=0}, {x=-1, y=0, z=0}, {x=0, y=0, z=1}, {x=1, y=1, z=0}, {x=-1, y=1, z=0}, {x=0, y=1, z=1}, - {x=0, y=1, z=-1}} + {x=0, y=1, z=-1} +} -local piston_get_rules = function (node) +local function piston_get_rules(node) local rules = piston_rules for i = 1, node.param2 do rules = mesecon.rotate_rules_left(rules) @@ -38,7 +41,7 @@ local piston_get_rules = function (node) return rules end -piston_facedir_direction = function (node) +local function piston_facedir_direction(node) local rules = {{x = 0, y = 0, z = -1}} for i = 1, node.param2 do rules = mesecon.rotate_rules_left(rules) @@ -46,7 +49,7 @@ piston_facedir_direction = function (node) return rules[1] end -piston_get_direction = function(dir, node) +local function piston_get_direction(dir, node) if type(dir) == "function" then return dir(node) else diff --git a/mesecons_pressureplates/init.lua b/mesecons_pressureplates/init.lua index 858f6ab..cd4529b 100644 --- a/mesecons_pressureplates/init.lua +++ b/mesecons_pressureplates/init.lua @@ -8,7 +8,7 @@ local pp_box_on = { fixed = { -7/16, -8/16, -7/16, 7/16, -7.5/16, 7/16 }, } -pp_on_timer = function (pos, elapsed) +local function pp_on_timer(pos, elapsed) local node = minetest.get_node(pos) local basename = minetest.registered_nodes[node.name].pressureplate_basename diff --git a/mesecons_wires/init.lua b/mesecons_wires/init.lua index 879cfa1..ced7c99 100644 --- a/mesecons_wires/init.lua +++ b/mesecons_wires/init.lua @@ -140,7 +140,7 @@ nid_inc = function (nid) return i <= 8 end -register_wires = function() +local function register_wires() local nid = {} while true do -- Create group specifiction and nodeid string (see note above for details)