Save/Load Code, Yet Another

X

xflip04

Guest
Wow I have been looking for an easy understanding save load code for ever this is awesome!

1 question though how can I add an account name specific code so someone cant take another persons code?
 

Steel

Software Engineer
Reaction score
109
It is a wonderful system, but I must say it uses a lot of globals...I understand this is done because it wasn't written for the advanced mappers that understand the ins and outs of JASS, but rather those people who want a save / load system that can be easily changed and formatted to their liking in the GUI.

Flip, he has a variable SaveLoad_UsePlayerName. This is what you want.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,492
The initialization trigger has a line that says: "Set SaveLoad_UsePlayername = True".
If that variable is true, and it is by default, the player's name will be part of the code.



> ... a lot of globals...
> ... can be easily changed and formatted to their liking in the GUI.

Well, :p
 
Reaction score
454
Great :D !

>(Substring((Entered chat string), 1, 6)) Equal to (Matched chat string)
>(Length of (Entered chat string)) Greater than 6

Does that really need both of them?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,492
> Does that really need both of them?

Preferably, yes.


Imagine some in-game chat:

- hey, how do I use that save thing?
- easy, type -load and you're done (condition 1)
- K
- -load (condition 2)
- don't work, what now?
- well, you were supposed to add the code after "-load"... (condition 1)
 
X

xflip04

Guest
Ok I see it now cool, if I were to add all lower case to the alphabet trigger as well, to make the code more random would that be hard? =P
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,492
Code generation is deterministic.
It doesn't get more random if you use more characters...

But, like said somehwere in post #1, if you add both lower and upper case characters:
- the code might be shorter
- you must "Set SaveLoad_CaseSensitive = True", in the initialization trigger; otherwise decoding won't work correctly


As for "is it hard?"... there's a ready to use variable, also in "initialization", called "SaveLoad_Alphabet".
Note: you must use the same "alphabet" for coding and for decoding.
 
X

xflip04

Guest
Ok 1 more question, If someone were to put a save load code in their map your going to need some sort of trigger that detects single player mode to use cheats. How can I make it disable the save and load option when not being played in battlenet?
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
this is an easy one just do this:
Code:
Single Mode
Event
    Map initialization
Condition
    (Number of players in (All players controlled by a User player)) Equal to 1
Action
    Turn off Saving <gen>
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,492
Code:
SaveLoad NoSinglePlayer
    Events
        Map initialization
    Conditions
    Actions
        Custom script:   if bj_isSinglePlayer then
        Trigger - Turn off <Save trigger>
        Trigger - Turn off <Load trigger>
        Wait 5.00 seconds
        Game - Display to (All players) the text: "Single player: -save and -load have been disabled"
        Custom script:   endif
 
X

xflip04

Guest
So that code will work even if someone adds computers in the empty slots to make it seem like theres more playing?
 
G

gormey

Guest
Putting in the trigger Unit - Remove (Triggering unit) from the game at the bottom of the trigger is not working how can I fix this?
 
G

gormey

Guest
What trigger? Your save load trigger on the bottom of the save trigger
Where exactly? The end before I put the trigger turn off this trigger
And what are you trying to do? Remove the hero from the game after saving to end the game.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,492
Well, the "save" trigger uses a "pick every unit in ..." to loop through your single Hero...
Put "Unit - Remove (Picked unit)" as very last action inside that loop.
 
K

Kyxoan.

Guest
nice save load code but...

I found an interesting bug.... The code will not restore a hero if it is saved with 0 gold, Is there a reason why that happens?

At first i used your map as a base for my map to preserve all the triggers / jass but i ended up needing to redo the terrain and stuff so i copy / pasted it to a new map. I didnt carry over the initialization trigger that is in yours thinking that was just for testing as stated..

I then tried to do a save load test with my partial terrain and it saved but said "decoding" and didn't create a new hero. So i wanted to see if its a single player only save load like some of them are and it didnt work there eaither.

I then decided to test it with gold and lumber on me for some reason (no idea what prompted me to do so) and it worked. first i did 100 gold / lumber and then i did just 1 gold piece and it saved me and loaded me perfectly.

So just for anyone out there running into this issue that is the only problem i have found with this save load.

If you know of anyway to fix it, I would appreciate the help. If not i will add a simple if then else for gold being less than 1 to set gold to 1 and it should work fine.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,492
> If you know of anyway to fix it

Indeed.

With "Save[1] = 0", the decoder will miss one character...
Interesting.

Congratulations.


I'll sleep a night over it or so.
Until then, don't save a potential 0 in Save[1]...


> I didn't carry over the initialization trigger

You should though.
At least for the alphabet. Actually, for any lines after "these three lines ...".
And the required global variables.
 
K

Kyxoan.

Guest
okay then=P

Also, Your tutorial makes it seem easy to add a new process by adding save[index] and telling it what to do, but i can't find anywhere to put a code to save str / agil / int or learned abilities. Do you have aim per chance? if so i am kproskater7 if not perhaps you could explain in detail to me what i need to do in PMs or on here =) thanks ace.

and, I carried the initialization Inside the save/load folder but not the one inside the initialization folder because that was just giving me ar andom level / gold. thats the one i ment.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    Happy Sunday!
    +1
  • The Helper The Helper:
    I will be out of town until Sunday evening
    +1
  • The Helper The Helper:
    I am back! Did you miss me LOL
    +1
  • jonas jonas:
    where did you go?
  • The Helper The Helper:
    Jefferson TX on a Paranormal Investigation of a haunted bed and breakfast - I got some friends that are paranormal investigators and they have an RV and do YouTubes
    +1
  • The Helper The Helper:
    It was a lot of fun. The RV was bad ass
  • jonas jonas:
    That sounds like fun!
    +1
  • The Helper The Helper:
    it was a blast!
  • The Helper The Helper:
    I am going to post the Youtube of the investigation in the forums when it is ready
    +1
  • jonas jonas:
    cool!
  • vypur85 vypur85:
    Sounds cool TH.
  • tom_mai78101 tom_mai78101:
    I was on a Legend of Zelda marathon...
  • tom_mai78101 tom_mai78101:
    Am still doing it now
    +1
  • jonas jonas:
    which one(s) are you playing?
  • jonas jonas:
    I played a little bit of the switch title two weeks ago and found it quite boring
  • The Helper The Helper:
    just got back from San Antonio this weekend had the best Buffalo Chicken Cheesesteak sandwhich in Universal City, TX - place was called Yous Guys freaking awesome! Hope everyone had a fantastic weekend!
    +1
  • The Helper The Helper:
    Happy Tuesday!
  • The Helper The Helper:
    We have been getting crazy numbers reported by the forum of people online the bots are going crazy on us I think it is AI training bots going at it at least that is what it looks like to me.
  • The Helper The Helper:
    Most legit traffic is tracked on multiple Analytics and we have Cloud Flare setup to block a ton of stuff but still there is large amount of bots that seem to escape detection and show up in the user list of the forum. I have been watching this bullshit for a year and still cannot figure it out it is drving me crazy lol.
    +1
  • Ghan Ghan:
    Beep boop
    +1
  • The Helper The Helper:
    hears robot sounds while 250 bots are on the forum lol
  • The Helper The Helper:
    Happy Saturday!
    +1
  • The Helper The Helper:
    and then it was Thursday...
    +2

    The Helper Discord

    Staff online

    • Ghan
      Administrator - Servers are fun

    Members online

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top