I am looking for a little help in implementing an inventory system. Nothing terribly complex. I am currently storing the data on my inventory as:
<<set $Items to {
makeup_kit : {
name : "Makeup kit",
value : 20.52,
desc : "",
type : "hygiene",
slot : 0
},
camera : {
name : "Disposable Camera",
value : 20.52,
desc : "",
type : "Utility",
slot : 0
}
} >>
At the moment I am trying to insert items into my player data using push() no problem.
And my player data container looks something like::
<<set $player = {
"fname" : "First Name...",
"lname" : "Last Name...",
"age" : random(16,22),
...
inventory : []
}
>>
I know I can push and pop the additions into $player.inventory, but I am having trouble trying to use $player.inventory.find(), $player.inventory.includes(), or etc to see if something already exists so that I can try to update the quantities. Whenever I would try to use find() it always returns false. I'd like to avoid having to write a for loop each time to see if something is in the inventory as I'm not versed in writing custom macros. Could someone suggest a solution, a better implementation, or a pre-existing solution?