System TriggerHappy's Simple Save/Load System

Reaction score
341
Information : This save/load is nothing special , its just a basic save/load code that im hoping people can learn from. Its not 100% Safe , if you saw the source code then you could decode it , or if you studied the code from saving alot , then you might be able to "hack" it.

Reason For Sumbitting : For Others to learn from , or use :)

What It Saves :

.Unlimited amount of heroes
.Unlimited amount of items

What It CAN Save :

.Anything

What I Am Looking to add:

.Level
.Abilites


Screenshot
Untitled-3.jpg

Triggers:
Inialization
Code:
Inialization
    Events
        Map initialization
    Conditions
    Actions
        Visibility - Disable fog of war
        Visibility - Disable black mask
        --------   --------
        Set PlayersHero[1] = Blood Mage 0000 <gen>
        Set PlayersHero[2] = Blood Mage 0049 <gen>
        Set PlayersHero[3] = Blood Mage 0050 <gen>
        Set PlayersHero[4] = Blood Mage 0051 <gen>
        Set PlayersHero[5] = Blood Mage 0052 <gen>
        -------- -------------------------Heroes-------------------------- --------
        Set InitializeHeroes[1] = Blood Mage
        Set InitializeHeroes_String[1] = 23
        Set EndHeroes = 1
        -------- -------------------------Items-------------------------- --------
        Set InitializeItems[1] = Claws of Attack +15
        Set InitializeItems_String[1] = 82
        Set InitializeItems[2] = Ring of Protection +5
        Set InitializeItems_String[2] = 34
        Set InitializeItems[3] = Crown of Kings +5
        Set InitializeItems_String[3] = 28
        Set InitializeItems[4] = Kelen's Dagger of Escape
        Set InitializeItems_String[4] = 15
        Set InitializeItems[5] = Cheese
        Set InitializeItems_String[5] = 75
        Set InitializeItems[6] = Orb of Frost
        Set InitializeItems_String[6] = 45
        Set EndItems = 6

Alphabet

Code:
function Trig_Alphabet_Actions takes nothing returns nothing
    set udg_TempInteger = 0
    set udg_Alphabet[udg_TempInteger] = "1"
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = "2"
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = "3"
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = "4"
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = "5"
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = "6"
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = "7"
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = "8"
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = "9"
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = "0"
    set udg_TempInteger = ( udg_TempInteger + 1 )
endfunction

//===========================================================================
function InitTrig_Alphabet takes nothing returns nothing
    set gg_trg_Alphabet = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_Alphabet, 0.00 )
    call TriggerAddAction( gg_trg_Alphabet, function Trig_Alphabet_Actions )
endfunction


Save
Code:
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
        Player - Player 5 (Yellow) types a chat message containing -save as An exact match
        Player - Player 6 (Orange) types a chat message containing -save as An exact match
        Player - Player 7 (Green) types a chat message containing -save as An exact match
        Player - Player 8 (Pink) types a chat message containing -save as An exact match
        Player - Player 9 (Gray) types a chat message containing -save as An exact match
        Player - Player 10 (Light Blue) types a chat message containing -save as An exact match
    Conditions
    Actions
        Cinematic - Clear the screen of text messages for (Player group((Triggering player)))
        For each (Integer B) from 1 to 6, do (Actions)
            Loop - Actions
                For each (Integer A) from 1 to EndHeroes, do (Actions)
                    Loop - Actions
                        Set RandomNumber = (Random integer number between 1 and 10)
                        Set RandomNumber2 = (Random integer number between 1 and 10)
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Alphabet[RandomNumber] + Alphabet[RandomNumber2]) Not equal to InitializeItems_String[(Integer A)]
                            Then - Actions
                                Set String_Items[(Integer B)] = (Alphabet[(Random integer number between 1 and 10)] + Alphabet[(Random integer number between 1 and 10)])
                            Else - Actions
                                Set String_Items[(Integer B)] = (81 + Alphabet[(Random integer number between 1 and 10)])
        Wait 0.15 seconds
        Trigger - Run Save Hero <gen> (checking conditions)
        Trigger - Run Save Items <gen> (checking conditions)
        -------- DisplayCode --------
        Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: |c000080FF=========...
        Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: |c00D7D700Code : |r
        Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: ((((((|c00FF8000 + (Substring(String_Hero, 1, 1))) + (String_Items[5] + String_Items[1])) + String_Items[2]) + String_Items[4]) + (String_Items[3] + (Substring(String_Hero, 2, 2)))) + (String_Items[6] + (<Empty String> + |r)))
        Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: |c000080FF=========...
        Game - Display to (Player group((Triggering player))) for 60.00 seconds the text:           
        Game - Display to (Player group((Triggering player))) for 60.00 seconds the text:           
        Game - Display to (Player group((Triggering player))) for 60.00 seconds the text:

