How do I keep the global variables'/array's values?

Get help using Construct 2

Post » Thu Feb 05, 2015 2:07 pm

@nimos100
If I save into a notepad file content like this:

Level: 12
Player: John
Controls:
jump - list key code
right - list key code
and so on

How do I tell C2 to retrieve the text in line 2 after "Player: "

I already added node webkit but I did not see an expression for something that specific, only readfile and clipboardtext

or do I need to use Regex?
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Thu Feb 05, 2015 3:06 pm

I wouldn't just store everything in a file, it would make it unnecessary complicated I think.
So only data that you can control. Meaning you know output and input so its easier to read it.

That way you can make a function that can parse the data after you have read it from the file. Here is an example that someone made of a simple parser, that I think you could use to create it. But still I would suggest that you make it so the player can only save and load between levels. And only display setting, controls etc are stored in a config file. I wouldn't store level and player name and so on.

Anyway here is the tutorial (Simple parser):
https://www.scirra.com/tutorials/757/simple-text-adventure-example
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Mon Feb 16, 2015 2:27 pm

TRY THIS:

For Saving:
Use the save action whenever you want

For Loading:
Set the first layout to the one that will load data, and make it load the game on start of layout or go to a specific layout if it fails to load (when there's no save) like this:
Cattura di schermata (23).png


Then, it will bring you to the last place you have saved, but we don't want that. So set this condition on every event sheet:
Cattura di schermata (22).png


Place that condition everywhere but not in the destination layout (for example Startscreen), or it will loop.
You do not have the required permissions to view the files attached to this post.
B
11
S
3
G
1
Posts: 91
Reputation: 997

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests