How do I.. Trouble with Local Key

0 favourites
  • 9 posts
From the Asset Store
Random Maze Generator with Door & Key System - tutorial capx
  • Morning all guys!

    Sorry to bother, but has been 3 days I'm dealing with a problem I cannot figure out.

    Here what I'm doing: a slot-machine with a splash-intro. The slot-machine is ok.. There is a variable (money) connected to a local webstorage key (moneysave) who saves everything in the cookies. The problem is in the splash.

    There's a text box, where I show the string "WebStorage.LocalValue("moneysave") so it shows the amount of chips I've.

    THE PROBLEM IS ON THE CREATION OF A BUTTON WHO'S ADDING money to that value.

    I tried several ways to do it, but some are adding strange values, other not working at all. Obviously the new value has to be saved in the same local webstorage.

    Do you have any suggestion?

    I'm sure it's simple, but I cannot figure out.

    Cannot sleep. Lol.. Thank guys!

  • What do you mean by adding strange values? Maybe your event is firing multiple times per click?

  • Thanks for the answer! Unlucky no. To be sure of it, i've set the button to disappear after 1 single tap.

    For example, I want to add the value 2000 to 1736. I've, as result 4000, sometimes 6000, etc etc, but never the correct value. It's driving me crazy!

  • Please share your capx or at least a screenshot of your event sheet, without it we can only guess..

  • Ya, sorry!

    So, first image is the working part - Just to show you SETTING_START_CREDITS, the value of my money, and the session key "Chips" where I save everything. Here everything is working and done.

    Here there is the part with troubles. (see the rectangles). Quiet simple.. want to add value "2000" to the amount of money, then save it automatically. But the result is just 2000, without the Chips I alread got!

  • I'm not sure but are you setting the global variable SETTING_START_CREDITS to the webstorage value anywhere?

    If not, SETTING_START_CREDITS - 0 at start of layout, so adding 2000 will make it 2000 which you then save to webstorage..

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Also I see you are using session key and local key for the webstorage

    The textobject is set to local value, while you are saving to session value..

  • Ya, what the hell.

    Seen it and correct!

    Now it's working properly!

    Thanks a lot guys, much appreciated!

  • Moreover In your event 12 the "Add to action", you are actually adding the string value of 2000, not the the numeric value.

    Don't use quotes when dealing with numbers.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)