mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-01 03:21:41 +00:00
Merge branch 'lua_enchantment_charge_nil' into 'master'
Lua Use nil instead of -1 for default enchantment charge See merge request OpenMW/openmw!3845
This commit is contained in:
commit
6be6f47503
@ -1,5 +1,6 @@
|
||||
#include <sol/sol.hpp>
|
||||
|
||||
#include "../../mwmechanics/spellutil.hpp"
|
||||
#include "../../mwworld/class.hpp"
|
||||
|
||||
#include "../itemdata.hpp"
|
||||
@ -10,10 +11,16 @@ namespace MWLua
|
||||
{
|
||||
void addItemBindings(sol::table item, const Context& context)
|
||||
{
|
||||
item["getEnchantmentCharge"]
|
||||
= [](const Object& object) { return object.ptr().getCellRef().getEnchantmentCharge(); };
|
||||
item["setEnchantmentCharge"]
|
||||
= [](const GObject& object, float charge) { object.ptr().getCellRef().setEnchantmentCharge(charge); };
|
||||
item["getEnchantmentCharge"] = [](const Object& object) -> sol::optional<float> {
|
||||
float charge = object.ptr().getCellRef().getEnchantmentCharge();
|
||||
if (charge == -1)
|
||||
return sol::nullopt;
|
||||
else
|
||||
return charge;
|
||||
};
|
||||
item["setEnchantmentCharge"] = [](const GObject& object, sol::optional<float> charge) {
|
||||
object.ptr().getCellRef().setEnchantmentCharge(charge.value_or(-1));
|
||||
};
|
||||
item["isRestocking"]
|
||||
= [](const Object& object) -> bool { return object.ptr().getCellRef().getCount(false) < 0; };
|
||||
|
||||
|
@ -652,7 +652,7 @@
|
||||
-- Get this item's current enchantment charge.
|
||||
-- @function [parent=#Item] getEnchantmentCharge
|
||||
-- @param openmw.core#GameObject item
|
||||
-- @return #number The charge remaining. -1 if the enchantment has never been used, implying the charge is full. Unenchanted items will always return a value of -1.
|
||||
-- @return #number The charge remaining. `nil` if the enchantment has never been used, implying the charge is full. Unenchanted items will always return a value of `nil`.
|
||||
|
||||
---
|
||||
-- Checks if the item restocks.
|
||||
@ -665,7 +665,7 @@
|
||||
-- Set this item's enchantment charge.
|
||||
-- @function [parent=#Item] setEnchantmentCharge
|
||||
-- @param openmw.core#GameObject item
|
||||
-- @param #number charge
|
||||
-- @param #number charge Can be `nil` to reset the unused state / full
|
||||
|
||||
---
|
||||
-- Whether the object is supposed to be carriable. It is true for all items except
|
||||
|
Loading…
Reference in New Issue
Block a user