mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add drop.json
This commit is contained in:
parent
8d41f6af11
commit
20ab48ecab
8 changed files with 28 additions and 13 deletions
|
|
@ -7,6 +7,7 @@
|
|||
#include "../../../physics/Hitbox.hpp"
|
||||
#include "../../../window/Camera.hpp"
|
||||
#include "../../../frontend/hud.hpp"
|
||||
#include "../../../content/Content.hpp"
|
||||
|
||||
#include <optional>
|
||||
|
||||
|
|
@ -21,10 +22,12 @@ static std::optional<Entity> get_entity(lua::State* L, int idx) {
|
|||
return level->entities->get(id);
|
||||
}
|
||||
|
||||
static int l_test(lua::State* L) {
|
||||
static int l_spawn(lua::State* L) {
|
||||
auto level = controller->getLevel();
|
||||
auto player = hud->getPlayer();
|
||||
auto id = level->entities->drop(player->camera->position);
|
||||
auto defname = lua::tostring(L, 1);
|
||||
auto& def = content->entities.require(defname);
|
||||
auto id = level->entities->spawn(def, player->camera->position);
|
||||
return lua::pushinteger(L, id);
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +46,7 @@ static int l_set_vel(lua::State* L) {
|
|||
}
|
||||
|
||||
const luaL_Reg entitylib [] = {
|
||||
{"test", lua::wrap<l_test>},
|
||||
{"spawn", lua::wrap<l_spawn>},
|
||||
{"get_vel", lua::wrap<l_get_vel>},
|
||||
{"set_vel", lua::wrap<l_set_vel>},
|
||||
{NULL, NULL}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue