[SOLVED] Issue with saving new max value for XP

Im saving the current value of XP in a storage and its fine… But when the max value for XP is changed by an event the new max value doesnt save and when i get back to the game its stack at the point where the XP bar is full and the “level up” menu is shown… When the menu is closed the max value updates but simply doesnt save?



When you save the xp to storage, save both the value and the max value. When you read the xp, read and set both the value and the max value.

What is happening is when the scene starts, the xp object has the default max value, not the one that was achieved previously. The xp value may well be more than the default value, which is why the level up menu is shown.

Im not sure if thats the right way to do it… What did i do wrong? :confused:


Using “xp1” + MaxValue is wrong. You need to use “XP1” + xp.ID.

  1. When you save MaxValue(), write it to "xp1" + xp.VariableString(ID). Using MaxValue is pointless, because, as explained above, when you read the data you won’t know what the MaxValue is until you’ve read it. And you can’t read it because you don’t know what it is.
    image

  1. When you read use ID as the identifier, not xp.MaxValue()

Still not working or i didnt understand corectly… :confused:


You’re reading max value, but setting value. You need to change the maxvalue of xp, not set the value of xp

Now it works…Kinda… When i close the game and get back to it, it adds 5 to xp maxvalue

Of course, because you are adding the value you just read, rather that setting it.

Now everything looks good! Thank you for your help :slight_smile: