mirror of
https://github.com/minetest-mods/digtron.git
synced 2024-08-19 20:34:04 +02:00
Builder wasn't saving manually-entered facing value. Also, make metadata movement more robust.
This commit is contained in:
parent
e43c5d3974
commit
c6a63cb4d4
@ -77,6 +77,7 @@ minetest.register_node("digtron:builder", {
|
|||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local period = tonumber(fields.period)
|
local period = tonumber(fields.period)
|
||||||
local offset = tonumber(fields.offset)
|
local offset = tonumber(fields.offset)
|
||||||
|
local build_facing = tonumber(fields.build_facing)
|
||||||
if period and period > 0 then
|
if period and period > 0 then
|
||||||
meta:set_int("period", math.floor(tonumber(fields.period)))
|
meta:set_int("period", math.floor(tonumber(fields.period)))
|
||||||
else
|
else
|
||||||
@ -87,6 +88,9 @@ minetest.register_node("digtron:builder", {
|
|||||||
else
|
else
|
||||||
offset = meta:get_int("offset")
|
offset = meta:get_int("offset")
|
||||||
end
|
end
|
||||||
|
if build_facing and build_facing >= 0 and build_facing < 24 then
|
||||||
|
meta:set_int("build_facing", math.floor(build_facing))
|
||||||
|
end
|
||||||
|
|
||||||
if fields.set then
|
if fields.set then
|
||||||
local buildpos = digtron.find_new_pos(pos, minetest.get_node(pos).param2)
|
local buildpos = digtron.find_new_pos(pos, minetest.get_node(pos).param2)
|
||||||
@ -122,11 +126,6 @@ minetest.register_node("digtron:builder", {
|
|||||||
local facing = minetest.get_node(pos).param2
|
local facing = minetest.get_node(pos).param2
|
||||||
local buildpos = digtron.find_new_pos(pos, facing)
|
local buildpos = digtron.find_new_pos(pos, facing)
|
||||||
meta:set_int("build_facing", minetest.get_node(buildpos).param2)
|
meta:set_int("build_facing", minetest.get_node(buildpos).param2)
|
||||||
else
|
|
||||||
local build_facing = tonumber(fields.build_facing)
|
|
||||||
if build_facing and build_facing >= 0 and build_facing < 24 then
|
|
||||||
meta:set_int("build_facing", math.floor(build_facing))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
digtron.update_builder_item(pos)
|
digtron.update_builder_item(pos)
|
||||||
|
@ -5,35 +5,19 @@ digtron.move_node = function(pos, newpos, player_name)
|
|||||||
local oldnode = minetest.get_node(newpos)
|
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.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 })
|
minetest.add_node(newpos, { name=node.name, param1=node.param1, param2=node.param2 })
|
||||||
if node_def.after_place_node then
|
-- copy the metadata
|
||||||
node_def.after_place_node(newpos)
|
local oldmeta = minetest.get_meta(pos):to_table()
|
||||||
end
|
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
|
-- Move the little floaty entity inside the builders
|
||||||
if minetest.get_item_group(node.name, "digtron") == 4 then
|
if minetest.get_item_group(node.name, "digtron") == 4 then
|
||||||
digtron.update_builder_item(newpos)
|
digtron.update_builder_item(newpos)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if node_def.after_place_node then
|
||||||
|
node_def.after_place_node(newpos)
|
||||||
|
end
|
||||||
|
|
||||||
-- remove node from old position
|
-- remove node from old position
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
if node_def.after_dig_node then
|
if node_def.after_dig_node then
|
||||||
|
Loading…
Reference in New Issue
Block a user