Lua API to get/set item condition

The current approach is a just to demo, and is for discussion. The idea is to have a quite similar interface, as in actor.stats. Example:

local itemData = types.Item.itemData(itemObject)
local itemCondition = itemData.condition --get
itemData.condition = 0 --set, make item(weapon, armor, tools) broken, or lights expire

Note: condition returns current health of weapon/armor, uses left for tools, and time left for lights before expire. Should they be separated instead?

It should be possible to move get/setSoul, get/setEnchantmentCharge into the structure. Example:

local soul_id = itemData.soul --get
itemData.soul = "skeleton" --set

"itemData", "itemStat", "stat" are possible names.

The straightforward approach, is to implement setCondition/getCondition directly. Example:

local itemCondition = types.Item.getCondition(item) --get
types.Item.setCondition(item, 0) --set

If the current logic is good, documentation will be added.

Edit: second commit changes: only self scripts can change values, and values are cached.

Edited by Kuyondo

Merge request reports

Loading