mirror of
https://github.com/joe7575/tubelib2.git
synced 2025-02-26 05:13:45 +01:00
v0.5 node meta data removed, memory cache added instead of
This commit is contained in:
@ -47,7 +47,7 @@ end
|
||||
local function get_player_data(self, placer, pointed_thing)
|
||||
if placer and pointed_thing and pointed_thing.type == "node" then
|
||||
if placer:get_player_control().sneak then
|
||||
return pointed_thing.under, fdir(placer)
|
||||
return pointed_thing.under, fdir(self, placer)
|
||||
else
|
||||
return nil, fdir(self, placer)
|
||||
end
|
||||
|
@ -274,6 +274,7 @@ function Tube:add_tube_dir(pos, dir)
|
||||
local npos, node = self:get_node(pos, dir)
|
||||
if self.primary_node_names[node.name] then
|
||||
local d1, d2, num = self:decode_param2(npos, node.param2)
|
||||
if not num then return end
|
||||
-- not already connected to the new tube?
|
||||
dir = Turn180Deg[dir]
|
||||
if d1 ~= dir and dir ~= d2 then
|
||||
|
28
tube_api.lua
28
tube_api.lua
@ -71,19 +71,21 @@ local function update2(self, pos1, dir1, pos2, dir2)
|
||||
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
|
||||
if pos and dir1 and dir2 then
|
||||
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
|
||||
end
|
||||
|
||||
--
|
||||
|
Reference in New Issue
Block a user