saving levels, again

0 favourites
  • 3 posts
From the Asset Store
Match the similar cards with each other and free all animals!
  • Hi all,

    I know that this topic has come up multiple times, but I'm having trouble with it in my app:

    I've worked out a simple enough level editor for my puzzle game idea. So far I've had no issues saving, using a dictionary that writes out JSON through the NodeWebkit object. I look at the JSON and it tracks.

    However, I can't for the life of me get the AJAX object to not error when loading the file back in. I should be able to, while previewing in Node-Webkit, load an arbitrary file, right? Here's how the logic looks:

    <img src="http://www.komakant.com/construct2_post_images/file_save1.PNG" border="0" />

    Which calls this function, where Param(0) is the JSON string, Param(1) is the offset in X, Param(2) is offset in Y. The offsets are there because I haven't figured out a simple way to save arrays of objects; instead, I'm using a "pointer" object, moving it to a position on the screen, and then subtracting the offset to determine which tile the X/Y coordinate is choosing. If that's confusing, imagine the tiles start from 0,0 and that the offsets are 0.

    <img src="http://www.komakant.com/construct2_post_images/file_save2.PNG" border="0" />

    So, I added a text object to debug, and I'm finding that the NodeWebkit object's ChosenPath is coming back empty after picking the file I saved out. Either that, or something is erroring along the way. What am I doing wrong here?

    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
  • Okay so to answer my own question:

    AJAX can only load program files and remote "web pages." So it appears that, at least from within Construct, you can write a program that saves out JSON to an arbitrary folder and then not be able to load that file back in.

    Could a developer weigh in: with the Node-Webkit browser that comes inside Construct, can't the NodeWebkit object itself do direct non-asynchronous loads, allowing the user to treat it like AJAX that returns immediately on systems that support this, like the desktop? I mean, why even have the ability to show an open file browser window if that file can't be loaded by the system? Or am I totally just missing an obscure setting on some object that would allow me to set security for local files only? Is it a pro feature? If so I can pay up.

    Thanks!

  • I think you're using the AJAX request wrong, it should say something like this:

    <img src="http://i.imgur.com/J7lfSMn.png" border="0" />

    The "chosenPath" you're using only returns the path, not the file the user picked.

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