make self-contained injector directional

This commit is contained in:
OgelGames 2020-05-20 20:24:49 +10:00
parent f83ad4f6c1
commit f99148f2c4
1 changed files with 12 additions and 5 deletions

View File

@ -5,7 +5,13 @@ local fs_helpers = pipeworks.fs_helpers
local tube_entry = "^pipeworks_tube_connection_metallic.png"
local function inject_items (pos)
local param2_to_under = {
[0] = {x= 0,y=-1,z= 0}, [1] = {x= 0,y= 0,z=-1},
[2] = {x= 0,y= 0,z= 1}, [3] = {x=-1,y= 0,z= 0},
[4] = {x= 1,y= 0,z= 0}, [5] = {x= 0,y= 1,z= 0}
}
local function inject_items(pos, dir)
local meta=minetest.get_meta(pos)
local inv = meta:get_inventory()
local mode=meta:get_string("mode")
@ -17,7 +23,7 @@ local function inject_items (pos)
local item0=stack:to_table()
if item0 then
item0["count"] = 1
technic.tube_inject_item(pos, pos, vector.new(0, -1, 0), item0)
technic.tube_inject_item(pos, pos, dir, item0)
stack:take_item(1)
inv:set_stack("main", i, stack)
return
@ -32,7 +38,7 @@ local function inject_items (pos)
if stack then
local item0=stack:to_table()
if item0 then
technic.tube_inject_item(pos, pos, vector.new(0, -1, 0), item0)
technic.tube_inject_item(pos, pos, dir, item0)
stack:clear()
inv:set_stack("main", i, stack)
return
@ -141,10 +147,11 @@ minetest.register_abm({
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local pos1 = vector.add(pos, vector.new(0, -1, 0))
local dir = param2_to_under[math.floor(node.param2/4)]
local pos1 = vector.add(pos, dir)
local node1 = minetest.get_node(pos1)
if minetest.get_item_group(node1.name, "tubedevice") > 0 then
inject_items(pos)
inject_items(pos, dir)
end
end,
})