From e704249735372a3232883cc8b7f25679f4949a8d Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Sat, 7 Jan 2017 17:00:15 -0700 Subject: Auto-controller will keep trying if it encounters an unloaded node, this is a condition that can spontaneously self-correct --- node_controllers.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'node_controllers.lua') 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 -- cgit v1.2.3