summaryrefslogtreecommitdiff
path: root/nodes
diff options
context:
space:
mode:
authorFaceDeer <derksenmobile@gmail.com>2018-01-07 13:38:25 -0700
committerFaceDeer <derksenmobile@gmail.com>2018-01-07 13:38:25 -0700
commit33995bc6ecf5b497f4e6b84b72fb476acf203af7 (patch)
tree0ff119e41832efcc2840342a1bae4c7e7fd96650 /nodes
parentfdde32283afd1327a09872214b09a611002e95fa (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 'nodes')
-rw-r--r--nodes/node_axle.lua16
1 files changed, 9 insertions, 7 deletions
diff --git a/nodes/node_axle.lua b/nodes/node_axle.lua
index 99dda4b..bdfaf76 100644
--- a/nodes/node_axle.lua
+++ b/nodes/node_axle.lua
@@ -45,13 +45,15 @@ minetest.register_node("digtron:axle", {
local image = DigtronLayout.create(pos, clicker)
image:rotate_layout_image(node.param2)
if image:can_write_layout_image() then
- image:write_layout_image(clicker)
-
- minetest.sound_play("whirr", {gain=1.0, pos=pos})
- meta = minetest.get_meta(pos)
- meta:set_string("waiting", "true")
- meta:set_string("infotext", nil)
- minetest.get_node_timer(pos):start(digtron.config.cycle_time*2)
+ if image:write_layout_image(clicker) then
+ minetest.sound_play("whirr", {gain=1.0, pos=pos})
+ meta = minetest.get_meta(pos)
+ meta:set_string("waiting", "true")
+ meta:set_string("infotext", nil)
+ minetest.get_node_timer(pos):start(digtron.config.cycle_time*2)
+ else
+ meta:set_string("infotext", "unrecoverable write_layout_image error")
+ end
else
minetest.sound_play("buzzer", {gain=1.0, pos=pos})
meta:set_string("infotext", S("Digtron is obstructed."))