mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add entities.name(...) and entity:get_name(...)
This commit is contained in:
parent
ec4043bc12
commit
5a3f28f2b5
6 changed files with 22 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "../../../objects/Player.hpp"
|
||||
#include "../../../objects/Entities.hpp"
|
||||
#include "../../../objects/EntityDef.hpp"
|
||||
#include "../../../objects/rigging.hpp"
|
||||
#include "../../../physics/Hitbox.hpp"
|
||||
#include "../../../window/Camera.hpp"
|
||||
|
|
@ -15,6 +16,13 @@ static int l_exists(lua::State* L) {
|
|||
return lua::pushboolean(L, get_entity(L, 1).has_value());
|
||||
}
|
||||
|
||||
static int l_name(lua::State* L) {
|
||||
if (auto entity = get_entity(L, 1)) {
|
||||
return lua::pushstring(L, entity->getDef().name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_spawn(lua::State* L) {
|
||||
auto level = controller->getLevel();
|
||||
auto defname = lua::tostring(L, 1);
|
||||
|
|
@ -150,6 +158,7 @@ static int l_raycast(lua::State* L) {
|
|||
|
||||
const luaL_Reg entitylib [] = {
|
||||
{"exists", lua::wrap<l_exists>},
|
||||
{"name", lua::wrap<l_name>},
|
||||
{"spawn", lua::wrap<l_spawn>},
|
||||
{"despawn", lua::wrap<l_despawn>},
|
||||
{"get_skeleton", lua::wrap<l_get_skeleton>},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue