# How do I know whether a value of an array is string or int?

Get help using Construct 2

### » Tue Dec 30, 2014 8:27 am

so, imagine an RPG where you have healers that can restore a certain amount of HP, give a positive effect to your party members (attack up, speed up, defense up, etc.), or restore a negative effect (cures poison, paralisys, or confusion).

I'm storing the skills in an array with the X row as the name, Y row as the target (single member, or all party members), and Z row as the effect. If the Z row is an int then I'll calculate the number of HP restored using a math formula, but if the Z row is a string then I'll do something based on it (whether raising stats or restoring negative effects)

what I don't understand is how do I know whether the value I retrieve from an array is an int or a string?
so maybe if I'm checking the value like this

Code: Select all
`    allSkills Value at (1, 1, 1) = isInt | (add action)`

in javascript we can do typeOf but I'm not sure how C2 does this
any suggestions would be appreciated, thanks.
B
45
S
13
G
2
Posts: 173
Reputation: 5,331

### » Tue Dec 30, 2014 8:46 am

You could check if int(Array.At(1, 1, 1)) > 0 then it's a number, as long as you don't have string values like "42", that are string representations of numbers..
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

### » Tue Dec 30, 2014 9:06 am

I don't have a string valued numbers, so it's safe. I just checked the manual and came up with the same solution. Thanks.
B
45
S
13
G
2
Posts: 173
Reputation: 5,331