I want to display data from an array and step through members of the array with key commands

I have one type of gunnery that does not decrement in a linear fashion.

It is my AA gunnery and it can start at any number and one hit on the AA might decrement it one or two or even three steps depending on ship.

I would like to solve this and in my mind i have an array of damage values like this [5,3,2,0]. On the first hit I want to decrement the text label by 2, then the next hit, decrement by 1 and the third hit to decrement by 1 again.

No idea how to do this. Wish it were javascript…

Open to any suggestions.

Maybe you could set up a property to record the number of hits received that can be incremented by 1 for each hit. Have another property with damage values stored as a string. Then use the number of hits property to access the correct character in the damage values string using either the charAt() method or the substring() method.

Edit: There is some discussion here: Manipulating Strings or Counting by Letters

2 Likes

That did it. I could not get the charAt() method to work so I used the substring() method and then used the hit counter and hit counter +1 as the parameters. Then in the command for the hit I decremented the counter by one each hit. Also set up a reverse of the command to add it back if you hit the key command too many times.

Below are instances of the same ship with different UI showing. The number in the red circle was what I was working on I set the string to be 742 so as I changed damage you can see the value in the red circle switch only between those numbers.

Thank you. Very successful. Appreciate the help.