block.material + minor refactor

This commit is contained in:
MihailRis
2024-04-25 05:12:45 +03:00
parent 8730b03a52
commit b1a79e3a6e
9 changed files with 35 additions and 16 deletions
+13
View File
@@ -22,6 +22,18 @@ int l_block_name(lua_State* L) {
return 1;
}
int l_block_material(lua_State* L) {
auto indices = scripting::content->getIndices();
lua::luaint id = lua_tointeger(L, 1);
if (id < 0 || size_t(id) >= indices->countBlockDefs()) {
return 0;
}
auto def = indices->getBlockDef(id);
lua_pushstring(L, def->material.c_str());
return 1;
}
int l_is_solid_at(lua_State* L) {
lua::luaint x = lua_tointeger(L, 1);
lua::luaint y = lua_tointeger(L, 2);
@@ -218,6 +230,7 @@ int l_is_replaceable_at(lua_State* L) {
const luaL_Reg blocklib [] = {
{"index", lua_wrap_errors<l_block_index>},
{"name", lua_wrap_errors<l_block_name>},
{"material", lua_wrap_errors<l_block_material>},
{"defs_count", lua_wrap_errors<l_blocks_count>},
{"is_solid_at", lua_wrap_errors<l_is_solid_at>},
{"is_replaceable_at", lua_wrap_errors<l_is_replaceable_at>},