mirror of
https://github.com/joe7575/tubelib2.git
synced 2024-07-15 04:09:34 +02:00
bugfix
This commit is contained in:
parent
e307045268
commit
abde0b6ebb
@ -160,9 +160,9 @@ end
|
|||||||
function Tube:get_next_tube(pos, dir)
|
function Tube:get_next_tube(pos, dir)
|
||||||
local param2, npos = self:get_primary_node_param2(pos, dir)
|
local param2, npos = self:get_primary_node_param2(pos, dir)
|
||||||
if param2 then
|
if param2 then
|
||||||
local val = Param2ToDir[param2 % 32]
|
local val = Param2ToDir[param2 % 32] or 0
|
||||||
local dir1, dir2 = math.floor(val / 10), val % 10
|
local dir1, dir2 = math.floor(val / 10), val % 10
|
||||||
local num_conn = math.floor(param2 / 32)
|
local num_conn = math.floor(param2 / 32) or 0
|
||||||
if Turn180Deg[dir] == dir1 then
|
if Turn180Deg[dir] == dir1 then
|
||||||
return npos, dir2, num_conn
|
return npos, dir2, num_conn
|
||||||
else
|
else
|
||||||
@ -174,11 +174,14 @@ end
|
|||||||
|
|
||||||
-- Return param2 and tube type ("A"/"S")
|
-- Return param2 and tube type ("A"/"S")
|
||||||
function Tube:encode_param2(dir1, dir2, num_conn)
|
function Tube:encode_param2(dir1, dir2, num_conn)
|
||||||
if dir1 > dir2 then
|
if dir1 and dir2 and num_conn then
|
||||||
dir1, dir2 = dir2, dir1
|
if dir1 > dir2 then
|
||||||
|
dir1, dir2 = dir2, dir1
|
||||||
|
end
|
||||||
|
local param2, _type = unpack(DirToParam2[dir1 * 10 + dir2] or {0, "S"})
|
||||||
|
return (num_conn * 32) + param2, _type
|
||||||
end
|
end
|
||||||
local param2, _type = unpack(DirToParam2[dir1 * 10 + dir2] or {0, "S"})
|
return 0, "S"
|
||||||
return (num_conn * 32) + param2, _type
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
25
tube_api.lua
25
tube_api.lua
@ -120,7 +120,6 @@ local function update_secondary_nodes_after_node_placed(self, pos, dirs)
|
|||||||
local tmp, npos
|
local tmp, npos
|
||||||
if self.force_to_use_tubes then
|
if self.force_to_use_tubes then
|
||||||
tmp, npos = self:get_special_node(pos, dir)
|
tmp, npos = self:get_special_node(pos, dir)
|
||||||
print("tmp, npos", tmp, S(npos))
|
|
||||||
else
|
else
|
||||||
tmp, npos = self:get_secondary_node(pos, dir)
|
tmp, npos = self:get_secondary_node(pos, dir)
|
||||||
end
|
end
|
||||||
@ -237,17 +236,19 @@ function Tube:after_dig_tube(pos, oldnode)
|
|||||||
-- s..secondary, f..far, n..near, x..node to be removed
|
-- s..secondary, f..far, n..near, x..node to be removed
|
||||||
|
|
||||||
-- update tubes
|
-- update tubes
|
||||||
local dir1, dir2 = self:update_after_dig_tube(pos, oldnode.param2)
|
if oldnode and oldnode.param2 then
|
||||||
if dir1 then update1(self, pos, dir1) end
|
local dir1, dir2 = self:update_after_dig_tube(pos, oldnode.param2)
|
||||||
if dir2 then update1(self, pos, dir2) end
|
if dir1 then update1(self, pos, dir1) end
|
||||||
|
if dir2 then update1(self, pos, dir2) end
|
||||||
-- Update secondary nodes, if right beside
|
|
||||||
dir1, dir2 = self:decode_param2(pos, oldnode.param2)
|
-- Update secondary nodes, if right beside
|
||||||
local npos1,ndir1 = get_pos(pos, dir1),Turn180Deg[dir1]
|
dir1, dir2 = self:decode_param2(pos, oldnode.param2)
|
||||||
local npos2,ndir2 = get_pos(pos, dir2),Turn180Deg[dir2]
|
local npos1,ndir1 = get_pos(pos, dir1),Turn180Deg[dir1]
|
||||||
self:del_from_cache(npos1,ndir1)
|
local npos2,ndir2 = get_pos(pos, dir2),Turn180Deg[dir2]
|
||||||
self:update_secondary_node(npos1,ndir1)
|
self:del_from_cache(npos1,ndir1)
|
||||||
self:update_secondary_node(npos2,ndir2)
|
self:update_secondary_node(npos1,ndir1)
|
||||||
|
self:update_secondary_node(npos2,ndir2)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user