# How do I make a number list

Get help using Construct 2

### » Mon Aug 10, 2015 7:25 pm

Ok so basically I'm trying to make a kind of DNA for sprites where 1=up, 2=left etc... Is there anyway I could make a list or something similar and go through it one at a time to control which was the sprite moves?
Example: 1,3,1,2,4,3,2,1
Sprite would move: Up, down, up, left, right, down, left, up

How could I do something like that? Or is it not possible with construct 2?
B
27
S
12
Posts: 222
Reputation: 2,624

### » Mon Aug 10, 2015 8:32 pm

my first thought is to use tokenat

from the manual -

tokenat(src, index, separator)
Return the Nth token from src, splitting the string by separator. For example, tokenat("apples|oranges|bananas", 1, "|") returns oranges.

you could also look at arrays.

If you have not had a better answer when I check later I will try to put a capx together for you
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,902

### » Tue Aug 11, 2015 6:18 am

B
21
S
8
G
6
Posts: 181
Reputation: 8,142

### » Tue Aug 11, 2015 9:41 am

Although you have already had a capx from @mrcgkh I will post this as I have spent a bit of time on it and think it is worth pursuing...

This i what i came up with - not quite what you asked for

instead of "l,r,u,d" or "1,2,3,4" I went for x,y#x,y ie the change in x and the change in y which will allow for diagonal movement so to move left 3 times left (then back) it would look like "-1,0#-1,0#-1,0#1,0#1,0#1,0" the number represents the number of pixels per step . so "-10,10 would move the sprite - 10 pixels in x and plus 10 pixels in y.

I included a timer so the same "movement string" can run at different speeds.

https://db.tt/AJB1ZmkY

let us know how you get on ?
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,902

### » Wed Aug 12, 2015 3:28 am

Thank you both, I'll try them tomorrow and see how they work I appreciate how quickly you replied and put something together
B
27
S
12
Posts: 222
Reputation: 2,624