summaryrefslogtreecommitdiff
path: root/util_movement.lua
diff options
context:
space:
mode:
authorFaceDeer <derksenmobile@gmail.com>2017-01-07 10:53:25 -0700
committerFaceDeer <derksenmobile@gmail.com>2017-01-07 10:53:25 -0700
commitc6a63cb4d43ab2850a2e6430ec1780349b5374f0 (patch)
tree932e0a2edde96e34afcc22312e6018ff1ebee979 /util_movement.lua
parente43c5d3974e99b5d8d9a96f5d5461be35eeec65b (diff)
Builder wasn't saving manually-entered facing value. Also, make metadata movement more robust.
Diffstat (limited to 'util_movement.lua')
-rw-r--r--util_movement.lua30
1 files changed, 7 insertions, 23 deletions
diff --git a/util_movement.lua b/util_movement.lua
index 204d045..218ba48 100644
--- a/util_movement.lua
+++ b/util_movement.lua
@@ -5,35 +5,19 @@ digtron.move_node = function(pos, newpos, player_name)
local oldnode = minetest.get_node(newpos)
minetest.log("action", string.format("%s moves %s from (%d, %d, %d) to (%d, %d, %d), displacing %s", player_name, node.name, pos.x, pos.y, pos.z, newpos.x, newpos.y, newpos.z, oldnode.name))
minetest.add_node(newpos, { name=node.name, param1=node.param1, param2=node.param2 })
- if node_def.after_place_node then
- node_def.after_place_node(newpos)
- end
+ -- copy the metadata
+ local oldmeta = minetest.get_meta(pos):to_table()
+ minetest.get_meta(newpos):from_table(oldmeta)
- local oldmeta = minetest.get_meta(pos)
- local oldinv = oldmeta:get_inventory()
- local list = oldinv:get_list("main")
- local fuel = oldinv:get_list("fuel")
- local oldformspec = oldmeta:get_string("formspec")
-
- local newmeta = minetest.get_meta(newpos)
- local newinv = newmeta:get_inventory()
- newinv:set_list("main", list)
- newinv:set_list("fuel", fuel)
- newmeta:set_string("formspec", oldformspec)
-
- newmeta:set_string("triggering_player", oldmeta:get_string("triggering_player")) -- for auto-controllers
-
- newmeta:set_int("offset", oldmeta:get_int("offset"))
- newmeta:set_int("period", oldmeta:get_int("period"))
- newmeta:set_int("build_facing", oldmeta:get_int("build_facing"))
- newmeta:set_float("fuel_burning", oldmeta:get_float("fuel_burning"))
- newmeta:set_string("infotext", oldmeta:get_string("infotext"))
-
-- Move the little floaty entity inside the builders
if minetest.get_item_group(node.name, "digtron") == 4 then
digtron.update_builder_item(newpos)
end
+ if node_def.after_place_node then
+ node_def.after_place_node(newpos)
+ end
+
-- remove node from old position
minetest.remove_node(pos)
if node_def.after_dig_node then