1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-13 22:43:06 +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); sol::table skill(context.mLua->sol(), sol::create);
book["SKILL"] = LuaUtil::makeStrictReadOnly(skill); book["SKILL"] = LuaUtil::makeStrictReadOnly(skill);
for (int id = ESM::Skill::Block; id < ESM::Skill::Length; ++id) 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>(); const MWWorld::Store<ESM::Book>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Book>();
book["record"] = sol::overload( 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["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["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["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["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["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["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 --- Book.SKILL
-- @type BookSKILL -- @type BookSKILL
-- @field #number Acrobatics -- @field #string acrobatics "acrobatics"
-- @field #number Alchemy -- @field #string alchemy "alchemy"
-- @field #number Alteration -- @field #string alteration "alteration"
-- @field #number Armorer -- @field #string armorer "armorer"
-- @field #number Athletics -- @field #string athletics "athletics"
-- @field #number Axe -- @field #string axe "axe"
-- @field #number Block -- @field #string block "block"
-- @field #number BluntWeapon -- @field #string bluntWeapon "bluntweapon"
-- @field #number Conjuration -- @field #string conjuration "conjuration"
-- @field #number Destruction -- @field #string destruction "destruction"
-- @field #number Enchant -- @field #string enchant "enchant"
-- @field #number HandToHand -- @field #string handToHand "handtohand"
-- @field #number HeavyArmor -- @field #string heavyArmor "heavyarmor"
-- @field #number Illusion -- @field #string illusion "illusion"
-- @field #number LightArmor -- @field #string lightArmor "lightarmor"
-- @field #number LongBlade -- @field #string longBlade "longblade"
-- @field #number Marksman -- @field #string marksman "marksman"
-- @field #number MediumArmor -- @field #string mediumArmor "mediumarmor"
-- @field #number Mercantile -- @field #string mercantile "mercantile"
-- @field #number Mysticism -- @field #string mysticism "mysticism"
-- @field #number Restoration -- @field #string restoration "restoration"
-- @field #number Security -- @field #string security "security"
-- @field #number ShortBlade -- @field #string shortBlade "shortblade"
-- @field #number Sneak -- @field #string sneak "sneak"
-- @field #number Spear -- @field #string spear "spear"
-- @field #number Speechcraft -- @field #string speechcraft "speechcraft"
-- @field #number Unarmored -- @field #string unarmored "unarmored"
--- @{#BookSKILL} --- @{#BookSKILL}
-- @field [parent=#Book] #BookSKILL SKILL -- @field [parent=#Book] #BookSKILL SKILL
@ -582,7 +582,7 @@
-- @field #string text The text content of the book -- @field #string text The text content of the book
-- @field #number weight -- @field #number weight
-- @field #number value -- @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 #boolean isScroll
-- @field #number enchantCapacity -- @field #number enchantCapacity