• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Help me extend my save/load...

Status
Not open for further replies.
Level 8
Joined
Aug 3, 2008
Messages
257
  • SaveLoadInitialize
    • Events
      • Time - Elapsed game time is 0.10 seconds
    • Conditions
    • Actions
      • -------- Need to load your number system in here, right now its 36 chars. --------
      • -------- Slot1=36 --------
      • -------- Slot2=1296 --------
      • -------- Slot2=1296 --------
      • -------- Slot3=46656 --------
      • -------- Slot4=1679616 --------
      • -------- Slot5=60466176 --------
      • -------- I like making 0 the actual 0 for the unencrypted system. makes it easier to track stuff later. --------
      • Set SaveLoadCharacterSet = 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ
      • Set SaveLoadMaxCharacters = 36
      • -------- Need to load your encryption system in here, right now its 5 sets. Load code will get broken if you use a '-' in the Number system --------
      • Set SaveLoadEncryptionSet[1] = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
      • Set SaveLoadEncryptionSet[2] = GHIJKLMNOPQRSTUVWXYZ0123456789ABCDEF
      • Set SaveLoadEncryptionSet[3] = ABCDEFPQRSTUVWXYZ012345GHIJKLMNO6789
      • Set SaveLoadEncryptionSet[4] = ASTUVWXYBCJKLMNOPQRZ01234DFEGHI56789
      • Set SaveLoadEncryptionSet[5] = HIJKLABCDEVWXYZ0123FGM4567NOPQRSTU89
      • Set SaveLoadMaxEncryptionSets = 5
      • -------- Now time to populate the Number system. this loop will put the characters into an array which acts like a counting system from 0 till MaxChars --------
      • For each (Integer A) from 1 to SaveLoadMaxCharacters, do (Actions)
        • Loop - Actions
          • Set SaveLoadCharacterNumbers[((Integer A) - 1)] = (Substring(SaveLoadCharacterSet, (Integer A), (Integer A)))
      • -------- Make sure you calculate on paper how many numbers per the amount of slots you get from Characters, this will make it MUCH easier to do slot sizes --------
      • -------- Size of Levels to be saved for herolevel --------
      • Set SaveLoadSlotsHeroLevel = 2
      • -------- Load the Heroes into an array to make numbers out of them. --------
      • Set SaveLoadHeroesStored[1] = Paladin
      • Set SaveLoadHeroesStored[2] = Archmage
      • Set SaveLoadHeroesStored[3] = Mountain King
      • Set SaveLoadHeroesStored[4] = Blood Mage
      • Set SaveLoadMaxHeroesStored = 4
      • Set SaveLoadSlotsHero = 2
      • -------- Load the Items into an array to make numbers out of them. --------
      • Set SaveLoadItemsStored[1] = Dust of Appearance
      • Set SaveLoadItemsStored[2] = Minor Replenishment Potion
      • Set SaveLoadItemsStored[3] = Potion of Speed
      • Set SaveLoadItemsStored[4] = Ring of the Archmagi
      • Set SaveLoadItemsStored[5] = Cloak of Shadows
      • Set SaveLoadItemsStored[6] = Gauntlets of Ogre Strength +3
      • Set SaveLoadItemsStored[7] = Mantle of Intelligence +3
      • Set SaveLoadItemsStored[8] = Slippers of Agility +3
      • Set SaveLoadItemsStored[9] = Manual of Health
      • Set SaveLoadItemsStored[10] = Healing Salve
      • Set SaveLoadMaxItemsStored = 10
      • Set SaveLoadSlotsItem = 2
      • -------- Need to setup slots for Gold and Lumber, 4 chars will cover up to 1.6 mill with 36 chars --------
      • Set SaveLoadSlotsGold = 4
      • Set SaveLoadSlotsLumber = 4
      • -------- Set the Block Size, basically the amount of characters between dashes. --------
      • Set SaveLoadBlockSize = 4
      • -------- Set the Variables to be stored size, good time to setup your variable positions. --------
      • Set SaveLoadVariablesStored[1] = SaveLoadSlotsHero
      • Set SaveLoadVariablesStored[2] = SaveLoadSlotsHeroLevel
      • Set SaveLoadVariablesStored[3] = SaveLoadSlotsItem
      • Set SaveLoadVariablesStored[4] = SaveLoadSlotsItem
      • Set SaveLoadVariablesStored[5] = SaveLoadSlotsItem
      • Set SaveLoadVariablesStored[6] = SaveLoadSlotsItem
      • Set SaveLoadVariablesStored[7] = SaveLoadSlotsItem
      • Set SaveLoadVariablesStored[8] = SaveLoadSlotsItem
      • Set SaveLoadVariablesStored[9] = SaveLoadSlotsGold
      • Set SaveLoadVariablesStored[10] = SaveLoadSlotsLumber
      • -------- This variable stops players from loading again after they load the first time. --------
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Set SaveLoadHasLoaded[(Integer A)] = False
  • SaveModuleSingle
    • 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
      • -------- This PlayerGroup is so you can broadcast the correct player the message in the end. --------
      • Player Group - Add (Triggering player) to SaveLoadPlayerGroupFocus
      • -------- Decide how many variables the system will store --------
      • Set SaveLoadMaxVariablesStored = 10
      • -------- Default everything and load the basic stuff. Needs to happen each trigger activation or bad things happen. --------
      • Set SaveLoadChecksumChar = <Empty String>
      • Set SaveLoadEncryptedString = <Empty String>
      • Set SaveLoadEncryptionKey = <Empty String>
      • Set SaveLoadCheckSumInt = 0
      • Set SaveLoadPreEncryptionString = <Empty String>
      • Set SaveLoadFinalString = <Empty String>
      • For each (Integer A) from 1 to SaveLoadMaxCharacters, do (Actions)
        • Loop - Actions
          • Set SaveLoadEncryptionNumbers[((Integer A) - 1)] = <Empty String>
      • For each (Integer A) from 1 to SaveLoadMaxVariablesStored, do (Actions)
        • Loop - Actions
          • Set SaveLoadTempStrings[(Integer A)] = <Empty String>
      • -------- Setup the encryption for use. --------
      • Set SaveLoadEncryptionKeyInt = (Random integer number between 1 and SaveLoadMaxEncryptionSets)
      • Set SaveLoadEncryptionKey = SaveLoadCharacterNumbers[SaveLoadEncryptionKeyInt]
      • For each (Integer A) from 1 to SaveLoadMaxCharacters, do (Actions)
        • Loop - Actions
          • Set SaveLoadEncryptionNumbers[((Integer A) - 1)] = (Substring(SaveLoadEncryptionSet[SaveLoadEncryptionKeyInt], (Integer A), (Integer A)))
      • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadEncryptionKey
      • -------- Now to start converting things to save --------
      • -------- Final string will be Encryption+Hero+HeroLevel+ItemsX6+Gold+Lumber+Checksum --------
      • -------- Hero first --------
      • For each (Integer A) from 1 to SaveLoadMaxHeroesStored, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of SaveLoadPlayerHeroSingle[(Player number of (Triggering player))]) Equal to SaveLoadHeroesStored[(Integer A)]
            • Then - Actions
              • Set SaveLoadConversionInteger = (Integer A)
            • Else - Actions
      • Set SaveLoadPowerOfCurrent = (SaveLoadSlotsHero - 1)
      • For each (Integer A) from 1 to SaveLoadSlotsHero, do (Actions)
        • Loop - Actions
          • Set SaveLoadPowerOfMaxNumber = 1
          • For each (Integer B) from (Integer A) to (SaveLoadSlotsHero - 1), do (Actions)
            • Loop - Actions
              • Set SaveLoadPowerOfMaxNumber = (SaveLoadPowerOfMaxNumber x SaveLoadMaxCharacters)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (SaveLoadSlotsHero - (Integer A)) Greater than or equal to 1
            • Then - Actions
              • Set SaveLoadConversionDividedInt = (SaveLoadConversionInteger / SaveLoadPowerOfMaxNumber)
              • Set SaveLoadConversionRemainder = (SaveLoadConversionInteger - (SaveLoadConversionDividedInt x SaveLoadPowerOfMaxNumber))
              • Set SaveLoadTempStrings[1] = (SaveLoadTempStrings[1] + SaveLoadCharacterNumbers[SaveLoadConversionDividedInt])
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (SaveLoadSlotsHero - (Integer A)) Less than 1
            • Then - Actions
              • Set SaveLoadTempStrings[1] = (SaveLoadTempStrings[1] + SaveLoadCharacterNumbers[SaveLoadConversionRemainder])
            • Else - Actions
          • Set SaveLoadConversionInteger = SaveLoadConversionRemainder
      • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadTempStrings[1]
      • -------- now to create the string section for the hero level --------
      • Set SaveLoadConversionInteger = (Hero level of SaveLoadPlayerHeroSingle[(Player number of (Triggering player))])
      • Set SaveLoadPowerOfCurrent = (SaveLoadSlotsHeroLevel - 1)
      • For each (Integer A) from 1 to SaveLoadSlotsHeroLevel, do (Actions)
        • Loop - Actions
          • Set SaveLoadPowerOfMaxNumber = 1
          • For each (Integer B) from (Integer A) to (SaveLoadSlotsHeroLevel - 1), do (Actions)
            • Loop - Actions
              • Set SaveLoadPowerOfMaxNumber = (SaveLoadPowerOfMaxNumber x SaveLoadMaxCharacters)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (SaveLoadSlotsHeroLevel - (Integer A)) Greater than or equal to 1
            • Then - Actions
              • Set SaveLoadConversionDividedInt = (SaveLoadConversionInteger / SaveLoadPowerOfMaxNumber)
              • Set SaveLoadConversionRemainder = (SaveLoadConversionInteger - (SaveLoadConversionDividedInt x SaveLoadPowerOfMaxNumber))
              • Set SaveLoadTempStrings[2] = (SaveLoadTempStrings[2] + SaveLoadCharacterNumbers[SaveLoadConversionDividedInt])
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (SaveLoadSlotsHeroLevel - (Integer A)) Less than 1
            • Then - Actions
              • Set SaveLoadTempStrings[2] = (SaveLoadTempStrings[2] + SaveLoadCharacterNumbers[SaveLoadConversionRemainder])
            • Else - Actions
          • Set SaveLoadConversionInteger = SaveLoadConversionRemainder
      • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadTempStrings[2]
      • -------- Now the Items carried by hero --------
      • -------- Item Slot1-6 courtesy the loop C --------
      • For each (Integer IntegerC) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set SaveLoadConversionInteger = 0
          • For each (Integer A) from 1 to SaveLoadMaxItemsStored, 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 SaveLoadPlayerHeroSingle[(Player number of (Triggering player))] in slot IntegerC)) Equal to SaveLoadItemsStored[(Integer A)]
                • Then - Actions
                  • Set SaveLoadConversionInteger = (Integer A)
                • Else - Actions
          • For each (Integer A) from 1 to SaveLoadSlotsItem, do (Actions)
            • Loop - Actions
              • Set SaveLoadPowerOfMaxNumber = 1
              • For each (Integer B) from (Integer A) to (SaveLoadSlotsItem - 1), do (Actions)
                • Loop - Actions
                  • Set SaveLoadPowerOfMaxNumber = (SaveLoadPowerOfMaxNumber x SaveLoadMaxCharacters)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (SaveLoadSlotsItem - (Integer A)) Greater than or equal to 1
                • Then - Actions
                  • Set SaveLoadConversionDividedInt = (SaveLoadConversionInteger / SaveLoadPowerOfMaxNumber)
                  • Set SaveLoadConversionRemainder = (SaveLoadConversionInteger - (SaveLoadConversionDividedInt x SaveLoadPowerOfMaxNumber))
                  • Set SaveLoadTempStrings[(IntegerC + 2)] = (SaveLoadTempStrings[(IntegerC + 2)] + SaveLoadCharacterNumbers[SaveLoadConversionDividedInt])
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (SaveLoadSlotsItem - (Integer A)) Less than 1
                • Then - Actions
                  • Set SaveLoadTempStrings[(IntegerC + 2)] = (SaveLoadTempStrings[(IntegerC + 2)] + SaveLoadCharacterNumbers[SaveLoadConversionRemainder])
                • Else - Actions
              • Set SaveLoadConversionInteger = SaveLoadConversionRemainder
          • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadTempStrings[(IntegerC + 2)]
      • -------- Now to convert the Gold into the strings --------
      • Set SaveLoadConversionInteger = ((Triggering player) Current gold)
      • For each (Integer A) from 1 to SaveLoadSlotsGold, do (Actions)
        • Loop - Actions
          • Set SaveLoadPowerOfMaxNumber = 1
          • For each (Integer B) from (Integer A) to (SaveLoadSlotsGold - 1), do (Actions)
            • Loop - Actions
              • Set SaveLoadPowerOfMaxNumber = (SaveLoadPowerOfMaxNumber x SaveLoadMaxCharacters)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (SaveLoadSlotsGold - (Integer A)) Greater than or equal to 1
            • Then - Actions
              • Set SaveLoadConversionDividedInt = (SaveLoadConversionInteger / SaveLoadPowerOfMaxNumber)
              • Set SaveLoadConversionRemainder = (SaveLoadConversionInteger - (SaveLoadConversionDividedInt x SaveLoadPowerOfMaxNumber))
              • Set SaveLoadTempStrings[9] = (SaveLoadTempStrings[9] + SaveLoadCharacterNumbers[SaveLoadConversionDividedInt])
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (SaveLoadSlotsGold - (Integer A)) Less than 1
            • Then - Actions
              • Set SaveLoadTempStrings[9] = (SaveLoadTempStrings[9] + SaveLoadCharacterNumbers[SaveLoadConversionRemainder])
            • Else - Actions
          • Set SaveLoadConversionInteger = SaveLoadConversionRemainder
      • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadTempStrings[9]
      • -------- Now to convert the Lumber into the strings --------
      • Set SaveLoadConversionInteger = ((Triggering player) Current lumber)
      • For each (Integer A) from 1 to SaveLoadSlotsLumber, do (Actions)
        • Loop - Actions
          • Set SaveLoadPowerOfMaxNumber = 1
          • For each (Integer B) from (Integer A) to (SaveLoadSlotsLumber - 1), do (Actions)
            • Loop - Actions
              • Set SaveLoadPowerOfMaxNumber = (SaveLoadPowerOfMaxNumber x SaveLoadMaxCharacters)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (SaveLoadSlotsLumber - (Integer A)) Greater than or equal to 1
            • Then - Actions
              • Set SaveLoadConversionDividedInt = (SaveLoadConversionInteger / SaveLoadPowerOfMaxNumber)
              • Set SaveLoadConversionRemainder = (SaveLoadConversionInteger - (SaveLoadConversionDividedInt x SaveLoadPowerOfMaxNumber))
              • Set SaveLoadTempStrings[10] = (SaveLoadTempStrings[10] + SaveLoadCharacterNumbers[SaveLoadConversionDividedInt])
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (SaveLoadSlotsLumber - (Integer A)) Less than 1
            • Then - Actions
              • Set SaveLoadTempStrings[10] = (SaveLoadTempStrings[10] + SaveLoadCharacterNumbers[SaveLoadConversionRemainder])
            • Else - Actions
          • Set SaveLoadConversionInteger = SaveLoadConversionRemainder
      • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadTempStrings[10]
      • -------- Now to combine the current finished strings. --------
      • For each (Integer A) from 1 to SaveLoadMaxVariablesStored, do (Actions)
        • Loop - Actions
          • Set SaveLoadPreEncryptionString = (SaveLoadPreEncryptionString + SaveLoadTempStrings[(Integer A)])
      • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadPreEncryptionString
      • -------- Now to create a checksum for security, there are many ways to create this number. We will use the previous variables since its easy. --------
      • Set SaveLoadCheckSumInt = 0
      • For each (Integer A) from 1 to (Length of SaveLoadPreEncryptionString), do (Actions)
        • Loop - Actions
          • For each (Integer B) from 0 to (SaveLoadMaxCharacters - 1), do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Substring(SaveLoadPreEncryptionString, (Integer A), (Integer A))) Equal to SaveLoadCharacterNumbers[(Integer B)]
                • Then - Actions
                  • Set SaveLoadCheckSumInt = (SaveLoadCheckSumInt + (Integer B))
                  • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: (String(SaveLoadCheckSumInt))
                • Else - Actions
      • Set SaveLoadConversionInteger = SaveLoadCheckSumInt
      • Set SaveLoadConversionDividedInt = (SaveLoadConversionInteger / SaveLoadMaxCharacters)
      • Set SaveLoadConversionRemainder = (SaveLoadConversionInteger - (SaveLoadConversionDividedInt x SaveLoadMaxCharacters))
      • Set SaveLoadChecksumChar = SaveLoadCharacterNumbers[SaveLoadConversionRemainder]
      • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadChecksumChar
      • -------- Now we have all the characters ready to combine and encrypt fully, then package it pretty. --------
      • -------- This will convert the characters to the encrypted data set. It will also place a '-' every specified number of characters. --------
      • Set SaveLoadPreEncryptionString = (SaveLoadPreEncryptionString + SaveLoadChecksumChar)
      • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadPreEncryptionString
      • For each (Integer A) from 1 to (Length of SaveLoadPreEncryptionString), do (Actions)
        • Loop - Actions
          • For each (Integer B) from 0 to (SaveLoadMaxCharacters - 1), do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Substring(SaveLoadPreEncryptionString, (Integer A), (Integer A))) Equal to SaveLoadCharacterNumbers[(Integer B)]
                • Then - Actions
                  • Set SaveLoadEncryptedString = (SaveLoadEncryptedString + SaveLoadEncryptionNumbers[(Integer B)])
                • Else - Actions
          • Set SaveLoadConversionInteger = (Integer A)
          • Set SaveLoadConversionDividedInt = (SaveLoadConversionInteger / SaveLoadBlockSize)
          • Set SaveLoadConversionRemainder = (SaveLoadConversionInteger - (SaveLoadConversionDividedInt x SaveLoadBlockSize))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SaveLoadConversionRemainder Less than or equal to 0
            • Then - Actions
              • Set SaveLoadEncryptedString = (SaveLoadEncryptedString + -)
            • Else - Actions
      • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadEncryptedString
      • -------- Now for the final string, which will be the unencrypted key, and the rest of the encrypted information --------
      • Set SaveLoadFinalString = ((SaveLoadEncryptionKey + -) + SaveLoadEncryptedString)
      • -------- And now to broadcast all the hard work --------
      • Game - Display to SaveLoadPlayerGroupFocus for 300.00 seconds the text: SaveLoadFinalString
      • Player Group - Remove all players from SaveLoadPlayerGroupFocus
  • LoadModuleSingle
    • 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, 5)) Equal to -load
    • Actions
      • -------- This PlayerGroup is so you can broadcast the correct player the message in the end. --------
      • Player Group - Add (Triggering player) to SaveLoadPlayerGroupFocus
      • -------- This will confirm if the player has loaded before since last reset. --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SaveLoadHasLoaded[(Player number of (Triggering player))] Equal to True
        • Then - Actions
          • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: You have loaded you...
        • Else - Actions
      • -------- Decide how many variables the system will store --------
      • Set SaveLoadMaxVariablesStored = 10
      • -------- Default everything and load the basic stuff. Needs to happen each trigger activation or bad things happen. --------
      • Set SaveLoadTriggerErrored = False
      • Set SaveLoadChecksumChar = <Empty String>
      • Set SaveLoadEncryptedString = <Empty String>
      • Set SaveLoadEncryptionKey = <Empty String>
      • Set SaveLoadPreEncryptionString = <Empty String>
      • Set SaveLoadFinalString = <Empty String>
      • Set SaveLoadEncryptionKeyInt = 0
      • For each (Integer A) from 1 to SaveLoadMaxCharacters, do (Actions)
        • Loop - Actions
          • Set SaveLoadEncryptionNumbers[((Integer A) - 1)] = <Empty String>
      • For each (Integer A) from 1 to SaveLoadMaxVariablesStored, do (Actions)
        • Loop - Actions
          • Set SaveLoadTempStrings[(Integer A)] = <Empty String>
      • -------- Now we need to pick up our load code from the message --------
      • Set SaveLoadFinalString = (String((Substring((Entered chat string), 7, (Length of (Entered chat string))))) as Upper case)
      • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadFinalString
      • -------- Now we need to break the string into 2 parts, Encryption set number and encrypted string --------
      • Set SaveLoadEncryptionKey = (Substring(SaveLoadFinalString, 1, 1))
      • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadEncryptionKey
      • Set SaveLoadEncryptedString = (Substring(SaveLoadFinalString, 2, (Length of SaveLoadFinalString)))
      • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadEncryptedString
      • -------- Setup the encryption for use. --------
      • For each (Integer A) from 0 to (SaveLoadMaxCharacters - 1), do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SaveLoadEncryptionKey Equal to SaveLoadCharacterNumbers[(Integer A)]
            • Then - Actions
              • Set SaveLoadEncryptionKeyInt = (Integer A)
              • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: (String(SaveLoadEncryptionKeyInt))
            • Else - Actions
      • For each (Integer A) from 1 to SaveLoadMaxCharacters, do (Actions)
        • Loop - Actions
          • Set SaveLoadEncryptionNumbers[((Integer A) - 1)] = (Substring(SaveLoadEncryptionSet[SaveLoadEncryptionKeyInt], (Integer A), (Integer A)))
      • -------- Now to Decrypt the Encrypted Section and remove the Dashes --------
      • Set SaveLoadPreEncryptionString = <Empty String>
      • For each (Integer A) from 1 to (Length of SaveLoadEncryptedString), do (Actions)
        • Loop - Actions
          • For each (Integer B) from 0 to (SaveLoadMaxCharacters - 1), do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Substring(SaveLoadEncryptedString, (Integer A), (Integer A))) Equal to SaveLoadEncryptionNumbers[(Integer B)]
                • Then - Actions
                  • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadCharacterNumbers[(Integer B)]
                  • Set SaveLoadPreEncryptionString = (SaveLoadPreEncryptionString + SaveLoadCharacterNumbers[(Integer B)])
                • Else - Actions
      • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadPreEncryptionString
      • -------- Now to seperate the strings out before reading --------
      • -------- Workaround for a bug involving String length being used twice in an action. --------
      • Set IntegerC = (Length of SaveLoadPreEncryptionString)
      • Set SaveLoadChecksumChar = (String((Substring(SaveLoadPreEncryptionString, IntegerC, IntegerC))) as Upper case)
      • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: (SaveLoadChecksumChar + = From Load)
      • Set SaveLoadPreEncryptionString = (Substring(SaveLoadPreEncryptionString, 1, ((Length of SaveLoadPreEncryptionString) - 1)))
      • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadPreEncryptionString
      • -------- Verify the Checksum to prove the code is correct. 1:MaxChars chance of being an error that would allow code to process. --------
      • Set SaveLoadCheckSumInt = 0
      • For each (Integer A) from 1 to (Length of SaveLoadPreEncryptionString), do (Actions)
        • Loop - Actions
          • For each (Integer B) from 0 to (SaveLoadMaxCharacters - 1), do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Substring(SaveLoadPreEncryptionString, (Integer A), (Integer A))) Equal to SaveLoadCharacterNumbers[(Integer B)]
                • Then - Actions
                  • Set SaveLoadCheckSumInt = (SaveLoadCheckSumInt + (Integer B))
                  • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: (String(SaveLoadCheckSumInt))
                • Else - Actions
      • Set SaveLoadConversionInteger = SaveLoadCheckSumInt
      • Set SaveLoadConversionDividedInt = (SaveLoadConversionInteger / SaveLoadMaxCharacters)
      • Set SaveLoadConversionRemainder = (SaveLoadConversionInteger - (SaveLoadConversionDividedInt x SaveLoadMaxCharacters))
      • Set SaveLoadChecksumCharCompare = SaveLoadCharacterNumbers[SaveLoadConversionRemainder]
      • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: (SaveLoadChecksumCharCompare + = Compare)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SaveLoadChecksumChar Not equal to SaveLoadChecksumCharCompare
        • Then - Actions
          • Game - Display to SaveLoadPlayerGroupFocus the text: Either your code is...
          • Set SaveLoadTriggerErrored = True
        • Else - Actions
      • -------- This IF is to make sure once they fail the checksum they cannot continue through the trigger. --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SaveLoadHasLoaded[(Player number of (Triggering player))] Equal to False
          • SaveLoadTriggerErrored Equal to False
        • Then - Actions
          • -------- Need to break each part of the String apart to each variable stored. --------
          • Set IntegerC = 1
          • -------- First the hero type --------
          • Set SaveLoadTempStrings[1] = (Substring(SaveLoadPreEncryptionString, IntegerC, (IntegerC + (SaveLoadSlotsHero - 1))))
          • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadTempStrings[1]
          • Set IntegerC = (IntegerC + SaveLoadSlotsHero)
          • -------- Now the Hero level --------
          • Set SaveLoadTempStrings[2] = (Substring(SaveLoadPreEncryptionString, IntegerC, (IntegerC + (SaveLoadSlotsHeroLevel - 1))))
          • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadTempStrings[2]
          • Set IntegerC = (IntegerC + SaveLoadSlotsHeroLevel)
          • -------- now the Items X6 --------
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • Set SaveLoadTempStrings[((Integer A) + 2)] = (Substring(SaveLoadPreEncryptionString, IntegerC, (IntegerC + (SaveLoadSlotsItem - 1))))
              • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadTempStrings[((Integer A) + 2)]
              • Set IntegerC = (IntegerC + SaveLoadSlotsItem)
          • -------- Now the Player Gold --------
          • Set SaveLoadTempStrings[9] = (Substring(SaveLoadPreEncryptionString, IntegerC, (IntegerC + (SaveLoadSlotsGold - 1))))
          • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadTempStrings[9]
          • Set IntegerC = (IntegerC + SaveLoadSlotsGold)
          • -------- Finally the lumber --------
          • Set SaveLoadTempStrings[10] = (Substring(SaveLoadPreEncryptionString, IntegerC, (IntegerC + (SaveLoadSlotsLumber - 1))))
          • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: SaveLoadTempStrings[10]
          • Set IntegerC = (IntegerC + SaveLoadSlotsLumber)
          • -------- Start performing actions and building the players stuff --------
          • -------- The ReBirth of a Hero! --------
          • Set SaveLoadMultiple = 0
          • For each (Integer A) from 1 to SaveLoadSlotsHero, do (Actions)
            • Loop - Actions
              • Set SaveLoadPowerOfMaxNumber = 1
              • For each (Integer B) from (Integer A) to (SaveLoadSlotsHero - 1), do (Actions)
                • Loop - Actions
                  • Set SaveLoadPowerOfMaxNumber = (SaveLoadPowerOfMaxNumber x SaveLoadMaxCharacters)
              • For each (Integer B) from 0 to (SaveLoadMaxCharacters - 1), do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Substring(SaveLoadTempStrings[1], (Integer A), (Integer A))) Equal to SaveLoadCharacterNumbers[(Integer B)]
                    • Then - Actions
                      • Set SaveLoadMultiple = (SaveLoadMultiple + ((Integer B) x SaveLoadPowerOfMaxNumber))
                    • Else - Actions
          • Unit - Create 1 SaveLoadHeroesStored[SaveLoadMultiple] for (Triggering player) at (Center of Regions[1]) facing 270.00 degrees
          • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: (String(SaveLoadMultiple))
          • Set SaveLoadPlayerHeroSingle[(Player number of (Triggering player))] = (Last created unit)
          • -------- Give that man a raise! --------
          • Set SaveLoadMultiple = 0
          • For each (Integer A) from 1 to SaveLoadSlotsHeroLevel, do (Actions)
            • Loop - Actions
              • Set SaveLoadPowerOfMaxNumber = 1
              • For each (Integer B) from (Integer A) to (SaveLoadSlotsHeroLevel - 1), do (Actions)
                • Loop - Actions
                  • Set SaveLoadPowerOfMaxNumber = (SaveLoadPowerOfMaxNumber x SaveLoadMaxCharacters)
              • For each (Integer B) from 0 to (SaveLoadMaxCharacters - 1), do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Substring(SaveLoadTempStrings[2], (Integer A), (Integer A))) Equal to SaveLoadCharacterNumbers[(Integer B)]
                    • Then - Actions
                      • Set SaveLoadMultiple = (SaveLoadMultiple + ((Integer B) x SaveLoadPowerOfMaxNumber))
                    • Else - Actions
          • Hero - Set SaveLoadPlayerHeroSingle[(Player number of (Triggering player))] Hero-level to SaveLoadMultiple, Hide level-up graphics
          • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: (String(SaveLoadMultiple))
          • -------- Time to Accessorize! --------
          • For each (Integer IntegerC) from 1 to 6, do (Actions)
            • Loop - Actions
              • Set SaveLoadMultiple = 0
              • For each (Integer A) from 1 to SaveLoadSlotsItem, do (Actions)
                • Loop - Actions
                  • Set SaveLoadPowerOfMaxNumber = 1
                  • For each (Integer B) from (Integer A) to (SaveLoadSlotsItem - 1), do (Actions)
                    • Loop - Actions
                      • Set SaveLoadPowerOfMaxNumber = (SaveLoadPowerOfMaxNumber x SaveLoadMaxCharacters)
                  • For each (Integer B) from 0 to (SaveLoadMaxCharacters - 1), do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Substring(SaveLoadTempStrings[(IntegerC + 2)], (Integer A), (Integer A))) Equal to SaveLoadCharacterNumbers[(Integer B)]
                        • Then - Actions
                          • Set SaveLoadMultiple = (SaveLoadMultiple + ((Integer B) x SaveLoadPowerOfMaxNumber))
                        • Else - Actions
              • Hero - Create SaveLoadItemsStored[SaveLoadMultiple] and give it to SaveLoadPlayerHeroSingle[(Player number of (Triggering player))]
              • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: (String(SaveLoadMultiple))
          • -------- Show me the money! --------
          • Set SaveLoadMultiple = 0
          • For each (Integer A) from 1 to SaveLoadSlotsGold, do (Actions)
            • Loop - Actions
              • Set SaveLoadPowerOfMaxNumber = 1
              • For each (Integer B) from (Integer A) to (SaveLoadSlotsGold - 1), do (Actions)
                • Loop - Actions
                  • Set SaveLoadPowerOfMaxNumber = (SaveLoadPowerOfMaxNumber x SaveLoadMaxCharacters)
              • For each (Integer B) from 0 to (SaveLoadMaxCharacters - 1), do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Substring(SaveLoadTempStrings[9], (Integer A), (Integer A))) Equal to SaveLoadCharacterNumbers[(Integer B)]
                    • Then - Actions
                      • Set SaveLoadMultiple = (SaveLoadMultiple + ((Integer B) x SaveLoadPowerOfMaxNumber))
                    • Else - Actions
          • Player - Set (Triggering player) Current gold to SaveLoadMultiple
          • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: (String(SaveLoadMultiple))
          • -------- How much wood could a woodchuck chuck, if a woodchuck could chuck wood? --------
          • Set SaveLoadMultiple = 0
          • For each (Integer A) from 1 to SaveLoadSlotsLumber, do (Actions)
            • Loop - Actions
              • Set SaveLoadPowerOfMaxNumber = 1
              • For each (Integer B) from (Integer A) to (SaveLoadSlotsLumber - 1), do (Actions)
                • Loop - Actions
                  • Set SaveLoadPowerOfMaxNumber = (SaveLoadPowerOfMaxNumber x SaveLoadMaxCharacters)
              • For each (Integer B) from 0 to (SaveLoadMaxCharacters - 1), do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Substring(SaveLoadTempStrings[10], (Integer A), (Integer A))) Equal to SaveLoadCharacterNumbers[(Integer B)]
                    • Then - Actions
                      • Set SaveLoadMultiple = (SaveLoadMultiple + ((Integer B) x SaveLoadPowerOfMaxNumber))
                    • Else - Actions
          • Player - Set (Triggering player) Current lumber to SaveLoadMultiple
          • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: (String(SaveLoadMultiple))
          • -------- All done, now to tell the player how good we did! --------
          • Set SaveLoadHasLoaded[(Integer A)] = False
          • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: Load Successful. We...
        • Else - Actions
          • Game - Display to SaveLoadPlayerGroupFocus for 30.00 seconds the text: Load Unsuccessful! ...
      • Player Group - Remove all players from SaveLoadPlayerGroupFocus

