[Solved] Save/load for two integer values.

Level 9
Joined
Dec 1, 2010
Messages
346
Hey, I'm trying to implement a save/load system for my current project. The goal is to save two integer values:

  • An integer for the player's lumber
  • A custom integer


The custom integer looks like this. the max value is 8388607 (no negatives)
  • Set VariableSet saveInt[1] = 8388607
So it's a pretty big number.

upon saving it should add the current value of saveInt[playerNumber] and the current lumber into the code and upon loading it should set the lumber and saveInt[playerNumber] variable to the values from the code.

I'm aware that there are systems like codeless save/load And others. I'm not well versed in jass. I don't need any loading related to heroes and honestly, i couldn't wrap my head around editing these systems to work for just integers. especially since my custom integer has a lot of digits.

I've been looking for easier systems to alter and found the one i added as an attachment here. However when i tried editing out the hero parts i just ended up breaking it too.

Does anyone know if there's systems around that are easier to use for my purpose?

I really just need these two integers. to be set. (and obviously the code should be player specific based on the name)

My knowledge of Jass however like i said is 0.

If anyone has some experience with using any of these systems and could point me into the right direction that would be appreciated. Or if someone knows of a system that's more similar on it's baseline to what i need.
 

Attachments

  • SaveLoadCode.w3x
    39.8 KB · Views: 2

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Someone else was asking about Codeless save/load recently:
See my first post in that thread, you can ignore most of the "How to design an MMR system" stuff. I recommend downloading the map as well as reading what I said about saving Gold and how you can repurpose that to be any Integer you want.

Also, you'll want to read the bottom posts in that thread to learn about some common pitfalls.
 
Last edited:
Level 9
Joined
Dec 1, 2010
Messages
346
Someone else was asking about Codeless save/load recently:
See my first post in that thread, you can ignore most of the "How to design an MMR system" stuff. I recommend downloading the map as well as reading what I said about saving Gold and how you can repurpose that to be any Integer you want.

Also, you'll want to read the bottom posts in that thread to learn about some common pitfalls.
oh, i saw the thread, i didn't realize it could have anything to do with save/load, (you used to have out of game mmr systems when bots were around) will take a look right away!
 
Level 9
Joined
Dec 1, 2010
Messages
346
Ok so i took a look.

  • Save Actions
    • Events
    • Conditions
    • Actions
      • -------- Save the player's Lumber --------
      • Set VariableSet SaveCount = (SaveCount + 1)
      • Set VariableSet SaveValue[SaveCount] = (SaveLoadEvent_Player Current lumber)
      • Set VariableSet SaveMaxValue[SaveCount] = 99999
      • -------- Save the player's SaveInt --------
      • Set VariableSet SaveCount = (SaveCount + 1)
      • Set VariableSet SaveValue[SaveCount] = saveInt[(Player number of SaveLoadEvent_Player)]
      • Set VariableSet SaveMaxValue[SaveCount] = 8388607
  • Load Actions
    • Events
    • Conditions
    • Actions
      • -------- !!! WARNING: YOU MUST LOAD IN THE REVERSE ORDER OF HOW YOU SAVED!!! --------
      • -------- --------
      • -------- --------
      • -------- Load the player's saveInt: --------
      • Set VariableSet SaveCount = (SaveCount + 1)
      • Set VariableSet SaveMaxValue[SaveCount] = 8388607
      • Custom script: call SaveHelper.GUILoadNext()
      • Set VariableSet SaveValue[SaveCount] = saveInt[(Player number of SaveLoadEvent_Player)]
      • Set VariableSet saveInt[(Player number of SaveLoadEvent_Player)] = SaveValue[SaveCount]
      • Game - Display to (Player group(SaveLoadEvent_Player)) for 10.00 seconds the text: (SaveInt= + (String(saveInt[(Player number of SaveLoadEvent_Player)])))
      • -------- --------
      • -------- Load the player's Lumber: --------
      • Set VariableSet SaveCount = (SaveCount + 1)
      • Set VariableSet SaveMaxValue[SaveCount] = 99999
      • Custom script: call SaveHelper.GUILoadNext()
      • Player - Set SaveLoadEvent_Player.Current lumber to SaveValue[SaveCount]
      • Game - Display to (Player group(SaveLoadEvent_Player)) for 10.00 seconds the text: (Loaded Experience: + (String(SaveValue[SaveCount])))
  • RESET Lumber
    • Events
      • Player - Player 1 (Red) types a chat message containing -reset as An exact match
    • Conditions
    • Actions
      • Player - Set Player 1 (Red).Current lumber to 0
  • increase SaveINT
    • Events
      • Player - Player 1 (Red) types a chat message containing -saveInt as An exact match
    • Conditions
    • Actions
      • Set VariableSet saveInt[(Player number of (Triggering player))] = (saveInt[(Player number of (Triggering player))] + 1)
      • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: (SaveInt= + (String(saveInt[(Player number of (Triggering player))])))
This is what i changed about the map you shared there.
It's correctly saving the lumber, however the custom variable does not seem to save.
Am i looking over something obvious? I'm a bit concerned about the size of the variable being incompatible with the system.

For testing purposes i'm just using the command i added to increase this variable.
 

Attachments

  • SaveLoadNoHeroes.w3x
    154 KB · Views: 1

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
You've made a mistake in the loading process for your saveInt:
  • Custom script: call SaveHelper.GUILoadNext()
  • Set VariableSet SaveValue[SaveCount] = saveInt[(Player number of SaveLoadEvent_Player)]
  • Set VariableSet saveInt[(Player number of SaveLoadEvent_Player)] = SaveValue[SaveCount]
You've loaded the saved value into SaveValue[SaveCount] but then you immediately overwrite this value with saveInt which is presumably set to 0 by default.

You simply want to set your own custom variable to the loaded save value:
  • Custom script: call SaveHelper.GUILoadNext()
  • Set VariableSet saveInt[(Player number of SaveLoadEvent_Player)] = SaveValue[SaveCount]
 
Level 9
Joined
Dec 1, 2010
Messages
346
You've made a mistake in the loading process for your saveInt:
  • Custom script: call SaveHelper.GUILoadNext()
  • Set VariableSet SaveValue[SaveCount] = saveInt[(Player number of SaveLoadEvent_Player)]
  • Set VariableSet saveInt[(Player number of SaveLoadEvent_Player)] = SaveValue[SaveCount]
You've loaded the saved value into SaveValue[SaveCount] but then you immediately overwrite this value with saveInt which is presumably set to 0 by default.

You simply want to set your own custom variable to the loaded save value:
  • Custom script: call SaveHelper.GUILoadNext()
  • Set VariableSet saveInt[(Player number of SaveLoadEvent_Player)] = SaveValue[SaveCount]
oh god.

I have no comment.
It works on the test map now though :peasant-neutral:.

I'll tank the embarrassment since with this my achievement system is finally working.

Thank you.

EDIT: Imported into my map. it worked (the areal shackles thing definitely helped!)

I do have one question, it still uses the same template file to store it in, will this cause issues if other maps use the same save/load system?

Edit2: Found the configuration this can be locked
 
Last edited:
Top