Save/Load Code, Yet Another

power

New Member
Reaction score
3
Oh I see it.. Sorry.. I didn't know! Thanks for posting this and helping me countless times! (Your a bloody legend :D)
 

power

New Member
Reaction score
3
Probably been asked this but how do I save the hero and another unit *IN this case a mount/unit that can carry your hero*
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,497
This has been asked before, and the reply is still the same.
There's an example trigger that saves several Heroes if you have them.
Change the units that are picked to include your "mount".
 

JakeWC123

New Member
Reaction score
2
With your Save Load Code its not sAVing items. its only saving one of the items out of the 6 or how ever many i have.

i tried recopying the code into my map from your demo and the one i copied into my map the 2nd time did the same thing?
 

Nestharus

o-o
Reaction score
84
Warcraft 3 has very limited processing power.

The characters being displayed aren't the problem. It's the calculator being used. At one point, the numbers go beyond the maximum, the loops go beyond the maximum, etc. In truth, it wouldn't crash warcraft 3, but Blizzard supports stability, so in order to stop something that might prove a tiny bit unstable, Warcraft 3 just stops processing the commands all together. This is why your save/load codes won't appear.

Now, what Acehart said was a good idea if you are trying to get around the calculator issue, however.. you need to give the processor a break. It's like running thru 5000 loops. Do you think warcraft 3 will actually run thru all 5000???

Probably not... unless you pause it at some point and give it a break.

What I suggest:
Save portion by portion, maybe even show what's being saved and the %. Store all of the information. When your done saving one chunk, pause, then start the next chunk. When it's all saved, show the code to the player. That will work.

For example:
Now Saving Heroes
Now Saving Items
Now Saving Gold and Lumber

As long as you have MPI (multi-player instance), it should work fine.

You can't go beyond the processing power of what you are using ; )

hope this helps

To jake
Jake, are you sure you are using a loop to save all of the items? If you only save the item in slot 1, it will only save the item in slot 1
You need to do something like a for loop for each slot the hero has from 1 to the maxmum slot. Save the item in slot x, then go on. It sounds like you're just saving the first item ;P


-nes
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,497
> your Save Load Code is not saving items

In the unlikely event that your item list would be, let's say, over 30, put the 30 most used ones, and forget the others.
They will be saved regardless of being in the list or not.
You'll get a code with a couple extra characters, but it will work.

If that wouldn't be it:
"It doesn't work" is not a very good problem description.
 

JakeWC123

New Member
Reaction score
2
I never touched the item part of the save load it says sometine like Saving all items in Integer A . but when i load it only gives me 1 item. i also imported it again into my map without changing anything and even changed the custom script back and it still was only saving 1 item.
 
T

Turilli

Guest
Warcraft 3 has very limited processing power.

The characters being displayed aren't the problem. It's the calculator being used. At one point, the numbers go beyond the maximum, the loops go beyond the maximum, etc. In truth, it wouldn't crash warcraft 3, but Blizzard supports stability, so in order to stop something that might prove a tiny bit unstable, Warcraft 3 just stops processing the commands all together. This is why your save/load codes won't appear.

Now, what Acehart said was a good idea if you are trying to get around the calculator issue, however.. you need to give the processor a break. It's like running thru 5000 loops. Do you think warcraft 3 will actually run thru all 5000???

Probably not... unless you pause it at some point and give it a break.

What I suggest:
Save portion by portion, maybe even show what's being saved and the %. Store all of the information. When your done saving one chunk, pause, then start the next chunk. When it's all saved, show the code to the player. That will work.

For example:
Now Saving Heroes
Now Saving Items
Now Saving Gold and Lumber

As long as you have MPI (multi-player instance), it should work fine.

You can't go beyond the processing power of what you are using ; )

hope this helps

I assume this was directed at my question.
I thank you for the detailed answer as well, but I don't have much experience with save/load systems. Is there any specific function you would reccomend for "pausing" inbetween the chunks of information I'd be saving?
 

Nestharus