okay i need this to save spells aswell (11 spells if possible), it will go up in the int part but can someone just help me so i know i'm not messing up with it?
 
Level 3
Joined
Dec 6, 2005
Messages
67
lol odd approach, but i had a system lying around that will take a series of alphanumeric strings with a given separator and return an array of integers. If someone can convert it from php to JASS i think it'd solve his problem
Code:
$library = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$alpha_size = strlen($library);

	function save_code($int){
	global $library, $alpha_size;
	$int = explode('-',$int);
	$output = '';
	for($c=0; $c < count($int); $c++){
		$partial = '';	
		$exponent = 0;	
			while(pow($alpha_size,$exponent+1) <= $int[$c]){
			$exponent++;
			}			
			for($exponent; $exponent >= 0; $exponent--){
			$temp = $int[$c]/pow($alpha_size,$exponent);
			$int[$c] = $int[$c] % pow($alpha_size,$exponent);
			$partial .= $library{$temp};
			}
		while(strlen($partial) < 4){
		$partial = '0'.$partial;
		}
	$output .= $partial;	
	}	
	return $output;	
	}

	function load_code($save_code){
	global $library, $alpha_size;
		for($c=0; $c+4 <= strlen($save_code); $c+=4){
		$codes[] = substr($save_code,$c,4);
		}
		for($i=0; $i < count($codes); $i++){
			$exponent = strlen($codes[$i])-1;
			$num = 0;
			$value = 0;
			for($exponent; $exponent >= 0; $exponent--){
				for($c=0; $c < $alpha_size; $c++){
					if($library{$c} === $codes[$i]{strlen($codes[$i])-1-$exponent}){
					$value = $c;
					}		
				}
			$num = $num +($value*pow($alpha_size,$exponent)); 	
			}
		$output[] = $num;	
		}
	return $output;
	}

looking it over i think the only thing that won't translate directly is the explode() function, breaks string into pieces based on a given delimiter
 
Status
Not open for further replies.
Top