diff --git a/res/content/base/scripts/hud.lua b/res/content/base/scripts/hud.lua index 26083c49..155a0a00 100644 --- a/res/content/base/scripts/hud.lua +++ b/res/content/base/scripts/hud.lua @@ -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 diff --git a/src/frontend/debug_panel.cpp b/src/frontend/debug_panel.cpp index 8af49f86..6960a6e9 100644 --- a/src/frontend/debug_panel.cpp +++ b/src/frontend/debug_panel.cpp @@ -10,6 +10,7 @@ #include "../graphics/render/WorldRenderer.hpp" #include "../logic/scripting/scripting.hpp" #include "../objects/Player.hpp" +#include "../objects/Entities.hpp" #include "../physics/Hitbox.hpp" #include "../util/stringutil.hpp" #include "../voxels/Block.hpp" @@ -83,6 +84,9 @@ std::shared_ptr create_debug_panel( return L"chunks: "+std::to_wstring(level->chunks->chunksCount)+ L" visible: "+std::to_wstring(level->chunks->visible); })); + panel->add(create_label([=]() { + return L"entities: "+std::to_wstring(level->entities->size()); + })); panel->add(create_label([=](){ const auto& vox = player->selection.vox; std::wstringstream stream; diff --git a/src/logic/scripting/scripting.cpp b/src/logic/scripting/scripting.cpp index cd6c407f..cc50014b 100644 --- a/src/logic/scripting/scripting.cpp +++ b/src/logic/scripting/scripting.cpp @@ -318,6 +318,7 @@ void scripting::on_entities_update() { auto L = lua::get_main_thread(); lua::get_from(L, STDCOMP, "update", true); lua::call_nothrow(L, 0, 0); + lua::pop(L); } void scripting::on_ui_open(