add skeleton:get_texture

This commit is contained in:
MihailRis
2024-07-13 01:51:50 +03:00
parent e506d17c50
commit ffb0ab2f05
3 changed files with 15 additions and 1 deletions
+13
View File
@@ -39,6 +39,18 @@ static int l_set_matrix(lua::State* L) {
return 0;
}
static int l_get_texture(lua::State* L) {
if (auto entity = get_entity(L, 1)) {
auto& skeleton = entity->getSkeleton();
skeleton.textures[lua::require_string(L, 2)] = lua::require_string(L, 3);
const auto& found = skeleton.textures.find(lua::require_string(L, 2));
if (found != skeleton.textures.end()) {
return lua::pushstring(L, found->second);
}
}
return 0;
}
static int l_set_texture(lua::State* L) {
if (auto entity = get_entity(L, 1)) {
auto& skeleton = entity->getSkeleton();
@@ -51,6 +63,7 @@ const luaL_Reg skeletonlib [] = {
{"get_model", lua::wrap<l_get_model>},
{"get_matrix", lua::wrap<l_get_matrix>},
{"set_matrix", lua::wrap<l_set_matrix>},
{"get_texture", lua::wrap<l_get_texture>},
{"set_texture", lua::wrap<l_set_texture>},
{NULL, NULL}
};