add EnumMetadata

This commit is contained in:
MihailRis
2025-04-13 13:53:59 +03:00
parent d888ddec4c
commit 7749675a61
20 changed files with 156 additions and 206 deletions
@@ -1,3 +1,5 @@
#define VC_ENABLE_REFLECTION
#include "util/stringutil.hpp"
#include "libentity.hpp"
@@ -96,8 +98,8 @@ static int l_set_crouching(lua::State* L) {
static int l_get_body_type(lua::State* L) {
if (auto entity = get_entity(L, 1)) {
return lua::pushstring(
L, to_string(entity->getRigidbody().hitbox.type)
return lua::pushlstring(
L, BodyTypeMeta.getName(entity->getRigidbody().hitbox.type)
);
}
return 0;
@@ -105,9 +107,9 @@ static int l_get_body_type(lua::State* L) {
static int l_set_body_type(lua::State* L) {
if (auto entity = get_entity(L, 1)) {
if (auto type = BodyType_from(lua::tostring(L, 2))) {
entity->getRigidbody().hitbox.type = *type;
} else {
if (!BodyTypeMeta.getItem(
lua::tostring(L, 2), entity->getRigidbody().hitbox.type
)) {
throw std::runtime_error(
"unknown body type " + util::quote(lua::tostring(L, 2))
);
+2 -1
View File
@@ -1,3 +1,4 @@
#define VC_ENABLE_REFLECTION
#include "content/Content.hpp"
#include "content/ContentLoader.hpp"
#include "content/ContentControl.hpp"
@@ -311,7 +312,7 @@ static int l_get_textures(lua::State* L) {
static int l_get_model(lua::State* L) {
if (auto def = require_block(L)) {
return lua::pushstring(L, to_string(def->model));
return lua::pushlstring(L, BlockModelMeta.getName(def->model));
}
return 0;
}