summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autocrafter.lua11
-rw-r--r--routing_tubes.lua18
-rw-r--r--signal_tubes.lua21
-rw-r--r--sorting_tubes.lua3
-rw-r--r--teleport_tube.lua9
-rw-r--r--tube_registration.lua22
-rw-r--r--vacuum_tubes.lua18
7 files changed, 41 insertions, 61 deletions
diff --git a/autocrafter.lua b/autocrafter.lua
index 89559ba..d3a4ccd 100644
--- a/autocrafter.lua
+++ b/autocrafter.lua
@@ -153,15 +153,8 @@ local function on_output_change(pos, inventory, stack)
if not input.items or input.type ~= "normal" then return end
local items, width = normalize(input.items), input.width
local item_idx, width_idx = 1, 1
- for i = 1, 9 do
- if width_idx <= width then
- inventory:set_stack("recipe", i, items[item_idx])
- item_idx = item_idx + 1
- else
- inventory:set_stack("recipe", i, ItemStack(""))
- end
- width_idx = (width_idx < 3) and (width_idx + 1) or 1
- end
+ inventory:set_width("recipe", 3)
+ inventory:set_list("recipe", items)
-- we'll set the output slot in after_recipe_change to the actual result of the new recipe
end
after_recipe_change(pos, inventory)
diff --git a/routing_tubes.lua b/routing_tubes.lua
index ebd451f..2610119 100644
--- a/routing_tubes.lua
+++ b/routing_tubes.lua
@@ -10,12 +10,9 @@ minetest.register_craft( {
})
if pipeworks.enable_accelerator_tube then
- local accelerator_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 accelerator_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 accelerator_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 accelerator_noctr_textures = { "pipeworks_accelerator_tube_noctr.png" }
+ local accelerator_plain_textures = { "pipeworks_accelerator_tube_plain.png" }
+ local accelerator_end_textures = { "pipeworks_accelerator_tube_end.png" }
local accelerator_short_texture = "pipeworks_accelerator_tube_short.png"
local accelerator_inv_texture = "pipeworks_accelerator_tube_inv.png"
@@ -39,12 +36,9 @@ if pipeworks.enable_accelerator_tube then
end
if pipeworks.enable_crossing_tube then
- local crossing_noctr_textures = {"pipeworks_crossing_tube_noctr.png", "pipeworks_crossing_tube_noctr.png", "pipeworks_crossing_tube_noctr.png",
- "pipeworks_crossing_tube_noctr.png", "pipeworks_crossing_tube_noctr.png", "pipeworks_crossing_tube_noctr.png"}
- local crossing_plain_textures = {"pipeworks_crossing_tube_plain.png" ,"pipeworks_crossing_tube_plain.png", "pipeworks_crossing_tube_plain.png",
- "pipeworks_crossing_tube_plain.png", "pipeworks_crossing_tube_plain.png", "pipeworks_crossing_tube_plain.png"}
- local crossing_end_textures = {"pipeworks_crossing_tube_end.png", "pipeworks_crossing_tube_end.png", "pipeworks_crossing_tube_end.png",
- "pipeworks_crossing_tube_end.png", "pipeworks_crossing_tube_end.png", "pipeworks_crossing_tube_end.png"}
+ local crossing_noctr_textures = { "pipeworks_crossing_tube_noctr.png" }
+ local crossing_plain_textures = { "pipeworks_crossing_tube_plain.png" }
+ local crossing_end_textures = { "pipeworks_crossing_tube_end.png" }
local crossing_short_texture = "pipeworks_crossing_tube_short.png"
local crossing_inv_texture = "pipeworks_crossing_tube_inv.png"
diff --git a/signal_tubes.lua b/signal_tubes.lua
index 44605c8..75a1159 100644
--- a/signal_tubes.lua
+++ b/signal_tubes.lua
@@ -1,6 +1,5 @@
if pipeworks.enable_detector_tube then
- local detector_plain_textures = {"pipeworks_detector_tube_plain.png", "pipeworks_detector_tube_plain.png", "pipeworks_detector_tube_plain.png",
- "pipeworks_detector_tube_plain.png", "pipeworks_detector_tube_plain.png", "pipeworks_detector_tube_plain.png"}
+ local detector_plain_textures = { "pipeworks_detector_tube_plain.png" }
local detector_inv_texture = "pipeworks_detector_tube_inv.png"
local detector_tube_step = 2 * tonumber(minetest.setting_get("dedicated_server_step"))
pipeworks.register_tube("pipeworks:detector_tube_on", "Detecting Pneumatic Tube Segment on (you hacker you)",
@@ -65,21 +64,15 @@ if pipeworks.enable_detector_tube then
end
if pipeworks.enable_conductor_tube then
- local conductor_plain_textures = {"pipeworks_conductor_tube_plain.png", "pipeworks_conductor_tube_plain.png", "pipeworks_conductor_tube_plain.png",
- "pipeworks_conductor_tube_plain.png", "pipeworks_conductor_tube_plain.png", "pipeworks_conductor_tube_plain.png"}
- local conductor_noctr_textures = {"pipeworks_conductor_tube_noctr.png", "pipeworks_conductor_tube_noctr.png", "pipeworks_conductor_tube_noctr.png",
- "pipeworks_conductor_tube_noctr.png", "pipeworks_conductor_tube_noctr.png", "pipeworks_conductor_tube_noctr.png"}
- local conductor_end_textures = {"pipeworks_conductor_tube_end.png", "pipeworks_conductor_tube_end.png", "pipeworks_conductor_tube_end.png",
- "pipeworks_conductor_tube_end.png", "pipeworks_conductor_tube_end.png", "pipeworks_conductor_tube_end.png"}
+ local conductor_plain_textures = { "pipeworks_conductor_tube_plain.png" }
+ local conductor_noctr_textures = { "pipeworks_conductor_tube_noctr.png" }
+ local conductor_end_textures = { "pipeworks_conductor_tube_end.png" }
local conductor_short_texture = "pipeworks_conductor_tube_short.png"
local conductor_inv_texture = "pipeworks_conductor_tube_inv.png"
- local conductor_on_plain_textures = {"pipeworks_conductor_tube_on_plain.png", "pipeworks_conductor_tube_on_plain.png", "pipeworks_conductor_tube_on_plain.png",
- "pipeworks_conductor_tube_on_plain.png", "pipeworks_conductor_tube_on_plain.png", "pipeworks_conductor_tube_on_plain.png"}
- local conductor_on_noctr_textures = {"pipeworks_conductor_tube_on_noctr.png", "pipeworks_conductor_tube_on_noctr.png", "pipeworks_conductor_tube_on_noctr.png",
- "pipeworks_conductor_tube_on_noctr.png", "pipeworks_conductor_tube_on_noctr.png", "pipeworks_conductor_tube_on_noctr.png"}
- local conductor_on_end_textures = {"pipeworks_conductor_tube_on_end.png", "pipeworks_conductor_tube_on_end.png", "pipeworks_conductor_tube_on_end.png",
- "pipeworks_conductor_tube_on_end.png", "pipeworks_conductor_tube_on_end.png", "pipeworks_conductor_tube_on_end.png"}
+ local conductor_on_plain_textures = { "pipeworks_conductor_tube_on_plain.png" }
+ local conductor_on_noctr_textures = { "pipeworks_conductor_tube_on_noctr.png" }
+ local conductor_on_end_textures = { "pipeworks_conductor_tube_on_end.png" }
pipeworks.register_tube("pipeworks:conductor_tube_off", "Conducting Pneumatic Tube Segment", conductor_plain_textures, conductor_noctr_textures,
conductor_end_textures, conductor_short_texture, conductor_inv_texture,
diff --git a/sorting_tubes.lua b/sorting_tubes.lua
index 93859d4..2060455 100644
--- a/sorting_tubes.lua
+++ b/sorting_tubes.lua
@@ -3,8 +3,7 @@ if pipeworks.enable_mese_tube then
"pipeworks_mese_tube_noctr_4.png", "pipeworks_mese_tube_noctr_5.png", "pipeworks_mese_tube_noctr_6.png"}
local mese_plain_textures = {"pipeworks_mese_tube_plain_1.png", "pipeworks_mese_tube_plain_2.png", "pipeworks_mese_tube_plain_3.png",
"pipeworks_mese_tube_plain_4.png", "pipeworks_mese_tube_plain_5.png", "pipeworks_mese_tube_plain_6.png"}
- local mese_end_textures = {"pipeworks_mese_tube_end.png", "pipeworks_mese_tube_end.png", "pipeworks_mese_tube_end.png",
- "pipeworks_mese_tube_end.png", "pipeworks_mese_tube_end.png", "pipeworks_mese_tube_end.png"}
+ local mese_end_textures = { "pipeworks_mese_tube_end.png" }
local mese_short_texture = "pipeworks_mese_tube_short.png"
local mese_inv_texture = "pipeworks_mese_tube_inv.png"
local function update_formspec(pos)
diff --git a/teleport_tube.lua b/teleport_tube.lua
index ccc5e0f..55c9b7f 100644
--- a/teleport_tube.lua
+++ b/teleport_tube.lua
@@ -105,12 +105,9 @@ local function get_receivers(pos, channel)
return receivers
end
-local teleport_noctr_textures={"pipeworks_teleport_tube_noctr.png","pipeworks_teleport_tube_noctr.png","pipeworks_teleport_tube_noctr.png",
- "pipeworks_teleport_tube_noctr.png","pipeworks_teleport_tube_noctr.png","pipeworks_teleport_tube_noctr.png"}
-local teleport_plain_textures={"pipeworks_teleport_tube_plain.png","pipeworks_teleport_tube_plain.png","pipeworks_teleport_tube_plain.png",
- "pipeworks_teleport_tube_plain.png","pipeworks_teleport_tube_plain.png","pipeworks_teleport_tube_plain.png"}
-local teleport_end_textures={"pipeworks_teleport_tube_end.png","pipeworks_teleport_tube_end.png","pipeworks_teleport_tube_end.png",
- "pipeworks_teleport_tube_end.png","pipeworks_teleport_tube_end.png","pipeworks_teleport_tube_end.png"}
+local teleport_noctr_textures={ "pipeworks_teleport_tube_noctr.png" }
+local teleport_plain_textures={ "pipeworks_teleport_tube_plain.png" }
+local teleport_end_textures={ "pipeworks_teleport_tube_end.png" }
local teleport_short_texture="pipeworks_teleport_tube_short.png"
local teleport_inv_texture="pipeworks_teleport_tube_inv.png"
diff --git a/tube_registration.lua b/tube_registration.lua
index 6ef4fee..4f387d8 100644
--- a/tube_registration.lua
+++ b/tube_registration.lua
@@ -11,20 +11,30 @@ local REGISTER_COMPATIBILITY = true
local vti = {4, 3, 2, 1, 6, 5}
local default_textures = {
- noctrs = { "pipeworks_tube_noctr.png", "pipeworks_tube_noctr.png", "pipeworks_tube_noctr.png",
- "pipeworks_tube_noctr.png", "pipeworks_tube_noctr.png", "pipeworks_tube_noctr.png"},
- plain = { "pipeworks_tube_plain.png", "pipeworks_tube_plain.png", "pipeworks_tube_plain.png",
- "pipeworks_tube_plain.png", "pipeworks_tube_plain.png", "pipeworks_tube_plain.png"},
- ends = { "pipeworks_tube_end.png", "pipeworks_tube_end.png", "pipeworks_tube_end.png",
- "pipeworks_tube_end.png", "pipeworks_tube_end.png", "pipeworks_tube_end.png"},
+ noctrs = { "pipeworks_tube_noctr.png" },
+ plain = { "pipeworks_tube_plain.png" },
+ ends = { "pipeworks_tube_end.png" },
short = "pipeworks_tube_short.png",
inv = "pipeworks_tube_inv.png",
}
+local texture_mt = {
+ __index = function(table, key)
+ local size, idx = #table, tonumber(key)
+ if size > 0 then -- avoid endless loops with empty tables
+ while idx > size do idx = idx - size end
+ return table[idx]
+ end
+ end
+}
+
local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, ends, short, inv, special, connects, style)
noctrs = noctrs or default_textures.noctrs
+ setmetatable(noctrs, texture_mt)
plain = plain or default_textures.plain
+ setmetatable(plain, texture_mt)
ends = ends or default_textures.ends
+ setmetatable(ends, texture_mt)
short = short or default_textures.short
inv = inv or default_textures.inv
diff --git a/vacuum_tubes.lua b/vacuum_tubes.lua
index 680e418..2e6dc81 100644
--- a/vacuum_tubes.lua
+++ b/vacuum_tubes.lua
@@ -1,10 +1,7 @@
if pipeworks.enable_sand_tube then
- local sand_noctr_textures = {"pipeworks_sand_tube_noctr.png", "pipeworks_sand_tube_noctr.png", "pipeworks_sand_tube_noctr.png",
- "pipeworks_sand_tube_noctr.png", "pipeworks_sand_tube_noctr.png", "pipeworks_sand_tube_noctr.png"}
- local sand_plain_textures = {"pipeworks_sand_tube_plain.png", "pipeworks_sand_tube_plain.png", "pipeworks_sand_tube_plain.png",
- "pipeworks_sand_tube_plain.png", "pipeworks_sand_tube_plain.png", "pipeworks_sand_tube_plain.png"}
- local sand_end_textures = {"pipeworks_sand_tube_end.png", "pipeworks_sand_tube_end.png", "pipeworks_sand_tube_end.png",
- "pipeworks_sand_tube_end.png", "pipeworks_sand_tube_end.png", "pipeworks_sand_tube_end.png"}
+ local sand_noctr_textures = { "pipeworks_sand_tube_noctr.png" }
+ local sand_plain_textures = { "pipeworks_sand_tube_plain.png" }
+ local sand_end_textures = { "pipeworks_sand_tube_end.png" }
local sand_short_texture = "pipeworks_sand_tube_short.png"
local sand_inv_texture = "pipeworks_sand_tube_inv.png"
@@ -39,12 +36,9 @@ if pipeworks.enable_sand_tube then
end
if pipeworks.enable_mese_sand_tube then
- local mese_sand_noctr_textures = {"pipeworks_mese_sand_tube_noctr.png", "pipeworks_mese_sand_tube_noctr.png", "pipeworks_mese_sand_tube_noctr.png",
- "pipeworks_mese_sand_tube_noctr.png", "pipeworks_mese_sand_tube_noctr.png", "pipeworks_mese_sand_tube_noctr.png"}
- local mese_sand_plain_textures = {"pipeworks_mese_sand_tube_plain.png", "pipeworks_mese_sand_tube_plain.png", "pipeworks_mese_sand_tube_plain.png",
- "pipeworks_mese_sand_tube_plain.png", "pipeworks_mese_sand_tube_plain.png", "pipeworks_mese_sand_tube_plain.png"}
- local mese_sand_end_textures = {"pipeworks_mese_sand_tube_end.png", "pipeworks_mese_sand_tube_end.png", "pipeworks_mese_sand_tube_end.png",
- "pipeworks_mese_sand_tube_end.png", "pipeworks_mese_sand_tube_end.png", "pipeworks_mese_sand_tube_end.png"}
+ local mese_sand_noctr_textures = { "pipeworks_mese_sand_tube_noctr.png" }
+ local mese_sand_plain_textures = { "pipeworks_mese_sand_tube_plain.png" }
+ local mese_sand_end_textures = { "pipeworks_mese_sand_tube_end.png" }
local mese_sand_short_texture = "pipeworks_mese_sand_tube_short.png"
local mese_sand_inv_texture = "pipeworks_mese_sand_tube_inv.png"