summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElias Åström <eliast.croc@gmail.com>2018-08-16 12:43:02 +0200
committerSmallJoker <SmallJoker@users.noreply.github.com>2018-08-25 12:24:58 +0200
commitd74c250a40d11df0d466f750e30e5575e3212706 (patch)
tree3a4225f3ae37b37cf1bb3c5917fea4229a70b1c5
parent2e7859c35e55b842752c6533edae2dd19290fabc (diff)
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.
-rw-r--r--technic/machines/other/frames.lua16
1 files changed, 15 insertions, 1 deletions
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, __)