forked from mtcontrib/pipeworks
Fix some more coding style, fix a crash, get rid of a conversion table (only used for the table generation)
This commit is contained in:
parent
27f3a8ab31
commit
76183bc325
32
tubes.lua
32
tubes.lua
|
@ -12,7 +12,6 @@ minetest.register_alias("pipeworks:tube", "pipeworks:tube_000000")
|
||||||
|
|
||||||
local REGISTER_COMPATIBILITY = true
|
local REGISTER_COMPATIBILITY = true
|
||||||
|
|
||||||
local stv = {1, 3, 5, 2, 4, 6}
|
|
||||||
local vti = {4, 3, 2, 1, 6, 5}
|
local vti = {4, 3, 2, 1, 6, 5}
|
||||||
|
|
||||||
local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, ends, short, inv, special, connects, style)
|
local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, ends, short, inv, special, connects, style)
|
||||||
|
@ -24,15 +23,15 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
|
||||||
outimgs[vti[i]] = plain[i]
|
outimgs[vti[i]] = plain[i]
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, side in ipairs(connects) do
|
for _, v in ipairs(connects) do
|
||||||
local v = stv[side+1]
|
|
||||||
pipeworks.add_node_box(outboxes, pipeworks.tube_boxes[v])
|
pipeworks.add_node_box(outboxes, pipeworks.tube_boxes[v])
|
||||||
table.insert(outsel, pipeworks.tube_selectboxes[v])
|
table.insert(outsel, pipeworks.tube_selectboxes[v])
|
||||||
outimgs[vti[v]] = noctrs[v]
|
outimgs[vti[v]] = noctrs[v]
|
||||||
end
|
end
|
||||||
|
|
||||||
if #connects == 1 then
|
if #connects == 1 then
|
||||||
local v = stv[(connects[1]+3)%6+1]
|
local v = connects[1]
|
||||||
|
v = v-1 + 2*(v%2) -- Opposite side
|
||||||
outimgs[vti[v]] = ends[v]
|
outimgs[vti[v]] = ends[v]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -145,22 +144,22 @@ pipeworks.register_tube = function(name, desc, plain, noctrs, ends, short, inv,
|
||||||
for zp = 0, 1 do
|
for zp = 0, 1 do
|
||||||
local connects = {}
|
local connects = {}
|
||||||
if xm == 1 then
|
if xm == 1 then
|
||||||
connects[#connects+1] = 0
|
connects[#connects+1] = 1
|
||||||
end
|
end
|
||||||
if xp == 1 then
|
if xp == 1 then
|
||||||
connects[#connects+1] = 3
|
connects[#connects+1] = 2
|
||||||
end
|
end
|
||||||
if ym == 1 then
|
if ym == 1 then
|
||||||
connects[#connects+1] = 1
|
connects[#connects+1] = 3
|
||||||
end
|
end
|
||||||
if yp == 1 then
|
if yp == 1 then
|
||||||
connects[#connects+1] = 4
|
connects[#connects+1] = 4
|
||||||
end
|
end
|
||||||
if zm == 1 then
|
if zm == 1 then
|
||||||
connects[#connects+1] = 2
|
connects[#connects+1] = 5
|
||||||
end
|
end
|
||||||
if zp == 1 then
|
if zp == 1 then
|
||||||
connects[#connects+1] = 5
|
connects[#connects+1] = 6
|
||||||
end
|
end
|
||||||
local tname = xm..xp..ym..yp..zm..zp
|
local tname = xm..xp..ym..yp..zm..zp
|
||||||
register_one_tube(name, tname, "000000", desc, plain, noctrs, ends, short, inv, special, connects, "old")
|
register_one_tube(name, tname, "000000", desc, plain, noctrs, ends, short, inv, special, connects, "old")
|
||||||
|
@ -171,7 +170,7 @@ pipeworks.register_tube = function(name, desc, plain, noctrs, ends, short, inv,
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local cconnects = {{}, {0}, {0, 3}, {0, 1}, {0, 1, 2}, {0, 1, 3}, {0, 1, 2, 3}, {0, 1, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4, 5}}
|
local cconnects = {{}, {1}, {1, 2}, {1, 3}, {1, 3, 5}, {1, 2, 3}, {1, 2, 3, 5}, {1, 2, 3, 4}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6}}
|
||||||
for index, connects in ipairs(cconnects) do
|
for index, connects in ipairs(cconnects) do
|
||||||
register_one_tube(name, tostring(index), "1", desc, plain, noctrs, ends, short, inv, special, connects, "6d")
|
register_one_tube(name, tostring(index), "1", desc, plain, noctrs, ends, short, inv, special, connects, "6d")
|
||||||
end
|
end
|
||||||
|
@ -441,8 +440,17 @@ end
|
||||||
|
|
||||||
if pipeworks.enable_crossing_tube then
|
if pipeworks.enable_crossing_tube then
|
||||||
-- FIXME: The textures are not the correct ones
|
-- FIXME: The textures are not the correct ones
|
||||||
pipeworks.register_tube("pipeworks:crossing_tube", "Crossing tube segment", accelerator_plain_textures,
|
local crossing_noctr_textures = {"pipeworks_accelerator_tube_noctr.png", "pipeworks_accelerator_tube_noctr.png", "pipeworks_accelerator_tube_noctr.png",
|
||||||
accelerator_noctr_textures, accelerator_end_textures, accelerator_short_texture, accelerator_inv_texture,
|
"pipeworks_accelerator_tube_noctr.png", "pipeworks_accelerator_tube_noctr.png", "pipeworks_accelerator_tube_noctr.png"}
|
||||||
|
local crossing_plain_textures = {"pipeworks_accelerator_tube_plain.png" ,"pipeworks_accelerator_tube_plain.png", "pipeworks_accelerator_tube_plain.png",
|
||||||
|
"pipeworks_accelerator_tube_plain.png", "pipeworks_accelerator_tube_plain.png", "pipeworks_accelerator_tube_plain.png"}
|
||||||
|
local crossing_end_textures = {"pipeworks_accelerator_tube_end.png", "pipeworks_accelerator_tube_end.png", "pipeworks_accelerator_tube_end.png",
|
||||||
|
"pipeworks_accelerator_tube_end.png", "pipeworks_accelerator_tube_end.png", "pipeworks_accelerator_tube_end.png"}
|
||||||
|
local crossing_short_texture = "pipeworks_accelerator_tube_short.png"
|
||||||
|
local crossing_inv_texture = "pipeworks_accelerator_tube_inv.png"
|
||||||
|
|
||||||
|
pipeworks.register_tube("pipeworks:crossing_tube", "Crossing tube segment", crossing_plain_textures,
|
||||||
|
crossing_noctr_textures, crossing_end_textures, crossing_short_texture, crossing_inv_texture,
|
||||||
{tube = {can_go = function(pos, node, velocity, stack)
|
{tube = {can_go = function(pos, node, velocity, stack)
|
||||||
return {velocity}
|
return {velocity}
|
||||||
end}
|
end}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user