diff --git a/res/content/base/scripts/hud.lua b/res/content/base/scripts/hud.lua index 09e83f6b..710a8e5e 100644 --- a/res/content/base/scripts/hud.lua +++ b/res/content/base/scripts/hud.lua @@ -5,7 +5,8 @@ function on_hud_open() input.add_callback("player.drop", function () local pid = hud.get_player() local pvel = {player.get_vel(pid)} - local eid = entity.spawn("base:drop") + local ppos = vec3.add({player.get_pos(pid)}, {0, 0.7, 0}) + local eid = entity.spawn("base:drop", ppos) local throw_force = vec3.mul(player.get_dir(pid), DROP_FORCE) Rigidbody.set_vel(eid, vec3.add(throw_force, vec3.add(pvel, DROP_INIT_VEL))) Transform.set_rot(eid, mat4.rotate({0, 1, 0}, math.random() * 360)) diff --git a/src/logic/scripting/lua/libentity.cpp b/src/logic/scripting/lua/libentity.cpp index 36676655..894e17c9 100644 --- a/src/logic/scripting/lua/libentity.cpp +++ b/src/logic/scripting/lua/libentity.cpp @@ -24,10 +24,10 @@ static std::optional get_entity(lua::State* L, int idx) { static int l_spawn(lua::State* L) { auto level = controller->getLevel(); - auto player = hud->getPlayer(); auto defname = lua::tostring(L, 1); auto& def = content->entities.require(defname); - auto id = level->entities->spawn(def, player->camera->position); + auto pos = lua::tovec3(L, 2); + auto id = level->entities->spawn(def, pos); return lua::pushinteger(L, id); }