diff options
author | FaceDeer <derksenmobile@gmail.com> | 2018-01-07 13:38:25 -0700 |
---|---|---|
committer | FaceDeer <derksenmobile@gmail.com> | 2018-01-07 13:38:25 -0700 |
commit | 33995bc6ecf5b497f4e6b84b72fb476acf203af7 (patch) | |
tree | 0ff119e41832efcc2840342a1bae4c7e7fd96650 /util_execute_cycle.lua | |
parent | fdde32283afd1327a09872214b09a611002e95fa (diff) |
attempt to recover from failure to write to map
There have been reports of large, distant-from-player Digtrons apparently failing to completely write their layouts to the map, resulting in an inconsistency.
This adds an attempt to brute-force a solution. When a map write fails it will be retried until it succeeds, or until 1 second elapses (at which point the write is aborted in a hopefully somewhat clean manner).
Diffstat (limited to 'util_execute_cycle.lua')
-rw-r--r-- | util_execute_cycle.lua | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/util_execute_cycle.lua b/util_execute_cycle.lua index 3997395..b294aa2 100644 --- a/util_execute_cycle.lua +++ b/util_execute_cycle.lua @@ -283,7 +283,9 @@ digtron.execute_dig_cycle = function(pos, clicker) --move the array layout:move_layout_image(dir) - layout:write_layout_image(clicker) + if not layout:write_layout_image(clicker) then + return pos, "unrecoverable write_layout_image error", 1 + end local oldpos = {x=pos.x, y=pos.y, z=pos.z} pos = vector.add(pos, dir) meta = minetest.get_meta(pos) @@ -412,7 +414,10 @@ digtron.execute_move_cycle = function(pos, clicker) minetest.sound_play("truck", {gain=1.0, pos=pos}) --move the array - layout:write_layout_image(clicker) + if not layout:write_layout_image(clicker) then + return pos, "unrecoverable write_layout_image error", 1 + end + pos = vector.add(pos, dir) if move_player then clicker:moveto(vector.add(clicker:getpos(), dir), true) @@ -520,7 +525,9 @@ digtron.execute_downward_dig_cycle = function(pos, clicker) --move the array layout:move_layout_image(digtron.facedir_to_down_dir(facing)) - layout:write_layout_image(clicker) + if not layout:write_layout_image(clicker) then + return pos, "unrecoverable write_layout_image error", 1 + end local oldpos = {x=pos.x, y=pos.y, z=pos.z} pos = vector.add(pos, dir) meta = minetest.get_meta(pos) |