Saving each instances to a form of data?

Get help using Construct 2

Post » Sat Jan 21, 2012 9:29 pm

Hi guys me again . Im trying to make a advanced level editor kinda thing to share with the community.

Basically I need to know how to save each instance to a string or something so i can then send the data to my server and retrieve it on command :).

So is there a way to convert each instance into one whole piece of data?
B
7
S
1
G
1
Posts: 32
Reputation: 881

Post » Sat Jan 21, 2012 9:59 pm

loop through them and build some string like
[code]foreach Sprite
set save to save&sprite.X&","&Sprite.Y&","&Sprite.Angle&","&Sprite.AnimationFrame&","&Sprite.instancVar1&newline[/code]

It's a bit like the replay thing I did a while ago
Yann2012-01-21 21:59:29
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sat Jan 21, 2012 10:28 pm

@Yann, Yeah i had a look at that thread, Very informative. But you used tokenat() right?

So lets break this down

I need a global var called text, its a string. I get that,

I get most of the second line aswell except: "&Sprite.instancVar1 what is instanceBar1?
B
7
S
1
G
1
Posts: 32
Reputation: 881

Post » Sat Jan 21, 2012 10:38 pm

Whatever instance variable you feel like saving @FlashDeveloper.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Sat Jan 21, 2012 10:46 pm

Oooooooh I see [:0] Thanks guys!
B
7
S
1
G
1
Posts: 32
Reputation: 881

Post » Sat Jan 21, 2012 11:17 pm

tokenat let you retrieve each part of the string. you can locate a part (token) thanks to an index and a separtator.
In our example, each object can be retrived thanks to the 'newline' separator
And each data of an object (once you retrieve the line) thanks to the "," separator.Yann2012-01-21 23:17:46
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 31 guests