Save/Load Code, Yet Another

martix

There is no spoon
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
> 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
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
> 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"...
 
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
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.
 
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
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
> 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
> 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
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
> 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.
  • Ghan Ghan:
    Kind of surprised it wouldn't have its own forum product offering.
  • Ghan Ghan:
    That said, when Blizzard switched forum software, they went with Discourse, not xenForo.
  • jonas jonas:
    I think news.google shows you personalized news
  • midnight8 midnight8:
    any of the peeps in here run youtube channels? Figure of all the peeps in this forum, got to be some other geeks like me with channels
  • Ghan Ghan:
    I can say I've uploaded a YouTube video.
    +1
  • The Helper The Helper:
    I can say I know someone that uploaded a youtube video :)
  • jonas jonas:
    A friend of mine has a channel where he uploads some of the crazy machines he has built. Like when he plugged an electric motor into a 3d printed gearbox, attached it to his bycicle and then drove 50mph with it.
  • The Helper The Helper:
    You should post a link to his channel in General Discussion I would definitely check it out
  • The Helper The Helper:
    how hard is it to put google analytics on the site?
  • Ghan Ghan:
    Likely not hard. I think we've done it in the past. Anything in particular you want to see?
  • The Helper The Helper:
    I remember we are already getting stats
  • The Helper The Helper:
    I watch the members online area of the site to see what is being viewed from the past and let me tell you there are some gems I am finding in there
  • jonas jonas:
    you could tell us the gems
  • The Helper The Helper:
    I am trying to bump the gems when I find them
    +1
  • The Helper The Helper:
    look at the whats new section
  • The Helper The Helper:
    there is not much static in the last posts on the forum
  • The Helper The Helper:
    I think Tom Mai got sick of the news :(
  • Ghan Ghan:
    Hopefully he'll be back.
  • Ghan Ghan:
    Probably should renew support on our xenForo license one of these days....
  • The Helper The Helper:
    we can do that how much is it?
  • The Helper The Helper:
    55 bucks ask google lol
  • The Helper The Helper:
    donate link is gone there should be one
  • Ghan Ghan:
    Added
  • Ghan Ghan:
    xenForo license is paid through 2022.

    Members online

    No members online now.

    Affiliates

    Hive Workshop NUON Dome
    Top