From d74c250a40d11df0d466f750e30e5575e3212706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20=C3=85str=C3=B6m?= Date: Thu, 16 Aug 2018 12:43:02 +0200 Subject: [PATCH] Preserve active timers at frame move Previously timers were not copied over to the new nodes when frames move. This lead to blinky plants from mesecons to stop working after a platform has moved, and buttons getting stuck in their pressed state. Now the timers state for active timers are copied from the old node positions to the new node positions. --- technic/machines/other/frames.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/technic/machines/other/frames.lua b/technic/machines/other/frames.lua index 5459289..2e2a830 100644 --- a/technic/machines/other/frames.lua +++ b/technic/machines/other/frames.lua @@ -114,7 +114,17 @@ local function move_nodes_vect(poslist,vect,must_not_move,owner) for _, pos in ipairs(poslist) do local node = minetest.get_node(pos) local meta = minetest.get_meta(pos):to_table() - nodelist[#(nodelist)+1] = {oldpos = pos, pos = vector.add(pos, vect), node = node, meta = meta} + local timer = minetest.get_node_timer(pos) + nodelist[#nodelist+1] = { + oldpos = pos, + pos = vector.add(pos, vect), + node = node, + meta = meta, + timer = { + timeout = timer:get_timeout(), + elapsed = timer:get_elapsed() + } + } end local objects = {} for _, pos in ipairs(poslist) do @@ -133,6 +143,10 @@ local function move_nodes_vect(poslist,vect,must_not_move,owner) minetest.set_node(npos, n.node) local meta = minetest.get_meta(npos) meta:from_table(n.meta) + local timer = minetest.get_node_timer(npos) + if n.timer.timeout ~= 0 or n.timer.elapsed ~= 0 then + timer:set(n.timer.timeout, n.timer.elapsed) + end for __,pos in ipairs(poslist) do if npos.x == pos.x and npos.y == pos.y and npos.z == pos.z then table.remove(poslist, __)