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 stv = {1, 3, 5, 2, 4, 6}
|
||||
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)
|
||||
|
@ -24,15 +23,15 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
|
|||
outimgs[vti[i]] = plain[i]
|
||||
end
|
||||
|
||||
for _, side in ipairs(connects) do
|
||||
local v = stv[side+1]
|
||||
for _, v in ipairs(connects) do
|
||||
pipeworks.add_node_box(outboxes, pipeworks.tube_boxes[v])
|
||||
table.insert(outsel, pipeworks.tube_selectboxes[v])
|
||||
outimgs[vti[v]] = noctrs[v]
|
||||
end
|
||||
|
||||
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]
|
||||
end
|
||||
|
||||
|
@ -145,22 +144,22 @@ pipeworks.register_tube = function(name, desc, plain, noctrs, ends, short, inv,
|
|||
for zp = 0, 1 do
|
||||
local connects = {}
|
||||
if xm == 1 then
|
||||
connects[#connects+1] = 0
|
||||
connects[#connects+1] = 1
|
||||
end
|
||||
if xp == 1 then
|
||||
connects[#connects+1] = 3
|
||||
connects[#connects+1] = 2
|
||||
end
|
||||
if ym == 1 then
|
||||
connects[#connects+1] = 1
|
||||
connects[#connects+1] = 3
|
||||
end
|
||||
if yp == 1 then
|
||||
connects[#connects+1] = 4
|
||||
end
|
||||
if zm == 1 then
|
||||
connects[#connects+1] = 2
|
||||
connects[#connects+1] = 5
|
||||
end
|
||||
if zp == 1 then
|
||||
connects[#connects+1] = 5
|
||||
connects[#connects+1] = 6
|
||||
end
|
||||
local tname = xm..xp..ym..yp..zm..zp
|
||||
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
|
||||
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
|
||||
register_one_tube(name, tostring(index), "1", desc, plain, noctrs, ends, short, inv, special, connects, "6d")
|
||||
end
|
||||
|
@ -441,8 +440,17 @@ end
|
|||
|
||||
if pipeworks.enable_crossing_tube then
|
||||
-- FIXME: The textures are not the correct ones
|
||||
pipeworks.register_tube("pipeworks:crossing_tube", "Crossing tube segment", accelerator_plain_textures,
|
||||
accelerator_noctr_textures, accelerator_end_textures, accelerator_short_texture, accelerator_inv_texture,
|
||||
local crossing_noctr_textures = {"pipeworks_accelerator_tube_noctr.png", "pipeworks_accelerator_tube_noctr.png", "pipeworks_accelerator_tube_noctr.png",
|
||||
"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)
|
||||
return {velocity}
|
||||
end}
|
||||
|
|
Loading…
Reference in New Issue
Block a user