mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 13:01:49 +00:00
fix lua stack leak
This commit is contained in:
parent
982c8b132d
commit
e08bfd071b
3 changed files with 13 additions and 1 deletions
|
|
@ -3,14 +3,21 @@ local DROP_INIT_VEL = {0, 3, 0}
|
|||
|
||||
function on_hud_open()
|
||||
input.add_callback("player.drop", function ()
|
||||
for i=1,5 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(player.get_dir(pid), DROP_FORCE)
|
||||
local throw_force = vec3.mul(vec3.add(player.get_dir(pid),
|
||||
{
|
||||
math.random() - 0.5,
|
||||
math.random() - 0.5,
|
||||
math.random() - 0.5
|
||||
}), DROP_FORCE)
|
||||
|
||||
local drop = entity.spawn("base:drop", ppos)
|
||||
drop.rigidbody:set_vel(vec3.add(throw_force, vec3.add(pvel, DROP_INIT_VEL)))
|
||||
drop.transform:set_rot(mat4.rotate(mat4.rotate(mat4.rotate({0, 1, 0}, math.random() * 360),
|
||||
{1, 0, 0}, math.random() * 360), {0, 0, 1}, math.random() * 360))
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue