add modeltree:get_model(index)

This commit is contained in:
MihailRis
2024-07-02 17:06:33 +03:00
parent 28ceffde9e
commit 3fe66e134d
8 changed files with 54 additions and 21 deletions
+13 -13
View File
@@ -4,20 +4,20 @@ 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 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 = 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))
local drop = entities.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
+2 -1
View File
@@ -24,6 +24,7 @@ function new_Rigidbody(eid)
end
local Modeltree = {__index={
get_model=function(self) return __modeltree.get_model(self.eid) end,
}}
function new_Modeltree(eid)
@@ -33,7 +34,7 @@ end
-- Entity class
local Entity = {__index={
despawn=function(self) return entity.despawn(self.eid) end,
despawn=function(self) return entities.despawn(self.eid) end,
}}
local entities = {}