Multiple Values In Instance Variable?

Get help using Construct 2

Post » Sat Oct 24, 2015 6:15 pm

is it possible to use a instance variable like Stats

and assign multiple values in it?

If so how?

maybe something like hex but with 9 4 digits with a value up 9 instead of 3 2 digits with a value 16
for example 0000111122223333444455556666777788889999
instead of 112233
B
13
S
6
G
1
Posts: 149
Reputation: 1,960

Post » Sat Oct 24, 2015 7:36 pm

I guess you can but your variable content in four parts with regexes, but an array would do the trick.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Sat Oct 24, 2015 7:57 pm

but arrays can't be instance variables
or am I wrong?
B
13
S
6
G
1
Posts: 149
Reputation: 1,960

Post » Sat Oct 24, 2015 9:04 pm

You can use a Container to add an Array to a Sprite.
ImageImageImage
B
71
S
21
G
232
Posts: 3,696
Reputation: 129,868

Post » Sat Oct 24, 2015 9:15 pm

I could possibly just convert them into text arrays and separate them with ";"
for example "1;2;3;4;5;6;7;8;9"

but I 'm not sure how

I also need to be able to locate their index
and update them as strings
and need to be able to do arithmetic on these

Maybe tokenat? but how would I write it back into the string form?
Last edited by Shadowblitz16 on Sat Oct 24, 2015 11:25 pm, edited 1 time in total.
B
13
S
6
G
1
Posts: 149
Reputation: 1,960

Post » Sat Oct 24, 2015 11:03 pm

Considering your string is "1;2;3;4;5;6;7;8;9"
You can get for example the fourth number by using tokenat(string, 3, ";") where string is your string (:D), 3 the index and ";" the separator.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Sat Oct 24, 2015 11:10 pm

Shadowblitz16 wrote:I could possibly just convert them into text arrays and separate them with ";"
for example "1;2;3;4;5;6;7;8;9"

but I 'm not sure how

I also need to be able to locate their index
and update them as strings
and need to be able to do arithmetic on these



I think BlackHornet had the best suggestion by using an array. If you cast them into string, then you are going to have to cast them back into int or Float.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Sat Oct 24, 2015 11:46 pm

wait will the array container act as a instance variable
I'm wondering for multiplayer purposes
B
13
S
6
G
1
Posts: 149
Reputation: 1,960


Return to How do I....?

Who is online

Users browsing this forum: tarek2, Yahoo [Bot] and 22 guests