forked from minetest-mods/technic
Actually call the mvps callback
This commit is contained in:
parent
83ecc59e5b
commit
902cd07218
|
@ -76,14 +76,14 @@ local function table_empty(table)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function add_table(table,toadd)
|
local function add_table(table,toadd)
|
||||||
local i=1
|
local i = 1
|
||||||
while true do
|
while true do
|
||||||
o=table[i]
|
o = table[i]
|
||||||
if o==toadd then return end
|
if o == toadd then return end
|
||||||
if o==nil then break end
|
if o == nil then break end
|
||||||
i=i+1
|
i = i+1
|
||||||
end
|
end
|
||||||
table[i]=toadd
|
table[i] = toadd
|
||||||
end
|
end
|
||||||
|
|
||||||
local function move_nodes_vect(poslist,vect,must_not_move,owner)
|
local function move_nodes_vect(poslist,vect,must_not_move,owner)
|
||||||
|
@ -105,49 +105,42 @@ local function move_nodes_vect(poslist,vect,must_not_move,owner)
|
||||||
return
|
return
|
||||||
end]]
|
end]]
|
||||||
end
|
end
|
||||||
nodelist={}
|
local nodelist = {}
|
||||||
frameslist = {}
|
for _, pos in ipairs(poslist) do
|
||||||
for _,pos in ipairs(poslist) do
|
local node = minetest.get_node(pos)
|
||||||
local node=minetest.get_node(pos)
|
local meta = minetest.get_meta(pos):to_table()
|
||||||
local meta=minetest.get_meta(pos):to_table()
|
nodelist[#(nodelist)+1] = {oldpos = pos, pos = vector.add(pos, vect), node = node, meta = meta}
|
||||||
nodelist[#(nodelist)+1]={pos=pos,node=node,meta=meta}
|
|
||||||
if frames_pos[pos_to_string(pos)] then
|
|
||||||
frameslist[#frameslist+1] = {pos=pos, name=frames_pos[pos_to_string(pos)]}
|
|
||||||
frames_pos[pos_to_string(pos)] = nil
|
|
||||||
end
|
end
|
||||||
end
|
local objects = {}
|
||||||
objects={}
|
for _, pos in ipairs(poslist) do
|
||||||
for _,pos in ipairs(poslist) do
|
|
||||||
for _,object in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
|
for _,object in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||||
add_table(objects,object)
|
local entity = object:get_luaentity()
|
||||||
|
if not entity or not mesecon:is_mvps_unmov(entity.name) then
|
||||||
|
add_table(objects, object)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for _,obj in ipairs(objects) do
|
|
||||||
obj:setpos(vector.add(obj:getpos(),vect))
|
|
||||||
le=obj:get_luaentity()
|
|
||||||
if le and le.name == "pipeworks:tubed_item" then
|
|
||||||
le.start_pos=vector.add(le.start_pos,vect)
|
|
||||||
end
|
end
|
||||||
end
|
for _, obj in ipairs(objects) do
|
||||||
for _, n in ipairs(frameslist) do
|
obj:setpos(vector.add(obj:getpos(), vect))
|
||||||
local npos=vector.add(n.pos,vect)
|
|
||||||
frames_pos[pos_to_string(npos)] = n.name
|
|
||||||
end
|
end
|
||||||
for _,n in ipairs(nodelist) do
|
for _,n in ipairs(nodelist) do
|
||||||
local npos=vector.add(n.pos,vect)
|
local npos = n.pos
|
||||||
minetest.set_node(npos,n.node)
|
minetest.set_node(npos, n.node)
|
||||||
local meta=minetest.get_meta(npos)
|
local meta = minetest.get_meta(npos)
|
||||||
meta:from_table(n.meta)
|
meta:from_table(n.meta)
|
||||||
for __,pos in ipairs(poslist) do
|
for __,pos in ipairs(poslist) do
|
||||||
if npos.x==pos.x and npos.y==pos.y and npos.z==pos.z then
|
if npos.x == pos.x and npos.y == pos.y and npos.z == pos.z then
|
||||||
table.remove(poslist, __)
|
table.remove(poslist, __)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for __,pos in ipairs(poslist) do
|
for __, pos in ipairs(poslist) do
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
end
|
end
|
||||||
|
for _, callback in ipairs(mesecon.on_mvps_move) do
|
||||||
|
callback(nodelist)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function is_supported_node(name)
|
local function is_supported_node(name)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user