• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Save/Load

Status
Not open for further replies.
Level 6
Joined
Feb 19, 2004
Messages
147
Ok so basically the problem here is that I have a save/load that I'm using substrings for along with if/then/else statements which...in my personal experience are a pain to work with. This is the trigger. I changed the variables of course to not give away codes in it later on...

  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Substring((Entered chat string), 9, 10)) Equal to (==) h
    • Then - Actions
      • Hero - Modify Strength of (Last created unit): Add 1
    • Else - Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring((Entered chat string), 9, 10)) Equal to (==) y
        • Then - Actions
          • Hero - Modify Strength of (Last created unit): Add 2
        • Else - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Substring((Entered chat string), 9, 10)) Equal to (==) n
            • Then - Actions
              • Hero - Modify Strength of (Last created unit): Add 3
            • Else - Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Substring((Entered chat string), 9, 10)) Equal to (==) p
                • Then - Actions
                  • Hero - Modify Strength of (Last created unit): Add 4
                • Else - Actions
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Substring((Entered chat string), 9, 10)) Equal to (==) t
                    • Then - Actions
                      • Hero - Modify Strength of (Last created unit): Add 5
                    • Else - Actions
                      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Substring((Entered chat string), 9, 10)) Equal to (==) k
                        • Then - Actions
                          • Hero - Modify Strength of (Last created unit): Add 6
                        • Else - Actions
                          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Substring((Entered chat string), 9, 10)) Equal to (==) l
                            • Then - Actions
                              • Hero - Modify Strength of (Last created unit): Add 7
                            • Else - Actions
                              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (Substring((Entered chat string), 9, 10)) Equal to (==) h
                                • Then - Actions
                                  • Hero - Modify Strength of (Last created unit): Add 8
                                • Else - Actions
                                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • (Substring((Entered chat string), 9, 10)) Equal to (==) v
                                    • Then - Actions
                                      • Hero - Modify Strength of (Last created unit): Add 9
                                    • Else - Actions
                                      • Hero - Modify Strength of (Last created unit): Add 0
If you can tell me what I've got wrong here it would be great...basically at the moment what it does is it will do the very last substring typed in, but nothing else...as in if I typed -load vvvv it disregards the first 3 and only counts the last. This function is only one variable of said code also.
-------------------------------------------------
Nevermind I figured it out
 
Last edited by a moderator:
Level 6
Joined
Apr 16, 2007
Messages
177
please use loops and arrays instead.

get the following globals:

a string variable SAVELOAD_CurChar
an integer array SAVELOAD_Val
a string array SAVELOAD_Char

then intialize the "Char" and "Val" arrays:

  • SAVE Init
  • set SAVELOAD_Char[ 0 ] = "h"
  • set SAVELOAD_Val[ 0 ] = 1
  • set SAVELOAD_Char[ 1 ] = "y"
  • set SAVELOAD_Val[ 1 ] = 2
(using the values from the trigger you posted)

then do:
  • Load Perform
  • set SAVELOAD_CurChar = Substring((Entered chat string), 9, 10)
  • For each integer A from 0 to [The number of possible values], do:
    • If - Conditions
      • (SAVELOAD_CurChar) Equal to (==) SAVELOAD_Char[ integer A ]
    • Then - Actions
      • Hero - Modify Strength of (Last created unit): Add SAVELOAD_Val[ integer A ]
      • [Exit the loop]
    • Else - Actions
That way you can easily modify, add or remove values without work.

I would also recommend using one of the countless saveload systems that exist... The master did a great one. (Acehart)
 
Last edited:
Status
Not open for further replies.
Top