mirror of
https://github.com/joe7575/tubelib2.git
synced 2024-10-04 00:43:14 +02:00
v0.5 node meta data removed, memory cache added instead of
This commit is contained in:
parent
396a7ac3fd
commit
b4db615b95
26
tube_api.lua
26
tube_api.lua
@ -70,6 +70,22 @@ local function update2(self, pos1, dir1, pos2, dir2)
|
||||
self:update_secondary_node(spos2, sdir2, spos1, sdir1)
|
||||
end
|
||||
|
||||
local function update3(self, pos, dir1, dir2)
|
||||
local fpos1,fdir1,cnt1 = self:walk_tube_line(pos, dir1)
|
||||
local fpos2,fdir2,cnt2 = self:walk_tube_line(pos, dir2)
|
||||
-- Translate fpos/fdir pointing to the secondary node into
|
||||
-- spos/sdir of the secondary node pointing to the tube.
|
||||
local spos1, sdir1 = get_pos(fpos1,fdir1), Turn180Deg[fdir1]
|
||||
local spos2, sdir2 = get_pos(fpos2,fdir2), Turn180Deg[fdir2]
|
||||
self:del_from_cache(spos1, sdir1)
|
||||
self:del_from_cache(spos2, sdir2)
|
||||
self:add_to_cache(spos1, sdir1, spos2, sdir2)
|
||||
self:add_to_cache(spos2, sdir2, spos1, sdir1)
|
||||
self:update_secondary_node(spos1, sdir1, spos2, sdir2)
|
||||
self:update_secondary_node(spos2, sdir2, spos1, sdir1)
|
||||
return dir1, dir2, fpos1, fpos2, fdir1, fdir2, cnt1 or 0, cnt2 or 0
|
||||
end
|
||||
|
||||
--
|
||||
-- API Functions
|
||||
--
|
||||
@ -175,6 +191,16 @@ function Tube:get_connected_node_pos(pos, dir)
|
||||
return spos, fdir
|
||||
end
|
||||
|
||||
-- To be called from a repair tool in the case of a "WorldEdit" or with
|
||||
-- legacy nodes corrupted tube line.
|
||||
function Tube:tool_repair_tube(pos)
|
||||
local _, node = self:primary_node(pos)
|
||||
if node then
|
||||
local dir1, dir2 = self:decode_param2(pos, node.param2)
|
||||
return update3(self, pos, dir1, dir2)
|
||||
end
|
||||
end
|
||||
|
||||
-- To be called from a repair tool in the case, tube nodes are "unbreakable".
|
||||
function Tube:tool_remove_tube(pos, sound)
|
||||
local _,node = self:get_node(pos)
|
||||
|
Loading…
Reference in New Issue
Block a user