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
@@ -108,6 +108,15 @@ static int l_reload_script(lua::State* L) {
return 0;
}
static int l_has_tag(lua::State* L) {
if (auto def = get_item_def(L, 1)) {
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 itemlib[] = {
{"index", lua::wrap<l_index>},
{"name", lua::wrap<l_name>},
@@ -121,5 +130,6 @@ const luaL_Reg itemlib[] = {
{"emission", lua::wrap<l_emission>},
{"uses", lua::wrap<l_uses>},
{"reload_script", lua::wrap<l_reload_script>},
{"has_tag", lua::wrap<l_has_tag>},
{NULL, NULL}
};