How do I load from a .Json?

Get help using Construct 2

Post » Thu Mar 09, 2017 11:02 am

I have made and saved a Dictionary of variables.

I want to be able to load those Variables back in on the press of a button to fill in text boxes (the variables that are being saved are custom entries to a card game in text boxes).

How is the simplest way to do this?

Thanks,

All advice appreciated.
B
5
S
1
Posts: 65
Reputation: 507

Post » Sat Mar 11, 2017 8:17 pm

ErudioLtd wrote:I have made and saved a Dictionary of variables.

I want to be able to load those Variables back in on the press of a button to fill in text boxes (the variables that are being saved are custom entries to a card game in text boxes).

How is the simplest way to do this?

Thanks,

All advice appreciated.


have you tried this?
https://www.scirra.com/tutorials/978/ex ... -game-card
B
11
S
6
G
3
Posts: 249
Reputation: 3,152

Post » Sun Mar 12, 2017 6:45 pm

Did you export it using the Dictionary toJson?
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,415
Reputation: 4,824


Post » Mon Mar 13, 2017 11:04 am

Lordshiva1948 wrote:try this tutorial

https://www.scirra.com/tutorials/1418/trivia-game



This seem essentially what I want to be doing. Is there a way to save variables out as a .txt? or do .Json files save in the same fashion?

(Just because this tutorial is pulling things that i have predetermined, I want the player to be able to save a set of variables out and then load them)

Thanks for all the advice
B
5
S
1
Posts: 65
Reputation: 507

Post » Mon Mar 13, 2017 11:36 am

gumshoe2029 wrote:Did you export it using the Dictionary toJson?



Yes. I am filling the dictionary with a string of variables (Which it is recognizing and formatting properly) but i am unsure how to then load the variables back into construct (e.g to fill a text box).

I have attempted to use the load action to Load the saved .Json and then use a

On button press set "Custom1" Global variable to "Dictionary.Get("Custom1")

But it doesn't seem to do anything.
B
5
S
1
Posts: 65
Reputation: 507

Post » Tue Mar 14, 2017 1:31 pm

Try outputting the Dictionary asJson in a Text object, then you will be able to see the JSON structure and more easily determine where the issue is.

However, I would highly recommend looking at @Yann 's JSON plugin. It is far better than the Dictionary object.
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,415
Reputation: 4,824


Return to How do I....?

Who is online

Users browsing this forum: jorgmaquoi, SignalOne and 17 guests