summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoplace.lua52
-rw-r--r--changelog.txt3
-rw-r--r--init.lua17
-rw-r--r--textures/pipeworks_tube_end.pngbin0 -> 482 bytes
-rw-r--r--textures/pipeworks_tube_inv.pngbin0 -> 508 bytes
-rw-r--r--textures/pipeworks_tube_noctr.pngbin0 -> 385 bytes
-rw-r--r--textures/pipeworks_tube_plain.pngbin0 -> 399 bytes
-rw-r--r--textures/pipeworks_tube_short.pngbin0 -> 269 bytes
-rw-r--r--textures/pipeworks_tube_transparent.pngbin0 -> 109 bytes
-rw-r--r--tubes.lua198
10 files changed, 258 insertions, 12 deletions
diff --git a/autoplace.lua b/autoplace.lua
index 2f7c7f1..492f558 100644
--- a/autoplace.lua
+++ b/autoplace.lua
@@ -1,4 +1,6 @@
-pipe_scanforobjects = function(pos)
+-- autorouting for pipes
+
+function pipe_scanforobjects(pos)
pipe_autoroute({ x=pos.x-1, y=pos.y , z=pos.z }, "_loaded")
pipe_autoroute({ x=pos.x+1, y=pos.y , z=pos.z }, "_loaded")
pipe_autoroute({ x=pos.x , y=pos.y-1, z=pos.z }, "_loaded")
@@ -17,19 +19,59 @@ pipe_scanforobjects = function(pos)
end
function pipe_autoroute(pos, state)
-
nctr = minetest.env:get_node(pos)
if (string.find(nctr.name, "pipeworks:pipe_") == nil) then return end
pipes_scansurroundings(pos)
nsurround = pxm..pxp..pym..pyp..pzm..pzp
-
if nsurround == "000000" then nsurround = "110000" end
-
minetest.env:add_node(pos, { name = "pipeworks:pipe_"..nsurround..state })
end
+-- autorouting for pneumatic tubes
+
+function tube_scanforobjects(pos)
+ tube_autoroute({ x=pos.x-1, y=pos.y , z=pos.z })
+ tube_autoroute({ x=pos.x+1, y=pos.y , z=pos.z })
+ tube_autoroute({ x=pos.x , y=pos.y-1, z=pos.z })
+ tube_autoroute({ x=pos.x , y=pos.y+1, z=pos.z })
+ tube_autoroute({ x=pos.x , y=pos.y , z=pos.z-1 })
+ tube_autoroute({ x=pos.x , y=pos.y , z=pos.z+1 })
+ tube_autoroute(pos)
+end
+
+function tube_autoroute(pos)
+ nctr = minetest.env:get_node(pos)
+ if (string.find(nctr.name, "pipeworks:tube_") == nil) then return end
+
+ pxm=0
+ pxp=0
+ pym=0
+ pyp=0
+ pzm=0
+ pzp=0
+
+ nxm = minetest.env:get_node({ x=pos.x-1, y=pos.y , z=pos.z })
+ nxp = minetest.env:get_node({ x=pos.x+1, y=pos.y , z=pos.z })
+ nym = minetest.env:get_node({ x=pos.x , y=pos.y-1, z=pos.z })
+ nyp = minetest.env:get_node({ x=pos.x , y=pos.y+1, z=pos.z })
+ nzm = minetest.env:get_node({ x=pos.x , y=pos.y , z=pos.z-1 })
+ nzp = minetest.env:get_node({ x=pos.x , y=pos.y , z=pos.z+1 })
+
+ if (string.find(nxm.name, "pipeworks:tube_") ~= nil) then pxm=1 end
+ if (string.find(nxp.name, "pipeworks:tube_") ~= nil) then pxp=1 end
+ if (string.find(nym.name, "pipeworks:tube_") ~= nil) then pym=1 end
+ if (string.find(nyp.name, "pipeworks:tube_") ~= nil) then pyp=1 end
+ if (string.find(nzm.name, "pipeworks:tube_") ~= nil) then pzm=1 end
+ if (string.find(nzp.name, "pipeworks:tube_") ~= nil) then pzp=1 end
+
+ nsurround = pxm..pxp..pym..pyp..pzm..pzp
+ minetest.env:add_node(pos, { name = "pipeworks:tube_"..nsurround })
+end
+
+-- auto-rotation code for various devices the tubes attach to
+
function pipe_device_autorotate(pos, state, bname)
if state == nil then
@@ -53,7 +95,7 @@ function pipe_device_autorotate(pos, state, bname)
end
-pipes_scansurroundings = function(pos)
+function pipes_scansurroundings(pos)
pxm=0
pxp=0
pym=0
diff --git a/changelog.txt b/changelog.txt
index 8db2a4a..9e51430 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,6 +1,9 @@
Changelog
---------
+2012-08-24: Added square-ish pneumatic tubes, with their own autoplace code
+(they do not connect to the steel pipes or their related devices).
+
2012-08-22: Added outlet grate, made it participate in autoplace algorithm.
Extended storage tank to show fill level in 10% steps (0% to 100%). Added
"expansion tank" that appears if the user stacks tanks upwards. (Downwards is
diff --git a/init.lua b/init.lua
index fe5d353..a36fc16 100644
--- a/init.lua
+++ b/init.lua
@@ -1,13 +1,15 @@
-- Pipeworks mod by Vanessa Ezekowitz - 2012-08-05
--
--- Entirely my own code. This mod merely supplies enough nodes to build
--- a bunch of pipes in all directions and with all types of junctions
+-- Entirely my own code. This mod supplies various shapes of pipes
+-- and devices that they can connect to such as pumps, valves, etc.
+-- All pipes autoconnect as you lay them out, and devices will auto-
+-- connect to them.
--
-- License: WTFPL
--
--- comment-out the following dofile line to disnable the old pipe nodes.
-dofile(minetest.get_modpath("pipeworks").."/oldpipes.lua")
+-- Un-comment the following dofile line to re-enable the old pipe nodes.
+-- dofile(minetest.get_modpath("pipeworks").."/oldpipes.lua")
-- tables
@@ -116,7 +118,7 @@ dbg = function(s)
end
end
-function fix_newpipe_names(table, replacement)
+function pipes_fix_image_names(table, replacement)
outtable={}
for i in ipairs(table) do
outtable[i]=string.gsub(table[i], "_XXXXX", replacement)
@@ -249,7 +251,7 @@ for zp = 0, 1 do
minetest.register_node("pipeworks:pipe_"..pname.."_empty", {
description = pipedesc,
drawtype = "nodebox",
- tiles = fix_newpipe_names(outimgs, "_empty"),
+ tiles = pipes_fix_image_names(outimgs, "_empty"),
paramtype = "light",
selection_box = {
type = "fixed",
@@ -280,7 +282,7 @@ for zp = 0, 1 do
minetest.register_node("pipeworks:pipe_"..pname.."_loaded", {
description = "Pipe segment (loaded, "..pname..")... You hacker, you.",
drawtype = "nodebox",
- tiles = fix_newpipe_names(outimgs, "_loaded"),
+ tiles = pipes_fix_image_names(outimgs, "_loaded"),
paramtype = "light",
selection_box = {
type = "fixed",
@@ -314,6 +316,7 @@ end
end
end
+dofile(minetest.get_modpath("pipeworks").."/tubes.lua")
dofile(minetest.get_modpath("pipeworks").."/devices.lua")
dofile(minetest.get_modpath("pipeworks").."/autoplace.lua")
diff --git a/textures/pipeworks_tube_end.png b/textures/pipeworks_tube_end.png
new file mode 100644
index 0000000..e35edb3
--- /dev/null
+++ b/textures/pipeworks_tube_end.png
Binary files differ
diff --git a/textures/pipeworks_tube_inv.png b/textures/pipeworks_tube_inv.png
new file mode 100644
index 0000000..93c51b1
--- /dev/null
+++ b/textures/pipeworks_tube_inv.png
Binary files differ
diff --git a/textures/pipeworks_tube_noctr.png b/textures/pipeworks_tube_noctr.png
new file mode 100644
index 0000000..5add4cf
--- /dev/null
+++ b/textures/pipeworks_tube_noctr.png
Binary files differ
diff --git a/textures/pipeworks_tube_plain.png b/textures/pipeworks_tube_plain.png
new file mode 100644
index 0000000..2d9c8d8
--- /dev/null
+++ b/textures/pipeworks_tube_plain.png
Binary files differ
diff --git a/textures/pipeworks_tube_short.png b/textures/pipeworks_tube_short.png
new file mode 100644
index 0000000..ba69c08
--- /dev/null
+++ b/textures/pipeworks_tube_short.png
Binary files differ
diff --git a/textures/pipeworks_tube_transparent.png b/textures/pipeworks_tube_transparent.png
new file mode 100644
index 0000000..4b4ee1f
--- /dev/null
+++ b/textures/pipeworks_tube_transparent.png
Binary files differ
diff --git a/tubes.lua b/tubes.lua
new file mode 100644
index 0000000..fb606a0
--- /dev/null
+++ b/tubes.lua
@@ -0,0 +1,198 @@
+-- This file supplies pneumatic tubes.
+
+-- tables
+
+minetest.register_alias("pipeworks:tube", "pipeworks:tube_000000")
+
+tube_leftstub = {
+ { -32/64, -9/64, -9/64, 9/64, 9/64, 9/64 }, -- tube segment against -X face
+}
+
+tube_rightstub = {
+ { -9/64, -9/64, -9/64, 32/64, 9/64, 9/64 }, -- tube segment against +X face
+}
+
+tube_bottomstub = {
+ { -9/64, -32/64, -9/64, 9/64, 9/64, 9/64 }, -- tube segment against -Y face
+}
+
+
+tube_topstub = {
+ { -9/64, -9/64, -9/64, 9/64, 32/64, 9/64 }, -- tube segment against +Y face
+}
+
+tube_frontstub = {
+ { -9/64, -9/64, -32/64, 9/64, 9/64, 9/64 }, -- tube segment against -Z face
+}
+
+tube_backstub = {
+ { -9/64, -9/64, -9/64, 9/64, 9/64, 32/64 }, -- tube segment against -Z face
+}
+
+tube_selectboxes = {
+ { -32/64, -10/64, -10/64, 10/64, 10/64, 10/64 },
+ { -10/64 , -10/64, -10/64, 32/64, 10/64, 10/64 },
+ { -10/64 , -32/64, -10/64, 10/64, 10/64, 10/64 },
+ { -10/64 , -10/64, -10/64, 10/64, 32/64, 10/64 },
+ { -10/64 , -10/64, -32/64, 10/64, 10/64, 10/64 },
+ { -10/64 , -10/64, -10/64, 10/64, 10/64, 32/64 }
+}
+
+-- Functions
+
+function tube_addbox(t, b)
+ for i in ipairs(b)
+ do table.insert(t, b[i])
+ end
+end
+
+-- now define the nodes!
+
+for xm = 0, 1 do
+for xp = 0, 1 do
+for ym = 0, 1 do
+for yp = 0, 1 do
+for zm = 0, 1 do
+for zp = 0, 1 do
+ local outboxes = {}
+ local outsel = {}
+ local outimgs = {}
+
+ if yp==1 then
+ tube_addbox(outboxes, tube_topstub)
+ table.insert(outsel, tube_selectboxes[4])
+ table.insert(outimgs, "pipeworks_tube_noctr.png")
+ else
+ table.insert(outimgs, "pipeworks_tube_plain.png")
+ end
+ if ym==1 then
+ tube_addbox(outboxes, tube_bottomstub)
+ table.insert(outsel, tube_selectboxes[3])
+ table.insert(outimgs, "pipeworks_tube_noctr.png")
+ else
+ table.insert(outimgs, "pipeworks_tube_plain.png")
+ end
+ if xp==1 then
+ tube_addbox(outboxes, tube_rightstub)
+ table.insert(outsel, tube_selectboxes[2])
+ table.insert(outimgs, "pipeworks_tube_noctr.png")
+ else
+ table.insert(outimgs, "pipeworks_tube_plain.png")
+ end
+ if xm==1 then
+ tube_addbox(outboxes, tube_leftstub)
+ table.insert(outsel, tube_selectboxes[1])
+ table.insert(outimgs, "pipeworks_tube_noctr.png")
+ else
+ table.insert(outimgs, "pipeworks_tube_plain.png")
+ end
+ if zp==1 then
+ tube_addbox(outboxes, tube_backstub)
+ table.insert(outsel, tube_selectboxes[6])
+ table.insert(outimgs, "pipeworks_tube_noctr.png")
+ else
+ table.insert(outimgs, "pipeworks_tube_plain.png")
+ end
+ if zm==1 then
+ tube_addbox(outboxes, tube_frontstub)
+ table.insert(outsel, tube_selectboxes[5])
+ table.insert(outimgs, "pipeworks_tube_noctr.png")
+ else
+ table.insert(outimgs, "pipeworks_tube_plain.png")
+ end
+
+ local jx = xp+xm
+ local jy = yp+ym
+ local jz = zp+zm
+
+ if (jx+jy+jz) == 1 then
+ if xm == 1 then
+ table.remove(outimgs, 3)
+ table.insert(outimgs, 3, "pipeworks_tube_end.png")
+ end
+ if xp == 1 then
+ table.remove(outimgs, 4)
+ table.insert(outimgs, 4, "pipeworks_tube_end.png")
+ end
+ if ym == 1 then
+ table.remove(outimgs, 1)
+ table.insert(outimgs, 1, "pipeworks_tube_end.png")
+ end
+ if xp == 1 then
+ table.remove(outimgs, 2)
+ table.insert(outimgs, 2, "pipeworks_tube_end.png")
+ end
+ if zm == 1 then
+ table.remove(outimgs, 5)
+ table.insert(outimgs, 5, "pipeworks_tube_end.png")
+ end
+ if zp == 1 then
+ table.remove(outimgs, 6)
+ table.insert(outimgs, 6, "pipeworks_tube_end.png")
+ end
+ end
+
+ local tname = xm..xp..ym..yp..zm..zp
+ local tgroups = ""
+
+ if tname ~= "000000" then
+ tgroups = {snappy=3, tube=1, not_in_creative_inventory=1}
+ tubedesc = "Pneumatic tube segment ("..tname..")... You hacker, you."
+ iimg=nil
+ else
+ tgroups = {snappy=3, tube=1}
+ tubedesc = "Pneumatic tube segment"
+ iimg="pipeworks_tube_inv.png"
+ outimgs = {
+ "pipeworks_tube_short.png",
+ "pipeworks_tube_short.png",
+ "pipeworks_tube_end.png",
+ "pipeworks_tube_end.png",
+ "pipeworks_tube_short.png",
+ "pipeworks_tube_short.png"
+ }
+ outboxes = { -24/64, -9/64, -9/64, 24/64, 9/64, 9/64 }
+ outsel = { -24/64, -10/64, -10/64, 24/64, 10/64, 10/64 }
+ end
+
+ minetest.register_node("pipeworks:tube_"..tname, {
+ description = tubedesc,
+ drawtype = "nodebox",
+ tiles = outimgs,
+ inventory_image=iimg,
+ wield_image=iimg,
+ paramtype = "light",
+ selection_box = {
+ type = "fixed",
+ fixed = outsel
+ },
+ node_box = {
+ type = "fixed",
+ fixed = outboxes
+ },
+ groups = tgroups,
+ sounds = default.node_sound_wood_defaults(),
+ walkable = true,
+ stack_max = 99,
+ drop = "pipeworks:tube_000000",
+ tubelike=1,
+ on_construct = function(pos)
+ local meta = minetest.env:get_meta(pos)
+ meta:set_int("tubelike",1)
+ end,
+ after_place_node = function(pos)
+ tube_scanforobjects(pos)
+ end,
+ after_dig_node = function(pos)
+ tube_scanforobjects(pos)
+ end
+ })
+
+end
+end
+end
+end
+end
+end
+
+print("pipeworks loaded!")