Copy an entire array

0 favourites
  • 7 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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")

  • Oh my god. Wonderful. I'll try it now.

  • IT WORKS! Thanks! First It didn't work, but adding AJAX to the project, It worked perfectly.

  • THANKS for this posts! Works great!

  • 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.

  • Hey guys, sorry for the Necromancy but any existing CAPX for this ?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)