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
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
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
 
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
> 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
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)
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
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
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
> 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
  • 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.
  • Wizard Wizard:
    I also still float around. Whenever I'm needed, just have Ghan poke me.

    Members online

    No members online now.

    Affiliates

    Hive Workshop NUON Dome
    Top