Access NWjs object methods from JavaScript?

0 favourites
  • 3 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I'm trying to write a set of unified methods to handle save data using either LocalStorage (for preview and a possible web release) or NWjs (for the desktop release). I'm having trouble getting the former to work, and I wonder if it's because LocalStorage is async while NWjs uses synchronous read/writes.

    Anyway, I'd like to write a JS method to call the correct storage handler internally in one method. Is it possible to access the NWjs object type and its methods (specifically create folder, write to file, and ReadFile) from the JS API? I examined runtime.objects.NWjs.getFirstInstance() and didn't find anything helpful on there.

    Edit: I know I can just make a C3 function that returns the value of NWjs.ReadFile() and call that from JS. I just wonder if there's a more direct approach.

    Edit 2: While I'm asking API questions, can I check the "System | Is in preview" property from JS too?

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The NW.js object is just a wrapper around the NW.js JavaScript API. So there's no point in the Construct object providing a script interface for it. You can just call the NW.js JavaScript APIs directly.

  • Ah, thank you! Good to know.

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