add entity.exists(...)
This commit is contained in:
parent
4df0f4e1e4
commit
e1eb652ef4
@ -22,6 +22,10 @@ static std::optional<Entity> get_entity(lua::State* L, int idx) {
|
||||
return level->entities->get(id);
|
||||
}
|
||||
|
||||
static int l_exists(lua::State* L) {
|
||||
return lua::pushboolean(L, get_entity(L, 1).has_value());
|
||||
}
|
||||
|
||||
static int l_spawn(lua::State* L) {
|
||||
auto level = controller->getLevel();
|
||||
auto defname = lua::tostring(L, 1);
|
||||
@ -102,6 +106,7 @@ static int l_get_size(lua::State* L) {
|
||||
}
|
||||
|
||||
const luaL_Reg entitylib [] = {
|
||||
{"exists", lua::wrap<l_exists>},
|
||||
{"spawn", lua::wrap<l_spawn>},
|
||||
{"despawn", lua::wrap<l_despawn>},
|
||||
{NULL, NULL}
|
||||
|
||||
@ -90,6 +90,10 @@ public:
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
inline size_t size() const {
|
||||
return entities.size();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // OBJECTS_ENTITIES_HPP_
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user