Save/Load Code, Yet Another

martix

There is no spoon
Reaction score
49
Cool tut :p Looks simpler than most of 'em.
Anyway - you still didn't answer that final question. All I see there are some dots... :p
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,497
> the initialization Inside ... random level / gold. that's the one I ment.

Oh.
Yeah, that one's definitely not needed.


> a code to save str / agil / int or learned abilities.

Learned abilities are a complete pain to save. Or load.
Though there is an example...

Players should be happy already to get a Hero back with the same level! :p


Set Save[1] = the Hero
Set Save[2] = Experience of <Hero>
Set Save[3] = Strength of <Hero>, ignoring bonuses
Set Save[4] = Agility of <Hero>, ignoring bonuses
Set Save[5] = Intelligence of <Hero>, ignoring bonuses
Set SaveCount = 5


Once it's loaded back:
Create a unit from Save[1],
set its experience to Save[2],
set its strength permanently to Save[3],
...


> that final question.

Did I miss one? Which one?
 

Effane

Save/Load Code Tutorial
Reaction score
51
You can save the learned abilities of the hero much like you would save an item in inventory that has charges.

Just search for a match in a pregenerated array of abilities, or you dont even need the array if the ability is preassigned to the hero (IE, ability 1 is always a Heal for Paladin Hero). Just takes more character slots to save (Even though there are tricks to make it take less space up, such as number compression). After the ability is matched, add an extra number at the end of the code for the level #. This will make code alot longer unless you compress it somehow.

Loading is a bit more fun and with the flexibility of Aceharts code it could get complicated to say the least.


Well very good work Acehart. Its definitly your usual great standard.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,497
> it could get complicated to say the least.

Well, like I said, I provided an example that saves abilities and their level.

Then again, this is a save / load code... which is definitely not just "copy and use"...
 

Oninuva

You can change this now in User CP.
Reaction score
221
Lol, Aceheart, A funny way to introduce something as always :)
 
I

IKilledKEnny

Guest
Wait, so what you did here is made it so you stroe information in one game and you can open it in another? If so, I didn;t understand how you opened it in the other map, thus how did you transfer the integers between 2 different maps??
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,497
Ever used or seen some "save / load" code?

Somewhen in game, you type "-save".
On screen, you'll get some weird bunch of letters, like A123-BC45-DEF6.

Next time you start that same map, you type "-load A123-BC45-DEF6".
And, whatever information was stored in that code is recreated.
 
I

IKilledKEnny

Guest
Yup, that's what I thought you did, thanks, but what I don't understand is how can you transfer information in one game to a whole other game, even if they are the same type.
 

Nestharus

o-o
Reaction score
84
Cread a base where all the information is stored. Let's say you have 10 heroes on your map.

Store those heroes use an array, let's call it Hero Array.

So we store all 10. Now when the person types save, we pick their heroes, go thru a for loop for all of the heroes we have stored and set tempinteger to forloop when the stored hero equals the picked hero.

After this, code's begin to vary. Acehart's code uses JASS to convert this unit to an integer. From there, he encodes it uses the encoder function so that people don't see the actual code and so people can't crack it very easily, then he displays it.

Many people do it differently. The code display is also based on an alphabet. The greater the alphabet, the smaller the code. Most codes generally have an alphabet of 36 characters, this way the code uses a base of 36. This means one digit in the code can hold 36 possibilities. 2 Digits can hold 36*36 possibilities.

= )

When the player is in another game and loads up the code, it takes in the code, decrypts it using the decryptor. From there, it just takes out all the information. It looks at the tempinteger we set earlier and goes to heroarray[tempinteger] and creates a hero of that type

Get it now? : )
 

Tonks

New Member
Reaction score
160
So, if I wanted to store a couple of integers (scores; wins and losses), and placed them in a multiboard when loaded, I don't understand how I could make that happen.
How, after loaded, would I derive the two integers from the code? How would I place them into the mutliboard?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,497
> after loading, would I derive the two integers from the code?

No, of course not.

If you start with, for example
Set Save[1] = 17
Set Save[2] = 25
Set Save[3] = 42

And get a code from this, then "-load" of that code will
set Save[1] to 17, Save[2] to 25 and Save[3] to 42.
 

Tonks

New Member
Reaction score
160
> after loading, would I derive the two integers from the code?

No, of course not.

If you start with, for example
Set Save[1] = 17
Set Save[2] = 25
Set Save[3] = 42

And get a code from this, then "-load" of that code will
set Save[1] to 17, Save[2] to 25 and Save[3] to 42.

So, the "-load ##LLetc" sets those variables, right?
What happens when two people set it at the same time? Or is it not MPI?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,497
Well, the "-load" trigger takes the code you typed, and restores the "Save" array from that.
Once the decoder function got back (have a look at the sample triggers), you're supposed to do something with the values you got in that "Save" array.

And, if a second player uses it?
Well, given "Save" is a global array, the second load will overwrite the values of the first.

But, given you already used the values of the first, that's no problem.

Just don't ever add any "wait" actions in the load trigger.

Triggers always run in the order their events happened.
And they also always finish their actions before a second trigger (or the same one one more time) starts to run.
Unless there is a wait action. A which point the current trigger will stop and all others that are currently waiting for some execution time will run.


You have no need to wait anyway, call the decoder, put the values you get back into your usual arrays, update the multiboard, done... nothing to worry there.
 
F

FFforce

Guest
Hi, i am trying to make a save load code based on yours. However, i cannot get a few custom scripts to work.
for eg.
Code:
function Trig_SaveLoad_Save_All_Func010A takes nothing returns nothing
    // Save the Hero
    set udg_SaveCount = ( udg_SaveCount + 1 )
    set udg_TempUnit = GetEnumUnit()
    [B]set udg_Save[udg_SaveCount] = SaveLoad_Unit2Integer( udg_TempUnit )[/B]
    // Hero Experience
    set udg_SaveCount = ( udg_SaveCount + 1 )
    set udg_Save[udg_SaveCount] = GetHeroXP(GetEnumUnit())
    // Hero Position X
    set udg_SaveCount = ( udg_SaveCount + 1 )
    set udg_Save[udg_SaveCount] = R2I(GetLocationX(GetUnitLoc(GetEnumUnit())))
    // Hero Position Y
when i tried to enable the trigger, the bold part will be said to be 'expected a name'.

I have tried to fix it to the best of my knowledge but to no avail. Any help would be appreciated.

P.S. Your save/load code rocks!
 
F

FFforce

Guest
yes i did. I even tried changing it a bit. Still does not work. for this
Code:
SaveLoad_Unit2Integer
, is that a variable?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,497
> is that a variable?

No, that's one of the functions in the custom script section (what you get when clicking on your map's name at the very top of the trigger list).

Other than that, that line expects three existing global variables:
Save, an array of type integer,
SaveCount, an integer,
TempUnit, of type unit.
 
F

FFforce

Guest
its there already. it still gives a 'expected a name' error.
 
D

dave-will

Guest
Wow thanks so much

Thank you for writing the code. I am now going to make an rpg using it. :p so yha thanks. I haven't found anything wrong with it yet.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top