Hi, just to clarify things, I am using Harlowe. The question I want to ask is a bit of a complicated one.
It's easiest for me if I just start at the beginning and work towards my question.
I am making a game where you collect Characters and use them to battle others. You can get multiple of the same character What I want to happen is when you lose a battle, you lose the character that you were using. Lets say I had a mummy, a vampire, and 2 ghosts. I want to fight the werewolf using the ghost. I have figured out that part of the code. I just set the variable $character to "Ghost". However, if I lose, I want to be able to make the code to where I lose just one of the ghosts. What I did was every time I obtained a new ghost, the variable $ghost would go up by one. What I want is when I lose a battle, for the variable $ghost to go down. It's pretty tricky because if I was using the vampire, then I would have to have the variable $vampire go down. So what I did was when I wanted to use the ghost, I would click on a button that would bring me to a page that would do the following: (set: $character to $ghost). When I lose a battle, I did: (set: $character to $character - 1). I thought that since I set $character to $ghost, $ghost would decrease by 1. But all it does is decrease $character by 1. The only other way I could think was do this:
(if: $character is $ghost)[ (set: $ghost to $ghost - 1)]
(elseif: $character is $vampire[ ( set: $vampire to $vampire - 1]
ect. ect.
However that would be extremely long and tedious since I plan to have over fifty characters when this is done. Is there a simpler way to do it? Thanks for your help.
Comments
StoryInit:
Then when you fight you say $player_ix to the ix value of the character they are using.
If they loose:
There is more complex structure using an array of structures you could consider:
Referencing the values is a little more complex:
The advantage is that you can put other attributes for the monsters into the data structure - which is easier that trying to maintain multiple cross matched arrays.
You can also do:
which makes $monster point to the index monster structure so you can reference it's values directly:
(Samples are indicative and have not been tested.)