Harlowe 3.2.2
I’m making an RPG game, and attempting to add a durability system. After thinking of a few ways I could implement this, I decided to start using arrays. For example
You mercilessly slaughter the ants, and pocket their corpses.
(set: $sdb to it-(a:“1”))
(set: $ant to $ant + (a:“1”,“1”,“1”,“1”,“1”,“1”,“1”,“1”,“1”,“1”))
(if: $sdb’s length > 0)[(set: $wep to it - (a:“wooden stick”))]
(else:)[You sniff out more ants. They make easy prey.]
You have (print: $ant’s length) ant corpses.
(if: $wep’s length > 0)[[[Kill More|Y]]]
(else:)[[[Kill More|broken stick]]]
[[Leave]]
This is the code I’m having issues with. Undoubtedly, it requires some explanation. I have an array set up, that is called “$sdb” (stick durability). This array has 5 different items in it, all of which are just "1"s. Basically, there are 5 different 1’s in this array, acting as different durability. In this code, each time the paragraph loads, it’s supposed to remove a 1 from the array.
There’s a second array, called “$wep” (weapons). This is just an array used for storage of the stick.
The line of code -
(if: $sdb’s length > 0)[(set: $wep to it - (a:“wooden stick”))]
is meant so that when all of the durability points are taking from the $sdb array, the stick will automatically be removed from its array.
Finally, when you run out of durability and no longer have a weapon, the “kill more” button will instead take you to another paragraph, which informs you that your weapon has broken. This, however, is not the case. I’ve been looking at the code for a decent amount of time now, and can’t seem to actually find what’s wrong with it. Could anyone help tell me what the actual problem is? That alone would help tremendously. Furthermore, if anyone has the actual code i could use instead, it would be appreciated. If anyone has an alternative method to the “array durability” method im attempting to use, feel free to share it. Thank you.