add 'tags.toml' file

This commit is contained in:
MihailRis
2025-09-19 22:16:28 +03:00
parent b85e357ab2
commit 43a7331f62
4 changed files with 76 additions and 29 deletions
+16
View File
@@ -117,6 +117,21 @@ static int l_has_tag(lua::State* L) {
return 0;
}
static int l_get_tags(lua::State* L) {
if (auto def = get_item_def(L, 1)) {
if (def->tags.empty()) {
return 0;
}
lua::createtable(L, 0, def->tags.size());
for (const auto& tag : def->tags) {
lua::pushboolean(L, true);
lua::setfield(L, tag);
}
return 1;
}
return 0;
}
const luaL_Reg itemlib[] = {
{"index", lua::wrap<l_index>},
{"name", lua::wrap<l_name>},
@@ -131,5 +146,6 @@ const luaL_Reg itemlib[] = {
{"uses", lua::wrap<l_uses>},
{"reload_script", lua::wrap<l_reload_script>},
{"has_tag", lua::wrap<l_has_tag>},
{"__get_tags", lua::wrap<l_get_tags>},
{NULL, NULL}
};