add modeltree:get_model(index)
This commit is contained in:
@@ -21,15 +21,18 @@ extern const luaL_Reg jsonlib [];
|
||||
extern const luaL_Reg mat4lib [];
|
||||
extern const luaL_Reg packlib [];
|
||||
extern const luaL_Reg playerlib [];
|
||||
extern const luaL_Reg rigidbodylib [];
|
||||
extern const luaL_Reg timelib [];
|
||||
extern const luaL_Reg tomllib [];
|
||||
extern const luaL_Reg transformlib [];
|
||||
extern const luaL_Reg vec2lib [];
|
||||
extern const luaL_Reg vec3lib [];
|
||||
extern const luaL_Reg vec4lib [];
|
||||
extern const luaL_Reg worldlib [];
|
||||
|
||||
// Components
|
||||
extern const luaL_Reg modeltreelib [];
|
||||
extern const luaL_Reg rigidbodylib [];
|
||||
extern const luaL_Reg transformlib [];
|
||||
|
||||
// Lua Overrides
|
||||
extern int l_print(lua::State* L);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "../../../world/Level.hpp"
|
||||
#include "../../../objects/Player.hpp"
|
||||
#include "../../../objects/Entities.hpp"
|
||||
#include "../../../objects/rigging.hpp"
|
||||
#include "../../../physics/Hitbox.hpp"
|
||||
#include "../../../window/Camera.hpp"
|
||||
#include "../../../frontend/hud.hpp"
|
||||
@@ -110,6 +111,16 @@ static int l_get_size(lua::State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_modeltree_get_model(lua::State* L) {
|
||||
if (auto entity = get_entity(L, 1)) {
|
||||
auto& rig = entity->getModeltree();
|
||||
auto* rigConfig = rig.config;
|
||||
auto index = lua::tointeger(L, 2);
|
||||
return lua::pushstring(L, rigConfig->getNodes()[index]->getModelName());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg entitylib [] = {
|
||||
{"exists", lua::wrap<l_exists>},
|
||||
{"spawn", lua::wrap<l_spawn>},
|
||||
@@ -117,13 +128,18 @@ const luaL_Reg entitylib [] = {
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
const luaL_Reg transformlib [] = {
|
||||
const luaL_Reg modeltreelib [] = {
|
||||
{"get_model", lua::wrap<l_modeltree_get_model>},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
const luaL_Reg transformlib [] = {
|
||||
{"get_pos", lua::wrap<l_get_pos>},
|
||||
{"set_pos", lua::wrap<l_set_pos>},
|
||||
{"get_rot", lua::wrap<l_get_rot>},
|
||||
{"set_rot", lua::wrap<l_set_rot>},
|
||||
{NULL, NULL}
|
||||
};
|
||||
};
|
||||
|
||||
const luaL_Reg rigidbodylib [] = {
|
||||
{"is_enabled", lua::wrap<l_is_enabled>},
|
||||
|
||||
@@ -22,8 +22,8 @@ static void remove_lib_funcs(lua::State* L, const char* libname, const char* fun
|
||||
pushnil(L);
|
||||
setfield(L, funcs[i], -2);
|
||||
}
|
||||
pop(L);
|
||||
}
|
||||
pop(L);
|
||||
}
|
||||
|
||||
static void create_libs(lua::State* L) {
|
||||
@@ -31,7 +31,6 @@ 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);
|
||||
@@ -48,7 +47,10 @@ static void create_libs(lua::State* L) {
|
||||
openlib(L, "vec4", vec4lib);
|
||||
openlib(L, "world", worldlib);
|
||||
|
||||
openlib(L, "entities", entitylib);
|
||||
|
||||
// components
|
||||
openlib(L, "__modeltree", modeltreelib);
|
||||
openlib(L, "__rigidbody", rigidbodylib);
|
||||
openlib(L, "__transform", transformlib);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user