Load

Code:
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
        Player - Player 5 (Yellow) types a chat message containing -load  as A substring
        Player - Player 6 (Orange) types a chat message containing -load  as A substring
        Player - Player 7 (Green) types a chat message containing -load  as A substring
        Player - Player 8 (Pink) types a chat message containing -load  as A substring
        Player - Player 9 (Gray) types a chat message containing -load  as A substring
        Player - Player 10 (Light Blue) types a chat message containing -load  as A substring
    Conditions
    Actions
        Set KeepLoading = True
        Cinematic - Clear the screen of text messages for (Player group((Triggering player)))
        Trigger - Run Load Hero <gen> (checking conditions)
        Trigger - Run Load Items <gen> (checking conditions)


Save Hero

Code:
Save Hero
    Events
    Conditions
    Actions
        For each (Integer A) from 1 to EndHeroes, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Unit-type of PlayersHero[(Player number of (Triggering player))]) Equal to InitializeHeroes[(Integer A)]
                    Then - Actions
                        Set String_Hero = InitializeHeroes_String[(Integer A)]
                        Skip remaining actions
                    Else - Actions

Save Items

Code:
Save Items
    Events
    Conditions
    Actions
        For each (Integer B) from 1 to 6, do (Actions)
            Loop - Actions
                For each (Integer A) from 1 to EndItems, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Item-type of (Item carried by PlayersHero[(Player number of (Triggering player))] in slot (Integer B))) Equal to InitializeItems[(Integer A)]
                            Then - Actions
                                Set String_Items[(Integer B)] = InitializeItems_String[(Integer A)]
                            Else - Actions


Load Hero

Code:
Load Hero
    Events
    Conditions
    Actions
        For each (Integer A) from 1 to EndHeroes, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Substring((Entered chat string), 7, 7)) Equal to (Substring(InitializeHeroes_String[(Integer A)], 1, 1))
                        (Substring((Entered chat string), 18, 18)) Equal to (Substring(InitializeHeroes_String[(Integer A)], 2, 2))
                    Then - Actions
                        Unit - Remove PlayersHero[(Player number of (Triggering player))] from the game
                        Unit - Create 1 InitializeHeroes[(Integer A)] for (Triggering player) at ((Triggering player) start location) facing (Position of (Triggering unit))
                        Set PlayersHero[(Player number of (Triggering player))] = (Last created unit)
                        Game - Display to (Player group((Triggering player))) the text: ((Name of (Last created unit)) + : |c0000FF00Loaded|r)
                    Else - Actions
                        Game - Display to (Player group((Triggering player))) the text: |c00FF0000Error #1 ...
                        Set KeepLoading = False

Load Items

