Place unloaded flying blocks to dest pos

This commit is contained in:
Joachim Stolberg 2022-12-02 20:29:38 +01:00
parent c83da97df5
commit 2b541d0197

View File

@ -3,7 +3,7 @@
TechAge TechAge
======= =======
Copyright (C) 2020-2021 Joachim Stolberg Copyright (C) 2020-2022 Joachim Stolberg
AGPL v3 AGPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
@ -308,18 +308,7 @@ local function detach_objects(pos, self)
self.players = {} self.players = {}
end end
local function entity_to_node(pos, obj) local function set_node(pos, name, param2, metadata)
local self = obj:get_luaentity()
if self then
local name = self.item_name or "air"
local param2 = self.param2 or 0
local metadata = self.metadata or {}
detach_objects(pos, self)
if self.base_pos then
local nvm = techage.get_nvm(self.base_pos)
nvm.running = nil
end
minetest.after(0.1, obj.remove, obj)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
local ndef1 = minetest.registered_nodes[name] local ndef1 = minetest.registered_nodes[name]
local ndef2 = minetest.registered_nodes[node.name] local ndef2 = minetest.registered_nodes[node.name]
@ -342,6 +331,21 @@ local function entity_to_node(pos, obj)
minetest.add_item(pos, ItemStack(name)) minetest.add_item(pos, ItemStack(name))
end end
end end
local function entity_to_node(pos, obj)
local self = obj:get_luaentity()
if self then
local name = self.item_name or "air"
local param2 = self.param2 or 0
local metadata = self.metadata or {}
detach_objects(pos, self)
if self.base_pos then
local nvm = techage.get_nvm(self.base_pos)
nvm.running = nil
end
minetest.after(0.1, obj.remove, obj)
set_node(pos, name, param2, metadata)
end
end end
local function node_to_entity(start_pos) local function node_to_entity(start_pos)
@ -468,6 +472,12 @@ minetest.register_entity("techage:move_item", {
}, },
get_staticdata = function(self) get_staticdata = function(self)
if self.start_pos and self.dest_pos then
local pos = vector.round(self.object:get_pos())
if not vector.equals(pos, self.start_pos) and not vector.equals(pos, self.dest_pos) then
set_node(self.dest_pos, self.item_name, self.param2, self.metadata or {})
end
end
return minetest.serialize({ return minetest.serialize({
item_name = self.item_name, item_name = self.item_name,
param2 = self.param2, param2 = self.param2,