mirror of
https://github.com/joe7575/tubelib2.git
synced 2024-08-18 20:44:09 +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 and dir2 and num_conn then
|
||||||
if dir1 > dir2 then
|
if dir1 > dir2 then
|
||||||
dir1, dir2 = dir2, dir1
|
dir1, dir2 = dir2, dir1
|
||||||
end
|
end
|
||||||
local param2, _type = unpack(DirToParam2[dir1 * 10 + dir2] or {0, "S"})
|
local param2, _type = unpack(DirToParam2[dir1 * 10 + dir2] or {0, "S"})
|
||||||
return (num_conn * 32) + param2, _type
|
return (num_conn * 32) + param2, _type
|
||||||
|
end
|
||||||
|
return 0, "S"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -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,6 +236,7 @@ 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
|
||||||
|
if oldnode and oldnode.param2 then
|
||||||
local dir1, dir2 = self:update_after_dig_tube(pos, oldnode.param2)
|
local dir1, dir2 = self:update_after_dig_tube(pos, oldnode.param2)
|
||||||
if dir1 then update1(self, pos, dir1) end
|
if dir1 then update1(self, pos, dir1) end
|
||||||
if dir2 then update1(self, pos, dir2) end
|
if dir2 then update1(self, pos, dir2) end
|
||||||
@ -248,6 +248,7 @@ function Tube:after_dig_tube(pos, oldnode)
|
|||||||
self:del_from_cache(npos1,ndir1)
|
self:del_from_cache(npos1,ndir1)
|
||||||
self:update_secondary_node(npos1,ndir1)
|
self:update_secondary_node(npos1,ndir1)
|
||||||
self:update_secondary_node(npos2,ndir2)
|
self:update_secondary_node(npos2,ndir2)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user