Merge branch 'enchantmentproptorecord' into 'master'

Return nil for absent values in record properties (enchant)

See merge request OpenMW/openmw!4228
pull/3236/head
psi29a 6 months ago
commit 061f10bef7

@ -98,8 +98,11 @@ namespace MWLua
record["icon"] = sol::readonly_property([vfs](const ESM::Armor& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});
record["enchant"]
= sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mEnchant.serializeText(); });
record["enchant"] = sol::readonly_property([](const ESM::Armor& rec) -> sol::optional<std::string> {
if (rec.mEnchant.empty())
return sol::nullopt;
return rec.mEnchant.serializeText();
});
record["mwscript"]
= sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mScript.serializeText(); });
record["weight"] = sol::readonly_property([](const ESM::Armor& rec) -> float { return rec.mData.mWeight; });

@ -110,8 +110,11 @@ namespace MWLua
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});
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.serializeText(); });
record["enchant"] = sol::readonly_property([](const ESM::Book& rec) -> sol::optional<std::string> {
if (rec.mEnchant.empty())
return sol::nullopt;
return rec.mEnchant.serializeText();
});
record["isScroll"] = sol::readonly_property([](const ESM::Book& rec) -> bool { return rec.mData.mIsScroll; });
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; });

@ -93,8 +93,11 @@ namespace MWLua
record["icon"] = sol::readonly_property([vfs](const ESM::Clothing& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});
record["enchant"] = sol::readonly_property(
[](const ESM::Clothing& rec) -> std::string { return rec.mEnchant.serializeText(); });
record["enchant"] = sol::readonly_property([](const ESM::Clothing& rec) -> sol::optional<std::string> {
if (rec.mEnchant.empty())
return sol::nullopt;
return rec.mEnchant.serializeText();
});
record["mwscript"] = sol::readonly_property(
[](const ESM::Clothing& rec) -> std::string { return rec.mScript.serializeText(); });
record["weight"] = sol::readonly_property([](const ESM::Clothing& rec) -> float { return rec.mData.mWeight; });

@ -131,8 +131,11 @@ namespace MWLua
record["icon"] = sol::readonly_property([vfs](const ESM::Weapon& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});
record["enchant"] = sol::readonly_property(
[](const ESM::Weapon& rec) -> std::string { return rec.mEnchant.serializeText(); });
record["enchant"] = sol::readonly_property([](const ESM::Weapon& rec) -> sol::optional<std::string> {
if (rec.mEnchant.empty())
return sol::nullopt;
return rec.mEnchant.serializeText();
});
record["mwscript"]
= sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mScript.serializeText(); });
record["isMagical"] = sol::readonly_property(

@ -1329,7 +1329,7 @@
-- @field #string model VFS path to the model
-- @field #string mwscript MWScript on this armor (can be empty)
-- @field #string icon VFS path to the icon
-- @field #string enchant The enchantment ID of this armor (can be empty)
-- @field #string enchant The enchantment ID of this armor (can be nil)
-- @field #number weight
-- @field #number value
-- @field #number type See @{#Armor.TYPE}
@ -1418,7 +1418,7 @@
-- @field #string model VFS path to the model
-- @field #string mwscript MWScript on this book (can be empty)
-- @field #string icon VFS path to the icon
-- @field #string enchant The enchantment ID of this book (can be empty)
-- @field #string enchant The enchantment ID of this book (can be nil)
-- @field #string text The text content of the book
-- @field #number weight
-- @field #number value
@ -1496,7 +1496,7 @@
-- @field #string model VFS path to the model
-- @field #string mwscript MWScript on this clothing (can be empty)
-- @field #string icon VFS path to the icon
-- @field #string enchant The enchantment ID of this clothing (can be empty)
-- @field #string enchant The enchantment ID of this clothing (can be nil)
-- @field #number weight
-- @field #number value
-- @field #number type See @{#Clothing.TYPE}
@ -1821,7 +1821,7 @@
-- @field #string model VFS path to the model
-- @field #string mwscript MWScript on this weapon (can be empty)
-- @field #string icon VFS path to the icon
-- @field #string enchant
-- @field #string enchant The enchantment ID of this weapon (can be nil)
-- @field #boolean isMagical
-- @field #boolean isSilver
-- @field #number weight

Loading…
Cancel
Save