Code:
Load Items
    Events
    Conditions
        KeepLoading Not equal to False
    Actions
        -------- Load Item #1 --------
        For each (Integer A) from 1 to EndItems, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Substring((Entered chat string), 8, 9)) Equal to InitializeItems_String[(Integer A)]
                    Then - Actions
                        Hero - Create InitializeItems[(Integer A)] and give it to PlayersHero[(Player number of (Triggering player))]
                        Game - Display to (Player group((Triggering player))) the text: ((Name of (Last created item)) + : |c0000FF00Loaded|r)
                    Else - Actions
        -------- Load Item #2 --------
        For each (Integer A) from 1 to EndItems, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Substring((Entered chat string), 10, 11)) Equal to InitializeItems_String[(Integer A)]
                    Then - Actions
                        Hero - Create InitializeItems[(Integer A)] and give it to PlayersHero[(Player number of (Triggering player))]
                        Game - Display to (Player group((Triggering player))) the text: ((Name of (Last created item)) + : |c0000FF00Loaded|r)
                    Else - Actions
        -------- Load Item #3 --------
        For each (Integer A) from 1 to EndItems, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Substring((Entered chat string), 12, 13)) Equal to InitializeItems_String[(Integer A)]
                    Then - Actions
                        Hero - Create InitializeItems[(Integer A)] and give it to PlayersHero[(Player number of (Triggering player))]
                        Game - Display to (Player group((Triggering player))) the text: ((Name of (Last created item)) + : |c0000FF00Loaded|r)
                    Else - Actions
        -------- Load Item #4 --------
        For each (Integer A) from 1 to EndItems, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Substring((Entered chat string), 14, 15)) Equal to InitializeItems_String[(Integer A)]
                    Then - Actions
                        Hero - Create InitializeItems[(Integer A)] and give it to PlayersHero[(Player number of (Triggering player))]
                        Game - Display to (Player group((Triggering player))) the text: ((Name of (Last created item)) + : |c0000FF00Loaded|r)
                    Else - Actions
        -------- Load Item #5 --------
        For each (Integer A) from 1 to EndItems, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Substring((Entered chat string), 16, 17)) Equal to InitializeItems_String[(Integer A)]
                    Then - Actions
                        Hero - Create InitializeItems[(Integer A)] and give it to PlayersHero[(Player number of (Triggering player))]
                        Game - Display to (Player group((Triggering player))) the text: ((Name of (Last created item)) + : |c0000FF00Loaded|r)
                    Else - Actions
        -------- Load Item #6 --------
        For each (Integer A) from 1 to EndItems, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Substring((Entered chat string), 19, 20)) Equal to InitializeItems_String[(Integer A)]
                    Then - Actions
                        Hero - Create InitializeItems[(Integer A)] and give it to PlayersHero[(Player number of (Triggering player))]
                        Game - Display to (Player group((Triggering player))) the text: ((Name of (Last created item)) + : |c0000FF00Loaded|r)
                    Else - Actions
 
1

131ackout

Guest
Will you post all triggers from the save and load map

So, it would help everyone. XD

EDIT: Will you include the "ABC" in the code, because numbers is difficult.
 
Reaction score
341
you can change the string 2 whatever you want. i jus chose numbers


theres like 6 triggers. its more organized then 1 trigger but fine ill post em
 
1

131ackout

Guest
Really a lot of triggers. A few triggers would be the better. Why don't you take some leaky stuff from the triggers off? See if it can.
 

trb92

Throwing science at the wall to see what sticks
Reaction score
142
JASS:
function Trig_Alphabet_Actions takes nothing returns nothing
    set udg_TempInteger = 0
    set udg_Alphabet[udg_TempInteger] = &quot;1&quot;
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = &quot;2&quot;
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = &quot;3&quot;
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = &quot;4&quot;
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = &quot;5&quot;
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = &quot;6&quot;
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = &quot;7&quot;
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = &quot;8&quot;
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = &quot;9&quot;
    set udg_TempInteger = ( udg_TempInteger + 1 )
    set udg_Alphabet[udg_TempInteger] = &quot;0&quot;
    set udg_TempInteger = ( udg_TempInteger + 1 )
endfunction
...Why would you do this??
Isn't this shorter and easier to work with?

JASS:
function Trig_Alphabet_Actions takes nothing returns nothing
    local integer i = 0
    loop
    exitwhen i&gt;8
    set udg_Alphabet<i> = I2S(i+1)
    set i = i +1
    endloop
    set udg_Alphabet[9] = &quot;0&quot;
endfunction</i>

It does exactly the same thing, starts with setting "1" at array[0] and ends with setting [9] to "0".

Oh, and change your Jass trigger so that it uses
JASS:
 tags, not 
	
	


<div class="bbCodeBlock bbCodeBlock--screenLimited bbCodeBlock--code">
	<div class="bbCodeBlock-title">
		Code:
	</div>
	<div class="bbCodeBlock-content" dir="ltr">
		<pre class="bbCodeCode" dir="ltr" data-xf-init="code-block" data-lang=""><code> tags.
And why did you do that one trigger in Jass, but the rest in GUI?</code></pre>
	</div>
</div>
 
Reaction score
341
Because originally i did the alphabet instead of integers

JASS:
   set udg_TempInteger = 0    set udg_Alphabet[udg_TempInteger] = &quot;a&quot;    set udg_TempInteger = ( udg_TempInteger + 1 )
   set udg_TempInteger = 0    set udg_Alphabet[udg_TempInteger] = &quot;b&quot;    set udg_TempInteger = ( udg_TempInteger + 1 )


ect..

then i just removed alphabet and replaced with integers


And why did you do that one trigger in Jass, but the rest in GUI?


its easier and faster to type the alphabet then clicking each time and imputing into gui
 
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