mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
add entity.test(...) function
This commit is contained in:
parent
4b3ac95d71
commit
eacbc1b9d0
5 changed files with 33 additions and 3 deletions
|
|
@ -10,6 +10,7 @@ extern const luaL_Reg audiolib [];
|
|||
extern const luaL_Reg blocklib [];
|
||||
extern const luaL_Reg consolelib [];
|
||||
extern const luaL_Reg corelib [];
|
||||
extern const luaL_Reg entitylib [];
|
||||
extern const luaL_Reg filelib [];
|
||||
extern const luaL_Reg guilib [];
|
||||
extern const luaL_Reg hudlib [];
|
||||
|
|
|
|||
26
src/logic/scripting/lua/libentity.cpp
Normal file
26
src/logic/scripting/lua/libentity.cpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include "api_lua.hpp"
|
||||
|
||||
#include "../../LevelController.hpp"
|
||||
#include "../../../world/Level.hpp"
|
||||
#include "../../../objects/Player.hpp"
|
||||
#include "../../../objects/Entities.hpp"
|
||||
#include "../../../physics/Hitbox.hpp"
|
||||
#include "../../../window/Camera.hpp"
|
||||
#include "../../../frontend/hud.hpp"
|
||||
|
||||
namespace scripting {
|
||||
extern Hud* hud;
|
||||
}
|
||||
using namespace scripting;
|
||||
|
||||
static int l_test(lua::State* L) {
|
||||
auto level = controller->getLevel();
|
||||
auto player = hud->getPlayer();
|
||||
level->entities->drop(player->camera->position, player->camera->front*8.0f+glm::vec3(0, 2, 0)+player->hitbox->velocity);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg entitylib [] = {
|
||||
{"test", lua::wrap<l_test>},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
|
@ -31,6 +31,7 @@ static void create_libs(lua::State* L) {
|
|||
openlib(L, "block", blocklib);
|
||||
openlib(L, "console", consolelib);
|
||||
openlib(L, "core", corelib);
|
||||
openlib(L, "entity", entitylib);
|
||||
openlib(L, "file", filelib);
|
||||
openlib(L, "gui", guilib);
|
||||
openlib(L, "input", inputlib);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue