How do I Copy an array

Get help using Construct 2

Post » Tue Jun 13, 2017 1:32 am

I tried searching the forums for this but all references are to the webstorage plugin that no longer exists

I have an inventory system for a ship which is based off of an array, what i want to be able to do is have it so that the player can change ships. Because of the way i want to do it i want to have an active inventory array and a storage inventory array, i thought i could swap the data between the arrays by exporting to and then importing json files but that seems like it is no longer possible.

Is there another way i can easily copy all the data from one array to another?
B
23
S
11
G
4
Posts: 69
Reputation: 3,439

Post » Tue Jun 13, 2017 2:21 am

Use Array2.Load(Array1.AsJSON).
You don't need storage to do this.
ImageImageImage
B
71
S
21
G
220
Posts: 3,646
Reputation: 123,721

Post » Tue Jun 13, 2017 3:45 am

how do i save the array tho?

i basically want to be able to hit a button in game and swap the contents of the two arrays in game.

so there is an inventory array and a stored array and i want the contents of inventory to go to stored and stored to go to inventory.
B
23
S
11
G
4
Posts: 69
Reputation: 3,439

Post » Tue Jun 13, 2017 4:08 am

Just store the AsJSON data of Array2 to a Text variable, Load Array2, then Load Array1 with the variable.
ImageImageImage
B
71
S
21
G
220
Posts: 3,646
Reputation: 123,721

Post » Tue Jun 13, 2017 5:55 am

dont suppose you wanna give me a capx example? purdy please? :)
B
23
S
11
G
4
Posts: 69
Reputation: 3,439

Post » Tue Jun 13, 2017 8:24 am

Nevermind got it to work ;) thanks man that was easy
B
23
S
11
G
4
Posts: 69
Reputation: 3,439

Post » Tue Jun 13, 2017 8:27 am

can anyone help me to solve errors in my game.
Banned User
B
3
Posts: 13
Reputation: 205

Post » Tue Jun 13, 2017 9:49 am

saravanakumar wrote:can anyone help me to solve errors in my game.


What errors?
B
23
S
11
G
4
Posts: 69
Reputation: 3,439

Post » Tue Jun 13, 2017 10:30 am

already posted in how do i forum bro.you can see there.thank u for ur valid replay
Banned User
B
3
Posts: 13
Reputation: 205

Post » Tue Jun 13, 2017 10:41 am

saravanakumar wrote:already posted in how do i forum bro.you can see there.thank u for ur valid replay


@saravanakumar

Please stop this hijacking of other users threads for your own problems. This is likely to get you a temporary ban if you don't stop.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
131
S
29
G
81
Posts: 5,328
Reputation: 56,630

Next

Return to How do I....?

Who is online

Users browsing this forum: jaytrott86, Yahoo [Bot] and 6 guests