AsJSON am i doing it wrong ?

Get help using Construct 2

Post » Tue Dec 03, 2013 11:07 pm

Hi

Here i s the link

odd

Enter some text in the 3 boxes and press set

Then click save. Restart the project and click load.

I am trying to use do this

AsJSON
Save the object state to a string of data in JSON format, and return it. This can be downloaded or otherwise stored, and later the state of the object restored using the Set from JSON action.

Thanksspongehammer2013-12-04 09:20:29
B
51
S
16
G
9
Posts: 1,098
Reputation: 11,252

Post » Wed Dec 04, 2013 12:56 am

can't load your example as I lack some plugin

If you want to save it over multiple sessions, use this in combination with the webstorage object.mindfaQ2013-12-04 00:57:04
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Wed Dec 04, 2013 8:38 am

@mindfaQ

HI thanks.

I can see how that might be useful but i dont really need the complexity. I just think what i have done should work but doesnt. Which means its either a bug or i dont understand how to use it.
B
51
S
16
G
9
Posts: 1,098
Reputation: 11,252

Post » Wed Dec 04, 2013 11:41 am

Well not really sure what's going wrong since I can't open your project. But since this function is very simple, here a rundown how it would work if it is just supposed to be for one play session:

variable1 = "" (text / string)
s pressed: set variable1 = array.asjson
l pressed: array json load from string variable1

Not sure what can go wrong there except defining the variable as number instead of text.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Wed Dec 04, 2013 12:37 pm

@mindfaQ

Hi, sorry didnt realise i had used the extended textbox plugin, i have changed that now so you should be able to dl it.

I cant see anything wrong with what i am doing tbh.
B
51
S
16
G
9
Posts: 1,098
Reputation: 11,252

Post » Wed Dec 04, 2013 1:36 pm

okay, two little things:
- Set level to WebStorage.LocalValue("test")   -> the key is case-sensitive and you saved it as test, not Test
- Set from JSON string level -> level is a variable, you don't want to load the word "level" as JSON

then it works
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Wed Dec 04, 2013 2:32 pm

@mindfaQ

Altered those two things but still doesnt work. I can see the data being saved in the webstorage but it doesnt load back in. Tried 3 browsers.

Any other ideas?

Thanks for helping btw
B
51
S
16
G
9
Posts: 1,098
Reputation: 11,252

Post » Wed Dec 04, 2013 2:42 pm

For me it works:
http://s000.tinyupload.com/index.php?file_id=38420570217602548161
(tested in Chrome, Opera)

don't forget to press the set button before you savemindfaQ2013-12-04 14:42:28
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Wed Dec 04, 2013 2:49 pm

I dont believe it. Yours is identical to mine but yours works. Which version of C2 are you running ?
B
51
S
16
G
9
Posts: 1,098
Reputation: 11,252

Post » Wed Dec 04, 2013 2:51 pm

152, I guess we must use the same version if we can open each others projects. Maybe you should upload your identical, not working version, so I can see if it doesn't work for me either.mindfaQ2013-12-04 14:51:51
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Next

Return to How do I....?

Who is online

Users browsing this forum: psicodelicow3, SEGamestudio and 3 guests