1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-13 17:43:08 +00:00

no skill returns nil

This commit is contained in:
kuyondo 2022-05-20 06:03:12 +08:00
parent 8a1a838ffa
commit 7dbccc914a
2 changed files with 36 additions and 30 deletions

View file

@ -19,7 +19,7 @@ namespace MWLua
sol::table skill(context.mLua->sol(), sol::create);
book["SKILL"] = LuaUtil::makeStrictReadOnly(skill);
for (int id = ESM::Skill::Block; id < ESM::Skill::Length; ++id)
skill[(ESM::Skill::sSkillNames[id])] = id;
skill[Misc::StringUtils::lowerCase(ESM::Skill::sSkillNames[id])] = Misc::StringUtils::lowerCase(ESM::Skill::sSkillNames[id]);
const MWWorld::Store<ESM::Book>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Book>();
book["record"] = sol::overload(
@ -35,9 +35,15 @@ namespace MWLua
record["text"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mText; });
record["enchant"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mEnchant; });
record["isScroll"] = sol::readonly_property([](const ESM::Book& rec) -> bool { return rec.mData.mIsScroll; });
record["skill"] = sol::readonly_property([](const ESM::Book& rec) -> int { return rec.mData.mSkillId; });
record["value"] = sol::readonly_property([](const ESM::Book& rec) -> int { return rec.mData.mValue; });
record["weight"] = sol::readonly_property([](const ESM::Book& rec) -> float { return rec.mData.mWeight; });
record["enchantCapacity"] = sol::readonly_property([](const ESM::Book& rec) -> float { return rec.mData.mEnchant * 0.1f; });
record["skill"] = sol::readonly_property([](const ESM::Book& rec) -> sol::optional<std::string>
{
if (rec.mData.mSkillId >= 0)
return Misc::StringUtils::lowerCase(ESM::Skill::sSkillNames[rec.mData.mSkillId]);
else
return sol::nullopt;
});
}
}

View file

@ -534,33 +534,33 @@
--- Book.SKILL
-- @type BookSKILL
-- @field #number Acrobatics
-- @field #number Alchemy
-- @field #number Alteration
-- @field #number Armorer
-- @field #number Athletics
-- @field #number Axe
-- @field #number Block
-- @field #number BluntWeapon
-- @field #number Conjuration
-- @field #number Destruction
-- @field #number Enchant
-- @field #number HandToHand
-- @field #number HeavyArmor
-- @field #number Illusion
-- @field #number LightArmor
-- @field #number LongBlade
-- @field #number Marksman
-- @field #number MediumArmor
-- @field #number Mercantile
-- @field #number Mysticism
-- @field #number Restoration
-- @field #number Security
-- @field #number ShortBlade
-- @field #number Sneak
-- @field #number Spear
-- @field #number Speechcraft
-- @field #number Unarmored
-- @field #string acrobatics "acrobatics"
-- @field #string alchemy "alchemy"
-- @field #string alteration "alteration"
-- @field #string armorer "armorer"
-- @field #string athletics "athletics"
-- @field #string axe "axe"
-- @field #string block "block"
-- @field #string bluntWeapon "bluntweapon"
-- @field #string conjuration "conjuration"
-- @field #string destruction "destruction"
-- @field #string enchant "enchant"
-- @field #string handToHand "handtohand"
-- @field #string heavyArmor "heavyarmor"
-- @field #string illusion "illusion"
-- @field #string lightArmor "lightarmor"
-- @field #string longBlade "longblade"
-- @field #string marksman "marksman"
-- @field #string mediumArmor "mediumarmor"
-- @field #string mercantile "mercantile"
-- @field #string mysticism "mysticism"
-- @field #string restoration "restoration"
-- @field #string security "security"
-- @field #string shortBlade "shortblade"
-- @field #string sneak "sneak"
-- @field #string spear "spear"
-- @field #string speechcraft "speechcraft"
-- @field #string unarmored "unarmored"
--- @{#BookSKILL}
-- @field [parent=#Book] #BookSKILL SKILL
@ -582,7 +582,7 @@
-- @field #string text The text content of the book
-- @field #number weight
-- @field #number value
-- @field #number skill See @{#Book.SKILL} The skill that this book teaches
-- @field #string skill The skill that this book teaches. See @{#Book.SKILL}
-- @field #boolean isScroll
-- @field #number enchantCapacity