1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-29 22:20:33 +00:00

Merge branch 'effective-effect-indexing' into 'master'

Lua: String overload for effects store index.

See merge request OpenMW/openmw!3285
This commit is contained in:
Petr Mikheev 2023-07-30 23:55:19 +00:00
commit 5702cb4b30
2 changed files with 9 additions and 2 deletions

View File

@ -240,8 +240,12 @@ namespace MWLua
magicEffectStoreT[sol::meta_function::to_string] = [](const MagicEffectStore& store) {
return "ESM3_MagicEffectStore{" + std::to_string(store.getSize()) + " effects}";
};
magicEffectStoreT[sol::meta_function::index]
= [](const MagicEffectStore& store, int id) -> const ESM::MagicEffect* { return store.find(id); };
magicEffectStoreT[sol::meta_function::index] = sol::overload(
[](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*/,
sol::optional<int> id) -> std::tuple<sol::object, sol::object> {
MagicEffectStore::iterator iter;

View File

@ -663,6 +663,9 @@
-- print(effect.name)
-- 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.
-- @field [parent=#Magic] #list<#Enchantment> enchantments