summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoplace.lua29
-rw-r--r--compat.lua8
-rw-r--r--item_transport.lua9
-rw-r--r--textures/black.pngbin0 -> 150 bytes
-rw-r--r--textures/blue.pngbin0 -> 160 bytes
-rw-r--r--textures/green.pngbin0 -> 160 bytes
-rw-r--r--textures/pipeworks_mese_tube_end.pngbin0 -> 2532 bytes
-rw-r--r--textures/pipeworks_mese_tube_inv.pngbin0 -> 1212 bytes
-rw-r--r--textures/pipeworks_mese_tube_noctr_1.pngbin0 -> 2063 bytes
-rw-r--r--textures/pipeworks_mese_tube_noctr_2.pngbin0 -> 2011 bytes
-rw-r--r--textures/pipeworks_mese_tube_noctr_3.pngbin0 -> 2055 bytes
-rw-r--r--textures/pipeworks_mese_tube_noctr_4.pngbin0 -> 2056 bytes
-rw-r--r--textures/pipeworks_mese_tube_noctr_5.pngbin0 -> 2059 bytes
-rw-r--r--textures/pipeworks_mese_tube_noctr_6.pngbin0 -> 2056 bytes
-rw-r--r--textures/pipeworks_mese_tube_plain_1.pngbin0 -> 2464 bytes
-rw-r--r--textures/pipeworks_mese_tube_plain_2.pngbin0 -> 2468 bytes
-rw-r--r--textures/pipeworks_mese_tube_plain_3.pngbin0 -> 2501 bytes
-rw-r--r--textures/pipeworks_mese_tube_plain_4.pngbin0 -> 2484 bytes
-rw-r--r--textures/pipeworks_mese_tube_plain_5.pngbin0 -> 2497 bytes
-rw-r--r--textures/pipeworks_mese_tube_plain_6.pngbin0 -> 2499 bytes
-rw-r--r--textures/pipeworks_mese_tube_short.pngbin0 -> 1209 bytes
-rw-r--r--textures/red.pngbin0 -> 160 bytes
-rw-r--r--textures/white.pngbin0 -> 160 bytes
-rw-r--r--textures/yellow.pngbin0 -> 160 bytes
-rw-r--r--tubes.lua166
25 files changed, 163 insertions, 49 deletions
diff --git a/autoplace.lua b/autoplace.lua
index 6ff5b90..2b297f2 100644
--- a/autoplace.lua
+++ b/autoplace.lua
@@ -41,10 +41,21 @@ function tube_scanforobjects(pos)
tube_autoroute(pos)
end
+function in_table(table,element)
+ for _,el in ipairs(table) do
+ if el==element then return true end
+ end
+ return false
+end
+
+function is_tube(nodename)
+ return in_table(tubenodes,nodename)
+end
+
function tube_autoroute(pos)
nctr = minetest.env:get_node(pos)
print ("minetest.get_item_group("..nctr.name..',"tubedevice") == '..minetest.get_item_group(nctr.name, "tubedevice"))
- if (string.find(nctr.name, "pipeworks:tube_") == nil)
+ if (is_tube(nctr.name) == nil)
and minetest.get_item_group(nctr.name, "tubedevice") ~= 1 then return end
pxm=0
@@ -61,22 +72,22 @@ function tube_autoroute(pos)
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)
+ if is_tube(nxm.name)
or minetest.get_item_group(nxm.name, "tubedevice") == 1 then pxm=1 end
- if (string.find(nxp.name, "pipeworks:tube_") ~= nil)
+ if is_tube(nxp.name)
or minetest.get_item_group(nxp.name, "tubedevice") == 1 then pxp=1 end
- if (string.find(nym.name, "pipeworks:tube_") ~= nil)
+ if is_tube(nym.name)
or minetest.get_item_group(nym.name, "tubedevice") == 1 then pym=1 end
- if (string.find(nyp.name, "pipeworks:tube_") ~= nil)
+ if is_tube(nyp.name)
or minetest.get_item_group(nyp.name, "tubedevice") == 1 then pyp=1 end
- if (string.find(nzm.name, "pipeworks:tube_") ~= nil)
+ if is_tube(nzm.name)
or minetest.get_item_group(nzm.name, "tubedevice") == 1 then pzm=1 end
- if (string.find(nzp.name, "pipeworks:tube_") ~= nil)
+ if is_tube(nzp.name)
or minetest.get_item_group(nzp.name, "tubedevice") == 1 then pzp=1 end
nsurround = pxm..pxp..pym..pyp..pzm..pzp
- if minetest.get_item_group(nctr.name, "tubedevice") ~= 1 then
- minetest.env:add_node(pos, { name = "pipeworks:tube_"..nsurround })
+ if is_tube(nctr.name) then
+ minetest.env:add_node(pos, { name = string.sub(nctr.name,1,-7)..nsurround })
end
end
diff --git a/compat.lua b/compat.lua
index 31e59a2..40ed4a1 100644
--- a/compat.lua
+++ b/compat.lua
@@ -18,10 +18,8 @@ minetest.register_node(":default:furnace", {
local inv=meta:get_inventory()
if direction.y==1 then
return inv:add_item("fuel",stack)
- elseif direction.y==-1 then
- return inv:add_item("src",stack)
else
- return stack
+ return inv:add_item("src",stack)
end
end,
can_insert=function(pos,node,stack,direction)
@@ -74,10 +72,8 @@ minetest.register_node(":default:furnace_active", {
local inv=meta:get_inventory()
if direction.y==1 then
return inv:add_item("fuel",stack)
- elseif direction.y==-1 then
- return inv:add_item("src",stack)
else
- return stack
+ return inv:add_item("src",stack)
end
end,
can_insert=function(pos,node,stack,direction)
diff --git a/item_transport.lua b/item_transport.lua
index 9f7f726..db057aa 100644
--- a/item_transport.lua
+++ b/item_transport.lua
@@ -269,6 +269,7 @@ function go_next(pos,velocity,stack)
--print(dump(pos))
local chests={}
local tubes={}
+ local cnode=minetest.env:get_node(pos)
local cmeta=minetest.env:get_meta(pos)
local node
local meta
@@ -276,7 +277,13 @@ function go_next(pos,velocity,stack)
local tube_receiver
local len=1
local n
- for _,vect in ipairs(adjlist) do
+ local can_go
+ if minetest.registered_nodes[cnode.name].tube and minetest.registered_nodes[cnode.name].tube.can_go then
+ can_go=minetest.registered_nodes[cnode.name].tube.can_go(pos,node,velocity,stack)
+ else
+ can_go=adjlist
+ end
+ for _,vect in ipairs(can_go) do
if vect.x~=-velocity.x or vect.y~=-velocity.y or vect.z~=-velocity.z then
npos=addVect(pos,vect)
node=minetest.env:get_node(npos)
diff --git a/textures/black.png b/textures/black.png
new file mode 100644
index 0000000..9e58d8c
--- /dev/null
+++ b/textures/black.png
Binary files differ
diff --git a/textures/blue.png b/textures/blue.png
new file mode 100644
index 0000000..aa346d4
--- /dev/null
+++ b/textures/blue.png
Binary files differ
diff --git a/textures/green.png b/textures/green.png
new file mode 100644
index 0000000..452aff0
--- /dev/null
+++ b/textures/green.png
Binary files differ
diff --git a/textures/pipeworks_mese_tube_end.png b/textures/pipeworks_mese_tube_end.png
new file mode 100644
index 0000000..c3b86a2
--- /dev/null
+++ b/textures/pipeworks_mese_tube_end.png
Binary files differ
diff --git a/textures/pipeworks_mese_tube_inv.png b/textures/pipeworks_mese_tube_inv.png
new file mode 100644
index 0000000..b952287
--- /dev/null
+++ b/textures/pipeworks_mese_tube_inv.png
Binary files differ
diff --git a/textures/pipeworks_mese_tube_noctr_1.png b/textures/pipeworks_mese_tube_noctr_1.png
new file mode 100644
index 0000000..85c27d7
--- /dev/null
+++ b/textures/pipeworks_mese_tube_noctr_1.png
Binary files differ
diff --git a/textures/pipeworks_mese_tube_noctr_2.png b/textures/pipeworks_mese_tube_noctr_2.png
new file mode 100644
index 0000000..c73b2d9
--- /dev/null
+++ b/textures/pipeworks_mese_tube_noctr_2.png
Binary files differ
diff --git a/textures/pipeworks_mese_tube_noctr_3.png b/textures/pipeworks_mese_tube_noctr_3.png
new file mode 100644
index 0000000..758560c
--- /dev/null
+++ b/textures/pipeworks_mese_tube_noctr_3.png
Binary files differ
diff --git a/textures/pipeworks_mese_tube_noctr_4.png b/textures/pipeworks_mese_tube_noctr_4.png
new file mode 100644
index 0000000..a429466
--- /dev/null
+++ b/textures/pipeworks_mese_tube_noctr_4.png
Binary files differ
diff --git a/textures/pipeworks_mese_tube_noctr_5.png b/textures/pipeworks_mese_tube_noctr_5.png
new file mode 100644
index 0000000..1d6a4b9
--- /dev/null
+++ b/textures/pipeworks_mese_tube_noctr_5.png
Binary files differ
diff --git a/textures/pipeworks_mese_tube_noctr_6.png b/textures/pipeworks_mese_tube_noctr_6.png
new file mode 100644
index 0000000..e352d37
--- /dev/null
+++ b/textures/pipeworks_mese_tube_noctr_6.png
Binary files differ
diff --git a/textures/pipeworks_mese_tube_plain_1.png b/textures/pipeworks_mese_tube_plain_1.png
new file mode 100644
index 0000000..95a2c8a
--- /dev/null
+++ b/textures/pipeworks_mese_tube_plain_1.png
Binary files differ
diff --git a/textures/pipeworks_mese_tube_plain_2.png b/textures/pipeworks_mese_tube_plain_2.png
new file mode 100644
index 0000000..f59031b
--- /dev/null
+++ b/textures/pipeworks_mese_tube_plain_2.png
Binary files differ
diff --git a/textures/pipeworks_mese_tube_plain_3.png b/textures/pipeworks_mese_tube_plain_3.png
new file mode 100644
index 0000000..f315ea2
--- /dev/null
+++ b/textures/pipeworks_mese_tube_plain_3.png
Binary files differ
diff --git a/textures/pipeworks_mese_tube_plain_4.png b/textures/pipeworks_mese_tube_plain_4.png
new file mode 100644
index 0000000..9665f78
--- /dev/null
+++ b/textures/pipeworks_mese_tube_plain_4.png
Binary files differ
diff --git a/textures/pipeworks_mese_tube_plain_5.png b/textures/pipeworks_mese_tube_plain_5.png
new file mode 100644
index 0000000..885300b
--- /dev/null
+++ b/textures/pipeworks_mese_tube_plain_5.png
Binary files differ
diff --git a/textures/pipeworks_mese_tube_plain_6.png b/textures/pipeworks_mese_tube_plain_6.png
new file mode 100644
index 0000000..3d13ef9
--- /dev/null
+++ b/textures/pipeworks_mese_tube_plain_6.png
Binary files differ
diff --git a/textures/pipeworks_mese_tube_short.png b/textures/pipeworks_mese_tube_short.png
new file mode 100644
index 0000000..1851dcf
--- /dev/null
+++ b/textures/pipeworks_mese_tube_short.png
Binary files differ
diff --git a/textures/red.png b/textures/red.png
new file mode 100644
index 0000000..1275e5d
--- /dev/null
+++ b/textures/red.png
Binary files differ
diff --git a/textures/white.png b/textures/white.png
new file mode 100644
index 0000000..8b83403
--- /dev/null
+++ b/textures/white.png
Binary files differ
diff --git a/textures/yellow.png b/textures/yellow.png
new file mode 100644
index 0000000..e6672bd
--- /dev/null
+++ b/textures/yellow.png
Binary files differ
diff --git a/tubes.lua b/tubes.lua
index a22c8a9..d788493 100644
--- a/tubes.lua
+++ b/tubes.lua
@@ -17,6 +17,8 @@ minetest.register_node("pipeworks:testobject", {
end,
})
+tubenodes={}
+
-- tables
minetest.register_alias("pipeworks:tube", "pipeworks:tube_000000")
@@ -64,7 +66,7 @@ function tube_addbox(t, b)
end
-- now define the nodes!
-
+function register_tube(name,desc,plain_textures,noctr_textures,end_textures,short_texture,inv_texture,special)
for xm = 0, 1 do
for xp = 0, 1 do
for ym = 0, 1 do
@@ -78,44 +80,44 @@ for zp = 0, 1 do
if yp==1 then
tube_addbox(outboxes, tube_topstub)
table.insert(outsel, tube_selectboxes[4])
- table.insert(outimgs, "pipeworks_tube_noctr.png")
+ table.insert(outimgs, noctr_textures[4])
else
- table.insert(outimgs, "pipeworks_tube_plain.png")
+ table.insert(outimgs, plain_textures[4])
end
if ym==1 then
tube_addbox(outboxes, tube_bottomstub)
table.insert(outsel, tube_selectboxes[3])
- table.insert(outimgs, "pipeworks_tube_noctr.png")
+ table.insert(outimgs, noctr_textures[3])
else
- table.insert(outimgs, "pipeworks_tube_plain.png")
+ table.insert(outimgs, plain_textures[3])
end
if xp==1 then
tube_addbox(outboxes, tube_rightstub)
table.insert(outsel, tube_selectboxes[2])
- table.insert(outimgs, "pipeworks_tube_noctr.png")
+ table.insert(outimgs, noctr_textures[2])
else
- table.insert(outimgs, "pipeworks_tube_plain.png")
+ table.insert(outimgs, plain_textures[2])
end
if xm==1 then
tube_addbox(outboxes, tube_leftstub)
table.insert(outsel, tube_selectboxes[1])
- table.insert(outimgs, "pipeworks_tube_noctr.png")
+ table.insert(outimgs, noctr_textures[1])
else
- table.insert(outimgs, "pipeworks_tube_plain.png")
+ table.insert(outimgs, plain_textures[1])
end
if zp==1 then
tube_addbox(outboxes, tube_backstub)
table.insert(outsel, tube_selectboxes[6])
- table.insert(outimgs, "pipeworks_tube_noctr.png")
+ table.insert(outimgs, noctr_textures[6])
else
- table.insert(outimgs, "pipeworks_tube_plain.png")
+ table.insert(outimgs, plain_textures[6])
end
if zm==1 then
tube_addbox(outboxes, tube_frontstub)
table.insert(outsel, tube_selectboxes[5])
- table.insert(outimgs, "pipeworks_tube_noctr.png")
+ table.insert(outimgs, noctr_textures[5])
else
- table.insert(outimgs, "pipeworks_tube_plain.png")
+ table.insert(outimgs, plain_textures[5])
end
local jx = xp+xm
@@ -125,27 +127,27 @@ for zp = 0, 1 do
if (jx+jy+jz) == 1 then
if xm == 1 then
table.remove(outimgs, 3)
- table.insert(outimgs, 3, "pipeworks_tube_end.png")
+ table.insert(outimgs, 3, end_textures[3])
end
if xp == 1 then
table.remove(outimgs, 4)
- table.insert(outimgs, 4, "pipeworks_tube_end.png")
+ table.insert(outimgs, 4, end_textures[4])
end
if ym == 1 then
table.remove(outimgs, 1)
- table.insert(outimgs, 1, "pipeworks_tube_end.png")
+ table.insert(outimgs, 1, end_textures[1])
end
if xp == 1 then
table.remove(outimgs, 2)
- table.insert(outimgs, 2, "pipeworks_tube_end.png")
+ table.insert(outimgs, 2, end_textures[2])
end
if zm == 1 then
table.remove(outimgs, 5)
- table.insert(outimgs, 5, "pipeworks_tube_end.png")
+ table.insert(outimgs, 5, end_textures[5])
end
if zp == 1 then
table.remove(outimgs, 6)
- table.insert(outimgs, 6, "pipeworks_tube_end.png")
+ table.insert(outimgs, 6, end_textures[6])
end
end
@@ -154,27 +156,26 @@ for zp = 0, 1 do
if tname ~= "000000" then
tgroups = {snappy=3, tube=1, not_in_creative_inventory=1}
- tubedesc = "Pneumatic tube segment ("..tname..")... You hacker, you."
+ tubedesc = desc.." ("..tname..")... You hacker, you."
iimg=nil
wscale = {x=1,y=1,z=1}
else
tgroups = {snappy=3, tube=1}
- tubedesc = "Pneumatic tube segment"
- iimg="pipeworks_tube_inv.png"
+ tubedesc = desc
+ iimg=inv_texture
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"
+ short_texture,short_texture,
+ end_textures[3],end_textures[4],
+ short_texture,short_texture
}
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 }
wscale = {x=1,y=1,z=0.01}
end
- minetest.register_node("pipeworks:tube_"..tname, {
+ table.insert(tubenodes,name.."_"..tname)
+
+ nodedef={
description = tubedesc,
drawtype = "nodebox",
tiles = outimgs,
@@ -194,19 +195,39 @@ for zp = 0, 1 do
sounds = default.node_sound_wood_defaults(),
walkable = true,
stack_max = 99,
- drop = "pipeworks:tube_000000",
+ drop = name.."_000000",
tubelike=1,
on_construct = function(pos)
- local meta = minetest.env:get_meta(pos)
- meta:set_int("tubelike",1)
+ local meta = minetest.env:get_meta(pos)
+ meta:set_int("tubelike",1)
+ if minetest.registered_nodes[name.."_"..tname].on_construct_ then
+ minetest.registered_nodes[name.."_"..tname].on_construct_(pos)
+ end
end,
after_place_node = function(pos)
tube_scanforobjects(pos)
+ if minetest.registered_nodes[name.."_"..tname].after_place_node_ then
+ minetest.registered_nodes[name.."_"..tname].after_place_node_(pos)
+ end
end,
after_dig_node = function(pos)
tube_scanforobjects(pos)
+ if minetest.registered_nodes[name.."_"..tname].after_dig_node_ then
+ minetest.registered_nodes[name.."_"..tname].after_dig_node_(pos)
+ end
end
- })
+ }
+
+ if special==nil then special={} end
+
+ for key,value in pairs(special) do
+ if key=="on_construct" or key=="after_dig_node" or key=="after_place_node" then
+ key=key.."_"
+ end
+ nodedef[key]=value
+ end
+
+ minetest.register_node(name.."_"..tname, nodedef)
end
end
@@ -214,4 +235,83 @@ end
end
end
end
+end
+
+noctr_textures={"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_textures={"pipeworks_tube_plain.png","pipeworks_tube_plain.png","pipeworks_tube_plain.png",
+ "pipeworks_tube_plain.png","pipeworks_tube_plain.png","pipeworks_tube_plain.png"}
+end_textures={"pipeworks_tube_end.png","pipeworks_tube_end.png","pipeworks_tube_end.png",
+ "pipeworks_tube_end.png","pipeworks_tube_end.png","pipeworks_tube_end.png"}
+short_texture="pipeworks_tube_short.png"
+inv_texture="pipeworks_tube_inv.png"
+register_tube("pipeworks:tube","Pneumatic tube segment",plain_textures,noctr_textures,end_textures,short_texture,inv_texture)
+
+mese_noctr_textures={"pipeworks_mese_tube_noctr_1.png","pipeworks_mese_tube_noctr_2.png","pipeworks_mese_tube_noctr_3.png",
+ "pipeworks_mese_tube_noctr_4.png","pipeworks_mese_tube_noctr_5.png","pipeworks_mese_tube_noctr_6.png"}
+
+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"}
+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"}
+mese_short_texture="pipeworks_mese_tube_short.png"
+mese_inv_texture="pipeworks_mese_tube_inv.png"
+
+
+meseadjlist={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=0,y=1,z=0},{x=0,y=-1,z=0},{x=1,y=0,z=0},{x=-1,y=0,z=0}}
+
+register_tube("pipeworks:mese_tube","Mese pneumatic tube segment",mese_plain_textures,mese_noctr_textures,
+ mese_end_textures,mese_short_texture,mese_inv_texture,
+ {tube={can_go=function(pos,node,velocity,stack)
+ tbl={}
+ local meta=minetest.env:get_meta(pos)
+ local inv=meta:get_inventory()
+ local found=false
+ local name=stack:get_name()
+ for i,vect in ipairs(meseadjlist) do
+ for _,st in ipairs(inv:get_list("line"..tostring(i))) do
+ if st:get_name()==name then
+ found=true
+ table.insert(tbl,vect)
+ end
+ end
+ end
+ if found==false then
+ for i,vect in ipairs(meseadjlist) do
+ if inv:is_empty("line"..tostring(i)) then
+ table.insert(tbl,vect)
+ end
+ end
+ end
+ return tbl
+ end},
+ on_construct = function(pos)
+ local meta = minetest.env:get_meta(pos)
+ meta:set_string("formspec",
+ "size[8,11]"..
+ "list[current_name;line1;1,0;7,1;]"..
+ "list[current_name;line2;1,1;7,1;]"..
+ "list[current_name;line3;1,2;7,1;]"..
+ "list[current_name;line4;1,3;7,1;]"..
+ "list[current_name;line5;1,4;7,1;]"..
+ "list[current_name;line6;1,5;7,1;]"..
+ "image[0,0;1,1;white.png]"..
+ "image[0,1;1,1;black.png]"..
+ "image[0,2;1,1;green.png]"..
+ "image[0,3;1,1;yellow.png]"..
+ "image[0,4;1,1;blue.png]"..
+ "image[0,5;1,1;red.png]"..
+ "list[current_player;main;0,7;8,4;]")
+ meta:set_string("infotext", "Mese pneumatic tube")
+ local inv = meta:get_inventory()
+ for i=1,6 do
+ inv:set_size("line"..tostring(i), 7*1)
+ end
+ end,
+ can_dig = function(pos,player)
+ local meta = minetest.env:get_meta(pos);
+ local inv = meta:get_inventory()
+ return (inv:is_empty("line1") and inv:is_empty("line2") and inv:is_empty("line3") and
+ inv:is_empty("line4") and inv:is_empty("line5") and inv:is_empty("line6"))
+ end})