Merge pull request #16 from Novatux/master

Mese filters: take full stack.
This commit is contained in:
VanessaE 2013-01-28 21:19:31 -08:00
commit 38b8d1a123
6 changed files with 102 additions and 3 deletions

View File

@ -76,6 +76,15 @@ minetest.register_craft( {
},
})
minetest.register_craft( {
output = "pipeworks:mese_filter 2",
recipe = {
{ "default:steel_ingot", "default:steel_ingot", "homedecor:plastic_sheeting" },
{ "default:stick", "default:mese", "homedecor:plastic_sheeting" },
{ "default:steel_ingot", "default:steel_ingot", "homedecor:plastic_sheeting" }
},
})
-- The tubes themselves
@ -220,4 +229,3 @@ if io.open(minetest.get_modpath("pipeworks").."/../technic/init.lua", "r") == ni
})
end

View File

@ -8,7 +8,7 @@ minetest.register_craftitem("pipeworks:filter", {
})
minetest.register_node("pipeworks:filter", {
description = "filter",
description = "Filter",
tiles = {"pipeworks_filter_top.png", "pipeworks_filter_top.png", "pipeworks_filter_output.png",
"pipeworks_filter_input.png", "pipeworks_filter_side.png", "pipeworks_filter_top.png"},
paramtype2 = "facedir",
@ -94,6 +94,97 @@ minetest.register_node("pipeworks:filter", {
end,
})
minetest.register_craftitem("pipeworks:mese_filter", {
description = "Mese filter",
stack_max = 99,
})
minetest.register_node("pipeworks:mese_filter", {
description = "Mese filter",
tiles = {"pipeworks_mese_filter_top.png", "pipeworks_mese_filter_top.png", "pipeworks_mese_filter_output.png",
"pipeworks_mese_filter_input.png", "pipeworks_mese_filter_side.png", "pipeworks_mese_filter_top.png"},
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,tubedevice=1,mesecon=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
"invsize[9,9;]"..
"list[current_name;main;0,2;8,2;]"..
"list[current_player;main;0,5;8,4;]")
meta:set_string("infotext", "Mese filter")
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
mesecons={effector={action_on=function(pos,node)
minetest.registered_nodes[node.name].on_punch(pos,node,nil)
end}},
on_punch = function (pos, node, puncher)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
local frompos
local dir
if node.param2==0 then
frompos={x=pos.x-1,y=pos.y,z=pos.z}
dir={x=1,y=0,z=0}
elseif node.param2==1 then
frompos={x=pos.x,y=pos.y,z=pos.z+1}
dir={x=0,y=0,z=-1}
elseif node.param2==2 then
frompos={x=pos.x+1,y=pos.y,z=pos.z}
dir={x=-1,y=0,z=0}
else
frompos={x=pos.x,y=pos.y,z=pos.z-1}
dir={x=0,y=0,z=1}
end
local fromnode=minetest.env:get_node(frompos)
local frominv
if not (minetest.registered_nodes[fromnode.name].tube and
minetest.registered_nodes[fromnode.name].tube.input_inventory) then
return
end
local frommeta=minetest.env:get_meta(frompos)
local frominvname=minetest.registered_nodes[fromnode.name].tube.input_inventory
local frominv=frommeta:get_inventory()
for _,filter in ipairs(inv:get_list("main")) do
local sname=filter:get_name()
if sname ~="" then
for spos,stack in ipairs(frominv:get_list(frominvname)) do
if stack:get_name()==sname then
item=stack:take_item(stack:get_count())
frominv:set_stack(frominvname,spos,stack)
pos1=pos
item1=tube_item({x=pos1.x,y=pos1.y,z=pos1.z},item)
item1:get_luaentity().start_pos = {x=pos1.x,y=pos1.y,z=pos1.z}
item1:setvelocity(dir)
item1:setacceleration({x=0, y=0, z=0})
return
end
end
end
end
if inv:is_empty("main") then
for spos,stack in ipairs(frominv:get_list(frominvname)) do
if stack:get_name()~="" then
item=stack:take_item(stack:get_count())
frominv:set_stack(frominvname,spos,stack)
pos1=pos
item1=tube_item({x=pos1.x,y=pos1.y,z=pos1.z},item)
item1:get_luaentity().start_pos = {x=pos1.x,y=pos1.y,z=pos1.z}
item1:setvelocity(dir)
item1:setacceleration({x=0, y=0, z=0})
return
end
end
end
end,
})
function tube_item(pos, item)
-- Take item in any format
@ -303,7 +394,7 @@ function go_next(pos,velocity,stack)
speed=1
end
vel.speed=speed
if minetest.registered_nodes[cnode.name].tube and minetest.registered_nodes[cnode.name].tube.can_go then
if minetest.registered_nodes[cnode.name] and 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,vel,stack)
else
can_go=notvel(adjlist,vel)

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB