diff --git a/apps/openmw/mwlua/magicbindings.cpp b/apps/openmw/mwlua/magicbindings.cpp index 586c50be6d..2048060f86 100644 --- a/apps/openmw/mwlua/magicbindings.cpp +++ b/apps/openmw/mwlua/magicbindings.cpp @@ -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 id) -> std::tuple { MagicEffectStore::iterator iter; diff --git a/files/lua_api/openmw/core.lua b/files/lua_api/openmw/core.lua index 70b91ed224..4f9adc3b08 100644 --- a/files/lua_api/openmw/core.lua +++ b/files/lua_api/openmw/core.lua @@ -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