add 'tags.toml' file
This commit is contained in:
@@ -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}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user