summaryrefslogtreecommitdiff
path: root/node_controllers.lua
diff options
context:
space:
mode:
authorFaceDeer <derksenmobile@gmail.com>2017-01-07 17:00:15 -0700
committerFaceDeer <derksenmobile@gmail.com>2017-01-07 17:00:15 -0700
commite704249735372a3232883cc8b7f25679f4949a8d (patch)
treec459d52783459809f8317012786e89667eb3c84f /node_controllers.lua
parent0b84a1dffa3224ada2a07204b64259f2fa15b458 (diff)
Auto-controller will keep trying if it encounters an unloaded node, this is a condition that can spontaneously self-correct
Diffstat (limited to 'node_controllers.lua')
-rw-r--r--node_controllers.lua10
1 files changed, 7 insertions, 3 deletions
diff --git a/node_controllers.lua b/node_controllers.lua
index 6960cbf..323b8f2 100644
--- a/node_controllers.lua
+++ b/node_controllers.lua
@@ -49,7 +49,7 @@ minetest.register_node("digtron:controller", {
return
end
- local newpos, status = digtron.execute_cycle(pos, clicker)
+ local newpos, status, return_code = digtron.execute_cycle(pos, clicker)
meta = minetest.get_meta(newpos)
if status ~= nil then
@@ -90,14 +90,18 @@ digtron.auto_cycle = function(pos)
return
end
- local newpos, status = digtron.execute_cycle(pos, player)
+ local newpos, status, return_code = digtron.execute_cycle(pos, player)
local cycle = 0
if vector.equals(pos, newpos) then
cycle = meta:get_int("offset")
status = status .. string.format("\nCycles remaining: %d\nHalted!", cycle)
meta:set_string("infotext", status)
- meta:set_string("formspec", auto_formspec)
+ 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)
+ else
+ meta:set_string("formspec", auto_formspec)
+ end
return
end