How do I save blocks to an array then to a file [Fixed]

Get help using Construct 2

Post » Wed Jan 25, 2017 6:46 pm

Hey :!:

I am trying to make a level editor were you can save the map, to a json file then loaded it back from that file to be played normally. Like mario maker.

I have seen some other post just like this one but I keep getting stuck and their old so I thought it would be better to start a new post.

So far I have got it to save all the block locations but the only block which saves the right position is the last one, all the others are 1,1.
I also have made it to be able to read the file then place the blocks in the right place(Thats how I knew it wasn't saving the array right).


Thanks in advance :)
Last edited by Ben Wilson on Thu Jan 26, 2017 11:16 am, edited 3 times in total.
B
8
S
2
Posts: 22
Reputation: 606

Post » Wed Jan 25, 2017 6:52 pm

Please provide a new download link/URL, it doesn't appear to work.

However there is one reason why it could be saving just one block, you need to do the saving action for each block objects, so a for each loop needs to be used. This is usually the case when an action is done just for one object correctly in an event, and what you are describing basically requires the use of a for each loop.
B
15
S
6
Posts: 85
Reputation: 1,195

Post » Thu Jan 26, 2017 9:10 am

Message: Ben Wilson can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Pulstar wrote:Please provide a new download link/URL, it doesn't appear to work.

However there is one reason why it could be saving just one block, you need to do the saving action for each block objects, so a for each loop needs to be used. This is usually the case when an action is done just for one object correctly in an event, and what you are describing basically requires the use of a for each loop.


I have updated the download link. (https://www.dropbox.com/home?preview=Sa ... arrays.rar)

I have currently used a for each block loop, and its creating the right amount of data in the table, it's just not storing the right numbers in the array.

Also I would add screen shots, but I am not sure how to add them to the scirra forums, do I have to upload them some where else and link it?
B
8
S
2
Posts: 22
Reputation: 606

Post » Thu Jan 26, 2017 9:21 am

The link still is not valid/complete.
There is a "shortage" around the name (where there are the ...).
Post a complete link if you want others to see your project.

And yes, screenshots need to be uploaded on a distant service and linked in the post using :
Code: Select all
[img]LinkToImage[/img]
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,317
Reputation: 87,483

Post » Thu Jan 26, 2017 10:49 am

Kyatric wrote:The link still is not valid/complete.
There is a "shortage" around the name (where there are the ...).
Post a complete link if you want others to see your project.

And yes, screenshots need to be uploaded on a distant service and linked in the post using :
Code: Select all
[img]LinkToImage[/img]


Yeah, reread the link and its been cut.

But I have managed to fix it.
I miss under stood the function of push in the array. I thought where it says value is how many you want it to push, but its the value to go in the one you have pushed.

Thanks
B
8
S
2
Posts: 22
Reputation: 606


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Google [Bot], tarek2 and 10 guests