Help with my code

0 favourites
  • 9 posts
From the Asset Store
5 levels with simple coding Source-code (.c3p) + HTML5 Exported
  • Hello! I made a little bit of code today, but it doesn't work properly it only gives a nA the first

  • I think the local storage value is a string so you have to use int(localstorage.itemvalue) if cash is a number.

  • What do you mean with int(localstorage.itemvalue)?

  • Set cash to int(localstorage.itemvalue), it converts the string to an int. Did you make those events as you mentioned or did you take it from an example file?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • In your 3rd Event "On Item "Cache" missing, the second action "Set Cash to LocalStorage.ItemValue" don't has a value when Cache is missing. You can set cash directly to 1 or you start your program a second time. Then there should be an item Cache in the local storage.

  • But in the first action, I give the Cash a value or do I miss understand something?

  • You give local storage item a value but after you already checked local storage. Just set cash to 1 in the missing event. If it is showing NaN later when you grab it then refer back to the int conversion I mentioned above.

  • But in the first action, I give the Cash a value or do I miss understand something?

    You have to load the value into the ItemValue. For that you need either the event "On item exist" or the action "Get item". If you use "Get Item" after you set Cash to 1 the value will only available in ItemValue in the next Event not in the same or you use "Wait for previous actions to complete" from System. But it much easier to set the variable Cash to 1.

  • Thank you!

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