o-o
Reaction score
84
Creating a simple timer to pause the trigger would do the trick, or maybe creating your own unique pauser function. It would be best to mask this as something such as what I said above:
Saving items
Saving hero

etc etc

=)

So, a simple timer would do the trick.

Just pause between each hero

Hopefully this helps =)
 

ROTS19

TH.net Regular
Reaction score
12
I changed the triggers a little so that it supopsed to save integers instead of heroes/items and spells. here's how the triggers look.,

Code:
SaveLoad Initialization
    Events
        Map initialization
    Conditions
    Actions
        -------- List of Scores --------
        Set PlayerScore[1] = 0
        Set PlayerScore[2] = 0
        Set PlayerScore[3] = 0
        Set PlayerScore[4] = 0
        Set PlayerScore[5] = 0
        Set PlayerScore[6] = 0
        Set PlayerScore[7] = 0
        Set PlayerScore[8] = 0
        Set PlayerScore[9] = 0
        Set PlayerScore[10] = 0
        Set PlayerScore[11] = 0
        Set PlayerScore[12] = 0
        -------- Number of PlayersScores --------
        Set SaveLoad_LastIndex = 12
        -------- These three lines may be changed if needed --------
        Set Saveload_Alphabet = abcdefghijklmnopqrstuvwxyz1234567890?!@$%^&*()<>[]
        Set SaveLoad_CaseSensitive = False
        Set SaveLoad_UsePlayerName = True
        -------- Required: false --------
        Set SaveLoad_Initialized = False
        -------- Leave as is. Used to autocreate variables when copy & pasting to a new map --------
        Set Code = AceHart
        Set Save[1] = 0
        Set SaveCount = 1
        Set Validate = False
        Set SaveLoad_Compress[1] = 0
        Set SaveLoad_Uncompress[1] = 0

Code:
SaveLoad Save
    Events
        Player - Player 1 (Red) types a chat message containing -save as An exact match
        Player - Player 2 (Blue) types a chat message containing -save as An exact match
        Player - Player 3 (Teal) types a chat message containing -save as An exact match
        Player - Player 4 (Purple) types a chat message containing -save as An exact match
    Conditions
    Actions
        -------- Those values need saving --------
        Set Save[1] = PlayerScore[1]
        Set Save[2] = PlayerScore[2]
        Set Save[3] = PlayerScore[3]
        Set Save[4] = PlayerScore[4]
        Set Save[5] = PlayerScore[5]
        Set Save[6] = PlayerScore[6]
        Set Save[7] = PlayerScore[7]
        Set Save[8] = PlayerScore[8]
        Set Save[9] = PlayerScore[9]
        Set Save[10] = PlayerScore[10]
        Set Save[11] = PlayerScore[11]
        Set Save[12] = PlayerScore[12]
        -------- The number of values we have --------
        Set SaveCount = 12
        -------- Turn values into code --------
        Custom script:   set udg_Code = SaveLoad_Encode()
        -------- Show code to player --------
        Quest - Display to (Player group((Triggering player))) the Secret message: Your code:
        Game - Display to (Player group((Triggering player))) for 900.00 seconds the text: Code
        Game - Display to (Player group((Triggering player))) for 900.00 seconds the text: Tip: Write down or ...

Code:
SaveLoad Load
    Events
        Player - Player 1 (Red) types a chat message containing -load  as A substring
        Player - Player 2 (Blue) types a chat message containing -load  as A substring
        Player - Player 3 (Teal) types a chat message containing -load  as A substring
        Player - Player 4 (Purple) types a chat message containing -load  as A substring
    Conditions
        (Substring((Entered chat string), 1, 6)) Equal to (Matched chat string)
        (Length of (Entered chat string)) Greater than 6
    Actions
        -------- Try to decode what was typed --------
        Set Code = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
        Custom script:   set udg_Validate = SaveLoad_Decode( udg_Code )
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Validate Equal to True
            Then - Actions
                -------- It worked, let's do something with it --------
                For each (Integer A) from 1 to SaveCount, do (Actions)
                    Loop - Actions
                        Game - Display to (Player group((Triggering player))) the text: (Decode:  + (String(Save[(Integer A)])))
            Else - Actions
                -------- Invalid code --------
                Game - Display to (Player group((Triggering player))) the text: Invalid Code

and i copied the custom script thingwhere you click on the map name in the trigger editor in the same place in my map,

it basicly, whenever i save, (the map), it saves the map, but it gives me lots of compile errors, and when i try to test, it just goes to the main menu, and i cant enable the triggers...so, what did i do that messed it up?
 

ROTS19

TH.net Regular
Reaction score
12
> some example?

yeah, so theres 260 and here's one on 142 (expected a name)

Code:
        exitwhen i > udg_SaveLoad_Heroes_LastIndex

145 (Expected 'endloop')
Code:
        endif

156 (Expected 'endif')
Code:
    endif

it doesnt highlight anything for 159, but it says need return value in function

161 (Expected end of line)
Code:
    local integer i = 0

194 (Expected a variable name)
Code:
        set i = i + 1

and i copied all the custom script
thats just some of the 260 errors, one of each diffrent type that i got
i don't really no what those errors are talkinga bout

what happen ?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,497
Ah... yes. Of course.

There's a reason why the "Initialization" trigger, even in the "Basic" category, has those Hero and Item variables... it's because they are expected to be there.


Open the save / load map, take one of the "init" triggers, rename it to something you're sure not to have in your map,
copy & paste it into your map to create all variables.
Remove the trigger...

Alternatively, create the Heroes and Items variables by hand... (copy&paste is easier. And faster)
 

JakeWC123

New Member
Reaction score
2
On my map i figured out how to make it save integers.
Actions
-------- Prepare the save array with this player's Hero --------
Set SaveCount = 0
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = PlayerXPshow[(Player number of
(Triggering player))]
-------- Turn values into code --------
Custom script: set udg_Code = SaveLoad_Encode()
-------- Show code to player --------
Quest - Display to (Player group((Triggering player))) the Secret message: Your code:
Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code


idk if thats helpful but i didnt put it in initlization or anything.

Then Load
Actions:
-------- Try to decode what was typed --------
Set Code = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
Custom script: set udg_Validate = SaveLoad_Decode( udg_Code )
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Validate Equal to False
Then - Actions
-------- Invalid code --------
Game - Display to (Player group((Triggering player))) the text: There's some error ...
Skip remaining actions
Else - Actions
-------- It worked, let's do something with it --------
-------- Load EXP --------
Set SaveCount = 0
Set SaveCount = (SaveCount + 1)
Set PlayerXPshow[(Player number of (Triggering player))] = Save[SaveCount]


my variable was a integer - Array
 

Syndrome

You can change this now in User CP.
Reaction score
126
Can I set:
Code:
For Each Integer A from 1-100 do Actions:
Set Save [Integer A] to Ability [Integer A]
Set Save [Integer A + 100] to Level of Ability [Integer A]

And that is ALL I have to do? Nothing else?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,497
> Set Save [Integer A + 100]

This would mean to save more than 100 values... which is 1. impossible, 2. would give an insanely long code.
Have a look at the example...
 
C

cliffhan61

Guest
Help Please:(

Eerm, may i ask how do you modify the trigger so that a player is only allowed to load his/her character twice? Thanks in advance.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,497
Add something like this to the beginning of the "load" trigger:

Set TempInteger = Player number of (Triggering player)
If LoadCount[TempInteger] greater than or equal to 2
- Game - Display to (Player goup (Triggering player)): Sorry, too many loads.
- Skip remaining actions
Set LoadCount[TempInteger] = LoadCount[TempInteger] + 1


With "LoadCount" being a variable of type "Integer", with a check in "array" and a size of 12.
 

xfirenzx

New Member
Reaction score
7
None of the custom scripts are working.

I only took Save Load Hero with Items.

Just wondering if i needed any other ones?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top