saving levels, again

Get help using Construct 2

Post » Fri Sep 06, 2013 8:15 pm

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:

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.

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!
Posts: 2
Reputation: 279

Post » Mon Sep 09, 2013 11:14 am

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.

Posts: 2
Reputation: 279

Post » Mon Sep 09, 2013 11:53 am

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

The "chosenPath" you're using only returns the path, not the file the user picked.
Posts: 857
Reputation: 28,485

Return to How do I....?

Who is online

Users browsing this forum: ChenBr and 4 guests