Lets say that there are several kinds/colors of potions that you want to keep track of.
The potions are acquired off the corpses of victims as such: You get a green potion from the corpse.
So everytime I get a green potion I want to increment greenCount, red potion redCount, yellow potion yellowCount, etc...
The long way would be something like:
if matches[2]="red" then redCount=redCount+1
elseif matches[2]="green" then greenCount=greenCount+1...
How do I simplify it such that it uses the matched color to refer to the appropriately named variable? i.e. matches[2]Count ?
Thanks!
How to use a match to reference a variable?
-
- Posts: 21
- Joined: Sun Dec 15, 2013 12:36 am
Re: How to use a match to reference a variable?
However, I would suggest putting them all in a table, like so...
-
- Posts: 21
- Joined: Sun Dec 15, 2013 12:36 am
Re: How to use a match to reference a variable?
Thanks again sir