22 lines
723 B
Lua
22 lines
723 B
Lua
local DROP_FORCE = 8
|
|
local DROP_INIT_VEL = {0, 3, 0}
|
|
|
|
function on_hud_open()
|
|
input.add_callback("player.drop", function ()
|
|
for i=1,80 do
|
|
local pid = hud.get_player()
|
|
local pvel = {player.get_vel(pid)}
|
|
local ppos = vec3.add({player.get_pos(pid)}, {0, 0.7, 0})
|
|
local throw_force = vec3.mul(vec3.add(player.get_dir(pid),
|
|
{
|
|
(math.random() - 0.5) * 1,
|
|
(math.random() - 0.5) * 1,
|
|
(math.random() - 0.5) * 1
|
|
}), DROP_FORCE)
|
|
|
|
local drop = entities.spawn("base:drop", ppos)
|
|
drop.rigidbody:set_vel(vec3.add(throw_force, vec3.add(pvel, DROP_INIT_VEL)))
|
|
end
|
|
end)
|
|
end
|