Merge pull request #6 from Novatux/master
Item insertion in furnaces through side and mese pipe
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
BIN
textures/black.png
Normal file
After Width: | Height: | Size: 150 B |
BIN
textures/blue.png
Normal file
After Width: | Height: | Size: 160 B |
BIN
textures/green.png
Normal file
After Width: | Height: | Size: 160 B |
BIN
textures/pipeworks_mese_tube_end.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
textures/pipeworks_mese_tube_inv.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
textures/pipeworks_mese_tube_noctr_1.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
textures/pipeworks_mese_tube_noctr_2.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
textures/pipeworks_mese_tube_noctr_3.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
textures/pipeworks_mese_tube_noctr_4.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
textures/pipeworks_mese_tube_noctr_5.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
textures/pipeworks_mese_tube_noctr_6.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
textures/pipeworks_mese_tube_plain_1.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
textures/pipeworks_mese_tube_plain_2.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
textures/pipeworks_mese_tube_plain_3.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
textures/pipeworks_mese_tube_plain_4.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
textures/pipeworks_mese_tube_plain_5.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
textures/pipeworks_mese_tube_plain_6.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
textures/pipeworks_mese_tube_short.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
textures/red.png
Normal file
After Width: | Height: | Size: 160 B |
BIN
textures/white.png
Normal file
After Width: | Height: | Size: 160 B |
BIN
textures/yellow.png
Normal file
After Width: | Height: | Size: 160 B |
166
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})
|
||||
|