summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFaceDeer <FaceDeer@users.noreply.github.com>2018-05-09 08:18:55 -0600
committerGitHub <noreply@github.com>2018-05-09 08:18:55 -0600
commitb33d33074c2848a05d64131e5aed85d004bc2d9a (patch)
treef5dad10b65c22d9b80451a610f8c687e1ae4c362
parent6ef9f95a608de5e1464280e93ca5233b25108a75 (diff)
parent3209856d6beef2f5076002061d6a83e0ca3b6720 (diff)
Merge pull request #20 from numberZero/fix-global
No need to make auto_cycle global
-rw-r--r--nodes/node_controllers.lua15
1 files changed, 7 insertions, 8 deletions
diff --git a/nodes/node_controllers.lua b/nodes/node_controllers.lua
index e066f18..e00cb35 100644
--- a/nodes/node_controllers.lua
+++ b/nodes/node_controllers.lua
@@ -107,8 +107,7 @@ if minetest.get_modpath("doc") then
"tooltip[help;" .. S("Show documentation about this block").. "]"
end
--- Needed to make this global so that it could recurse into minetest.after
-digtron.auto_cycle = function(pos)
+local function auto_cycle(pos)
local node = minetest.get_node(pos)
local controlling_coordinate = digtron.get_controlling_coordinate(pos, node.param2)
local meta = minetest.get_meta(pos)
@@ -128,13 +127,13 @@ digtron.auto_cycle = function(pos)
status = status .. "\n" .. S("Cycles remaining: @1", cycle) .. "\n" .. S("Halted!")
meta:set_string("infotext", status)
if return_code == 1 then --return code 1 happens when there's unloaded nodes adjacent, just keep trying.
- minetest.after(meta:get_int("period"), digtron.auto_cycle, newpos)
+ minetest.after(meta:get_int("period"), auto_cycle, newpos)
else
meta:set_string("formspec", auto_formspec)
end
else
meta = minetest.get_meta(newpos)
- minetest.after(meta:get_int("period"), digtron.auto_cycle, newpos)
+ minetest.after(meta:get_int("period"), auto_cycle, newpos)
meta:set_string("infotext", status)
meta:set_string("lateral_done", "true")
end
@@ -147,7 +146,7 @@ digtron.auto_cycle = function(pos)
status = status .. "\n" .. S("Cycles remaining: @1", cycle) .. "\n" .. S("Halted!")
meta:set_string("infotext", status)
if return_code == 1 then --return code 1 happens when there's unloaded nodes adjacent, just keep trying.
- minetest.after(meta:get_int("period"), digtron.auto_cycle, newpos)
+ minetest.after(meta:get_int("period"), auto_cycle, newpos)
else
meta:set_string("formspec", auto_formspec)
end
@@ -162,7 +161,7 @@ digtron.auto_cycle = function(pos)
meta:set_string("lateral_done", nil)
if cycle > 0 then
- minetest.after(meta:get_int("period"), digtron.auto_cycle, newpos)
+ minetest.after(meta:get_int("period"), auto_cycle, newpos)
else
meta:set_string("formspec", auto_formspec)
end
@@ -252,7 +251,7 @@ minetest.register_node("digtron:auto_controller", {
if fields.execute then
meta:set_string("waiting", nil)
meta:set_string("formspec", nil)
- digtron.auto_cycle(pos)
+ auto_cycle(pos)
end
end
end
@@ -343,4 +342,4 @@ minetest.register_node("digtron:pusher", {
minetest.get_meta(pos):set_string("waiting", nil)
end,
-}) \ No newline at end of file
+})