How do I Load A Boolean Variable Using WebStorage?

Get help using Construct 2

Post » Sat Jul 12, 2014 10:07 am

Hi everyone, i was wondering if anyone knew how to load a Boolean Variable Using Webstorage?

I know how to Set keys and grab them /save and load Gloabal and Instance variables,but lack the knowledge to load an actual boolean.
Is it possible to save the actual state of the boolean?
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Sat Jul 12, 2014 7:48 pm

Does anyone know how to save and load a boolean variable? im not asking for a capX or anything i just need help.I couldnt find anything on this in the manual or on google.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Sat Jul 12, 2014 7:59 pm

A boolean is just a hidden way of storing 0 or 1. You can save it, but you can't read it back in anyway, as C2 wants to set a boolean explicitly through a drop-down. You can save it directly, but to load it back you need to compare it to 1 and set the boolean again with True 'Else' False.
ImageImageImage
B
71
S
22
G
240
Posts: 3,734
Reputation: 133,994

Post » Sat Jul 12, 2014 10:02 pm

@blackhornet thank you, One thing that bothers me is im not quite sure how to set that up,there is no write up of this in the manual.I never knew we couldnt load them in the same way other variables are loaded.Do you think we will see an addon to construct adding a better way to load a boolean?

I made an equipping system based on boolean and would of never went that route if i known this info beforehand.Thanks again for the feedback blackhornet you have helped me alot over the past months,this must of been scarce info being ive gotten over one hundred views with a single reply.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Sat Jul 12, 2014 10:25 pm

This is overkill, but shows the process.

(Attachments are broken at the moment): http://blackhornettechnologies.com/cons ... leans.capx
ImageImageImage
B
71
S
22
G
240
Posts: 3,734
Reputation: 133,994

Post » Sat Jul 12, 2014 11:58 pm

@blackhornet thank you for this example,After seeing how you coded this up i realized its just alot less frustrating to make another instance variable and set everything to that,then check if its equal to 1 or 0.
Im not sure if the way booleans are handle is ment to be set up that way but it would be pretty awesome to be able to save the state of a boolean through webstorage similar to instance variables.
Thank you for showing me this,i wouldnt of found this out myself.
hopefully this thread helps some others aswell.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests