mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-24 21:11:34 +00:00
Lua: String overload for effects store index.
This commit is contained in:
parent
e76ce6b696
commit
edb7081ea6
2 changed files with 9 additions and 2 deletions
|
@ -240,8 +240,12 @@ namespace MWLua
|
||||||
magicEffectStoreT[sol::meta_function::to_string] = [](const MagicEffectStore& store) {
|
magicEffectStoreT[sol::meta_function::to_string] = [](const MagicEffectStore& store) {
|
||||||
return "ESM3_MagicEffectStore{" + std::to_string(store.getSize()) + " effects}";
|
return "ESM3_MagicEffectStore{" + std::to_string(store.getSize()) + " effects}";
|
||||||
};
|
};
|
||||||
magicEffectStoreT[sol::meta_function::index]
|
magicEffectStoreT[sol::meta_function::index] = sol::overload(
|
||||||
= [](const MagicEffectStore& store, int id) -> const ESM::MagicEffect* { return store.find(id); };
|
[](const MagicEffectStore& store, int id) -> const ESM::MagicEffect* { return store.find(id); },
|
||||||
|
[](const MagicEffectStore& store, std::string_view id) -> const ESM::MagicEffect* {
|
||||||
|
int index = ESM::MagicEffect::indexNameToIndex(id);
|
||||||
|
return store.find(index);
|
||||||
|
});
|
||||||
auto magicEffectsIter = [magicEffectStore](sol::this_state lua, const sol::object& /*store*/,
|
auto magicEffectsIter = [magicEffectStore](sol::this_state lua, const sol::object& /*store*/,
|
||||||
sol::optional<int> id) -> std::tuple<sol::object, sol::object> {
|
sol::optional<int> id) -> std::tuple<sol::object, sol::object> {
|
||||||
MagicEffectStore::iterator iter;
|
MagicEffectStore::iterator iter;
|
||||||
|
|
|
@ -663,6 +663,9 @@
|
||||||
-- print(effect.name)
|
-- print(effect.name)
|
||||||
-- end
|
-- end
|
||||||
-- end
|
-- end
|
||||||
|
-- @usage -- Look up the record of a specific effect and print its icon
|
||||||
|
-- local mgef = core.magic.effects[core.magic.EFFECT_TYPE.Reflect]
|
||||||
|
-- print('Reflect Icon: '..tostring(mgef.icon))
|
||||||
|
|
||||||
--- List of all @{#Enchantment}s.
|
--- List of all @{#Enchantment}s.
|
||||||
-- @field [parent=#Magic] #list<#Enchantment> enchantments
|
-- @field [parent=#Magic] #list<#Enchantment> enchantments
|
||||||
|
|
Loading…
Reference in a new issue