summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crafts.lua9
-rw-r--r--item_transport.lua95
-rw-r--r--textures/pipeworks_mese_filter_input.pngbin0 -> 12120 bytes
-rw-r--r--textures/pipeworks_mese_filter_output.pngbin0 -> 12894 bytes
-rw-r--r--textures/pipeworks_mese_filter_side.pngbin0 -> 12700 bytes
-rw-r--r--textures/pipeworks_mese_filter_top.pngbin0 -> 12677 bytes
6 files changed, 102 insertions, 2 deletions
diff --git a/crafts.lua b/crafts.lua
index e5adc4e..8bbc580 100644
--- a/crafts.lua
+++ b/crafts.lua
@@ -155,6 +155,15 @@ if io.open(minetest.get_modpath("pipeworks").."/../technic/init.lua", "r") == ni
{ "default:steel_ingot", "default:steel_ingot", "homedecor:plastic_sheeting" }
},
})
+
+ 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" }
+ },
+ })
minetest.register_craft( {
output = "pipeworks:entry_panel 2",
diff --git a/item_transport.lua b/item_transport.lua
index 665516e..305a459 100644
--- a/item_transport.lua
+++ b/item_transport.lua
@@ -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)
diff --git a/textures/pipeworks_mese_filter_input.png b/textures/pipeworks_mese_filter_input.png
new file mode 100644
index 0000000..b8aed3e
--- /dev/null
+++ b/textures/pipeworks_mese_filter_input.png
Binary files differ
diff --git a/textures/pipeworks_mese_filter_output.png b/textures/pipeworks_mese_filter_output.png
new file mode 100644
index 0000000..b2ee77a
--- /dev/null
+++ b/textures/pipeworks_mese_filter_output.png
Binary files differ
diff --git a/textures/pipeworks_mese_filter_side.png b/textures/pipeworks_mese_filter_side.png
new file mode 100644
index 0000000..6bdb507
--- /dev/null
+++ b/textures/pipeworks_mese_filter_side.png
Binary files differ
diff --git a/textures/pipeworks_mese_filter_top.png b/textures/pipeworks_mese_filter_top.png
new file mode 100644
index 0000000..990116e
--- /dev/null
+++ b/textures/pipeworks_mese_filter_top.png
Binary files differ