Copy an entire array

Get help using Construct 2

Post » Sat Jun 09, 2012 4:23 pm

Hello guys.

Since last time I wrote here, my project has advanced a lot. Now I have a problem trying to make save games with this method. I have few local variables because I use a 10x10 array. I've tried to save it as Haematite says in that example, but It seems not to load correctly.

I have an object in HUD layer whose width depends on an array value. Same with weapon duration. When the game loads the "variables" stored in the array don't work. That two are only few examples of the problem, and I was wondering if is there another method for doing this copy.

Thanks in advance.
B
10
S
3
G
5
Posts: 7
Reputation: 4,237

Post » Sat Jun 09, 2012 4:40 pm

That thread was written before you could convert arrays to JSON strings. Now it's simply:
WebStorage -> Set local key "savedArray" to array.AsJSON
and to load:
Array -> Load from JSON string WebStorage.LocalValue("savedArray")
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990

Post » Sat Jun 09, 2012 4:42 pm

Oh my god. Wonderful. I'll try it now.
B
10
S
3
G
5
Posts: 7
Reputation: 4,237

Post » Sat Jun 09, 2012 5:10 pm

IT WORKS! Thanks! First It didn't work, but adding AJAX to the project, It worked perfectly.
B
10
S
3
G
5
Posts: 7
Reputation: 4,237

Post » Tue Oct 09, 2012 10:05 am

THANKS for this posts! Works great!
B
43
S
14
G
8
Posts: 47
Reputation: 7,556

Post » Wed Apr 06, 2016 3:19 pm

I see this is an antique post but maybe it well get bumped if I ask here first since it came up in my search.

Context:
I am using Construct 2 as a mean to create an app for neuro-psychological testing. It's a precious tool for somebody not knowing how to program enough to write an app of this complexity, but it has one major flaw for my purpose, which is that it is cumbersome to store variables an retrieve their values in a file outside of the app for further analysis.
I stumbled on the Array-> Json download function. It isn't perfect but it does the trick, at least on Desktop systems where the command opens a "Save as" Dialog and I can save a .json string as a textfile which i can then convert to CSV for further treatment.

The issue:
For many reasons beyond my will or control, my app is primarily designed to run on Ipads, not tablets in general, but Ipads. When I test my app on Ipad through Adobe phonegap, the "Download Link" Link is being shown and when i click the button designed to trigger the "Download Array as .json" action, it directly shows me the contents of the string on screen, in the app window.
What I want is for it to open a dialog like on desktop asking me where to save the file.

My first step was to ask our local IOS developer for advice. She said that if I could find the part of the code that contains the event, she could adapt it in order for the Ipad to open said Dialog instead of showing it in the window. While searching through the code files we couldn't locate any reference to the button or the array though (the code was NOT minified).
My question is, in which file and under what format/language is the actual logic/event files/script stored during export (I used a cordova export function)? Is the code always automatically obfuscated or does it contain the names of strings and variables used in the construct editor? Where should I look for this?

This is probably a question for the devs but someone might have had the same issue before and knows something about Construct's inner magic :)

Thank you very much for your time! I will provide a mock .capx wit only the layout concerned by the download function if you think it would be useful, but the question is more general.
B
3
Posts: 6
Reputation: 194


Return to How do I....?

Who is online

Users browsing this forum: michaelverdi and 29 guests