add block.has_tag, item.has_tag

This commit is contained in:
MihailRis
2025-08-30 23:46:45 +03:00
parent 8bdf31d7bb
commit 185b6cc661
7 changed files with 41 additions and 6 deletions
+10
View File
@@ -698,6 +698,15 @@ static int l_reload_script(lua::State* L) {
return 0;
}
static int l_has_tag(lua::State* L) {
if (auto def = require_block(L)) {
auto tag = lua::require_string(L, 2);
const auto& tags = def->rt.tags;
return lua::pushboolean(L, tags.find(content->getTagIndex(tag)) != tags.end());
}
return 0;
}
const luaL_Reg blocklib[] = {
{"index", lua::wrap<l_index>},
{"name", lua::wrap<l_get_def>},
@@ -737,5 +746,6 @@ const luaL_Reg blocklib[] = {
{"get_field", lua::wrap<l_get_field>},
{"set_field", lua::wrap<l_set_field>},
{"reload_script", lua::wrap<l_reload_script>},
{"has_tag", lua::wrap<l_has_tag>},
{NULL, NULL}
};