add block.has_tag, item.has_tag
This commit is contained in:
@@ -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}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user