How do I save system time to a file, NW.js

Get help using Construct 2

Post » Thu Sep 01, 2016 10:01 am

Okay so I have a save function on my game, it saves the game and then writes the SaveStateJSON to file; you can then load the save from the Main Menu or In-Game. I want to get it so that when you hover over the Load Last Save button from within the Main Menu a piece of text will become visible, of which it displays the system Time and Date of the save.

I can get the hover function working myself, I'm just at a stand still with how to save the system Time and Date to a file that the game could read from the Main Menu without loading the full save file.

Any help would be greatly appreciated, thanks!
----------

If you need a hand with anything, just drop me a PM.
B
8
S
2
Posts: 29
Reputation: 560

Post » Sat Sep 03, 2016 4:56 am

On NW.js, you could write/read this information to another file yourself, using the NodeWebkit's functionalities:


Action:

Write file
Write a text file to the user's local system. If the file does not exist, it is created. If the file already exists, its content is overwritten.

Expression:

ReadFile(path)
Open the given file and return its text content as a string. Note that each time this expression is used the file is opened and read from disk. Therefore if the expression is used twice, the file is opened and read twice, which can impact performance. If necessary first read the file to a variable, then reference the variable multiple times.



Alternatively, I believe you could also write/read such data using LocalStorage: https://www.scirra.com/manual/188/local-storage

For the system time, you may need to use this: plugin-system-date-and-time_t63492
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Mon Sep 05, 2016 1:05 pm

Thanks, this is by far the most helpful answer I've been given. :)
----------

If you need a hand with anything, just drop me a PM.
B
8
S
2
Posts: 29
Reputation: 560


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 11 guests