mirror of
https://github.com/mt-mods/pipeworks.git
synced 2025-06-26 05:20:34 +02:00
check destination node before injecting item
This commit is contained in:
parent
e23a2fda3d
commit
e9d5bd8fce
@ -35,14 +35,25 @@ end
|
|||||||
function pipeworks.tube_inject_item(pos, start_pos, velocity, item, owner, tags)
|
function pipeworks.tube_inject_item(pos, start_pos, velocity, item, owner, tags)
|
||||||
-- Take item in any format
|
-- Take item in any format
|
||||||
local stack = ItemStack(item)
|
local stack = ItemStack(item)
|
||||||
|
local to_pos = vector.add(pos, velocity)
|
||||||
|
local def = minetest.registered_nodes[minetest.get_node(to_pos).name]
|
||||||
|
if not def or not def.groups or not (def.groups.tube
|
||||||
|
or def.groups.tubedevice or def.groups.tubedevice_receiver) then
|
||||||
|
local dropped_item = minetest.add_item(pos, stack)
|
||||||
|
if dropped_item then
|
||||||
|
dropped_item:set_velocity(vector.multiply(velocity, 5))
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
local obj = luaentity.add_entity(pos, "pipeworks:tubed_item")
|
local obj = luaentity.add_entity(pos, "pipeworks:tubed_item")
|
||||||
obj:set_item(stack:to_string())
|
if obj then
|
||||||
obj.start_pos = vector.new(start_pos)
|
obj:set_item(stack:to_string())
|
||||||
obj:set_velocity(velocity)
|
obj.start_pos = vector.new(start_pos)
|
||||||
obj.owner = owner
|
obj:set_velocity(velocity)
|
||||||
obj.tags = tags
|
obj.owner = owner
|
||||||
--obj:set_color("red") -- todo: this is test-only code
|
obj.tags = tags
|
||||||
return obj
|
return obj
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- adding two tube functions
|
-- adding two tube functions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user