|
|
|
@ -204,7 +204,7 @@ namespace MWLua
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static sol::table effectParamsListToTable(sol::state_view& lua, const std::vector<ESM::IndexedENAMstruct>& effects)
|
|
|
|
|
static sol::table effectParamsListToTable(lua_State* lua, const std::vector<ESM::IndexedENAMstruct>& effects)
|
|
|
|
|
{
|
|
|
|
|
sol::table res(lua, sol::create);
|
|
|
|
|
for (size_t i = 0; i < effects.size(); ++i)
|
|
|
|
@ -313,8 +313,9 @@ namespace MWLua
|
|
|
|
|
[](const ESM::Spell& rec) -> bool { return !!(rec.mData.mFlags & ESM::Spell::F_PCStart); });
|
|
|
|
|
spellT["autocalcFlag"] = sol::readonly_property(
|
|
|
|
|
[](const ESM::Spell& rec) -> bool { return !!(rec.mData.mFlags & ESM::Spell::F_Autocalc); });
|
|
|
|
|
spellT["effects"] = sol::readonly_property(
|
|
|
|
|
[&lua](const ESM::Spell& rec) -> sol::table { return effectParamsListToTable(lua, rec.mEffects.mList); });
|
|
|
|
|
spellT["effects"] = sol::readonly_property([lua = lua.lua_state()](const ESM::Spell& rec) -> sol::table {
|
|
|
|
|
return effectParamsListToTable(lua, rec.mEffects.mList);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Enchantment record
|
|
|
|
|
auto enchantT = lua.new_usertype<ESM::Enchantment>("ESM3_Enchantment");
|
|
|
|
@ -328,7 +329,8 @@ namespace MWLua
|
|
|
|
|
enchantT["cost"] = sol::readonly_property([](const ESM::Enchantment& rec) -> int { return rec.mData.mCost; });
|
|
|
|
|
enchantT["charge"]
|
|
|
|
|
= sol::readonly_property([](const ESM::Enchantment& rec) -> int { return rec.mData.mCharge; });
|
|
|
|
|
enchantT["effects"] = sol::readonly_property([&lua](const ESM::Enchantment& rec) -> sol::table {
|
|
|
|
|
enchantT["effects"]
|
|
|
|
|
= sol::readonly_property([lua = lua.lua_state()](const ESM::Enchantment& rec) -> sol::table {
|
|
|
|
|
return effectParamsListToTable(lua, rec.mEffects.mList);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -522,7 +524,8 @@ namespace MWLua
|
|
|
|
|
activeSpellT["id"] = sol::readonly_property([](const ActiveSpell& activeSpell) -> std::string {
|
|
|
|
|
return activeSpell.mParams.getSourceSpellId().serializeText();
|
|
|
|
|
});
|
|
|
|
|
activeSpellT["item"] = sol::readonly_property([&lua](const ActiveSpell& activeSpell) -> sol::object {
|
|
|
|
|
activeSpellT["item"]
|
|
|
|
|
= sol::readonly_property([lua = lua.lua_state()](const ActiveSpell& activeSpell) -> sol::object {
|
|
|
|
|
auto item = activeSpell.mParams.getItem();
|
|
|
|
|
if (!item.isSet())
|
|
|
|
|
return sol::nil;
|
|
|
|
@ -534,9 +537,10 @@ namespace MWLua
|
|
|
|
|
else
|
|
|
|
|
return sol::make_object(lua, LObject(itemPtr));
|
|
|
|
|
});
|
|
|
|
|
activeSpellT["caster"] = sol::readonly_property([&lua](const ActiveSpell& activeSpell) -> sol::object {
|
|
|
|
|
auto caster
|
|
|
|
|
= MWBase::Environment::get().getWorld()->searchPtrViaActorId(activeSpell.mParams.getCasterActorId());
|
|
|
|
|
activeSpellT["caster"]
|
|
|
|
|
= sol::readonly_property([lua = lua.lua_state()](const ActiveSpell& activeSpell) -> sol::object {
|
|
|
|
|
auto caster = MWBase::Environment::get().getWorld()->searchPtrViaActorId(
|
|
|
|
|
activeSpell.mParams.getCasterActorId());
|
|
|
|
|
if (caster.isEmpty())
|
|
|
|
|
return sol::nil;
|
|
|
|
|
else
|
|
|
|
@ -547,7 +551,8 @@ namespace MWLua
|
|
|
|
|
return sol::make_object(lua, LObject(getId(caster)));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
activeSpellT["effects"] = sol::readonly_property([&lua](const ActiveSpell& activeSpell) -> sol::table {
|
|
|
|
|
activeSpellT["effects"]
|
|
|
|
|
= sol::readonly_property([lua = lua.lua_state()](const ActiveSpell& activeSpell) -> sol::table {
|
|
|
|
|
sol::table res(lua, sol::create);
|
|
|
|
|
size_t tableIndex = 0;
|
|
|
|
|
for (const ESM::ActiveEffect& effect : activeSpell.mParams.getEffects())
|
|
|
|
|