mirror of
https://github.com/minetest-mods/technic.git
synced 2024-08-20 05:24:11 +02:00
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.
This commit is contained in:
parent
2e7859c35e
commit
d74c250a40
@ -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, __)
|
||||
|
Loading…
Reference in New Issue
Block a user