Make items shot by dispensers and droppers always go forward

This commit is contained in:
wallabra 2022-02-09 03:34:23 -03:00
parent 11a661f427
commit 96b8552ae4
Signed by: Gustavo6046
GPG Key ID: 5182FABAA5E139B3
2 changed files with 29 additions and 4 deletions

View File

@ -260,9 +260,22 @@ local dispenserdef = {
end
else
-- Drop item otherwise
minetest.add_item(droppos, dropitem)
stack:take_item()
inv:set_stack("main", stack_id, stack)
-- Drop item normally
local dropitemobj = minetest.add_item(droppos, dropitem)
stack:take_item()
inv:set_stack("main", stack_id, stack)
-- Set item velocity (overrides the default random drop direction)
local shoot_force = 1.3
local newv = minetest.facedir_to_dir(node.param2)
newv = {
x = newv.x * shoot_force,
y = newv.y * shoot_force,
z = newv.z * shoot_force
}
dropitemobj.set_velocity(newv)
end
end

View File

@ -134,9 +134,21 @@ local dropperdef = {
-- No container?
if not dropped and not dropnodedef.groups.container then
-- Drop item normally
minetest.add_item(droppos, dropitem)
local dropitemobj = minetest.add_item(droppos, dropitem)
stack:take_item()
inv:set_stack("main", stack_id, stack)
-- Set item velocity (overrides the default random drop direction)
local shoot_force = 1.3
local newv = minetest.facedir_to_dir(node.param2)
newv = {
x = newv.x * shoot_force,
y = newv.y * shoot_force,
z = newv.z * shoot_force
}
dropitemobj.set_velocity(newv)
end
end
end,