| 11-01-2004, 12:55 AM | #1 |
Hey im makeing a save/load code for my game and am running to to a few problems. I think i got most under controll but i cant get the item saveing to stay stable. Ok im gona post my trigger in a sec but let me explain some simple things to it first. The variable "Alphabet" is as it sounds just a string of the uppercase alphabet. Also all the items are saved in arrays in another trigger. They way i did this was set the first number of the array to represent a number and the second one or two diget number represents a letter in the alphabet which is converted in the save code. Ok so the code runs perfectly as long as there are no more then 4 items in your hero's inventory but if there are 5 or 6 it breaks. So to see where it breaks i put the "Game - Display to (All players) the text: ((((()))))" in every now and then. When there are 5 items in the hero's inventory it displays 5 ((((()))))s and when there are 6 it displays 4. So can anyone tell me wtf is roung with it lol. Ok so heres the code: Code:
NewSave
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 10 (Light Blue) types a chat message containing -save as An exact match
Player - Player 11 (Dark Green) types a chat message containing -save as An exact match
Conditions
Actions
Set SavePass = <Empty String>
Game - Display to (All players) the text: ((((()))))
For each (Integer A) from 1 to 100, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Hero level of Hero_of_Player[(Player number of (Triggering player))]) Equal to (Integer A)
Then - Actions
Set LevelBefore = (String((Integer A)))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(String((Length of LevelBefore))) Equal to 1
Then - Actions
Set LevelBefore = (0 + (String((Integer A))))
Else - Actions
Set LevelBefore2 = (Substring(LevelBefore, 1, ((Length of LevelBefore) - 1)))
For each (Integer B) from 0 to 10, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
LevelBefore2 Equal to (String((Integer B)))
Then - Actions
Set SaveParts[4] = (Substring(Alphabet, (((Integer B) + 1) x 2), (((Integer B) + 1) x 2)))
Else - Actions
Set SaveParts[3] = (Substring(LevelBefore, (Length of LevelBefore), (Length of LevelBefore)))
Else - Actions
Game - Display to (All players) the text: ((((()))))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of Hero_of_Player[(Player number of (Triggering player))]) Equal to White Sorceress
Then - Actions
Set SaveParts[9] = 1
Set SaveParts[10] = B
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of Hero_of_Player[(Player number of (Triggering player))]) Equal to Human Warrior
Then - Actions
Set SaveParts[9] = 2
Set SaveParts[10] = D
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of Hero_of_Player[(Player number of (Triggering player))]) Equal to Rifleman
Then - Actions
Set SaveParts[9] = 3
Set SaveParts[10] = F
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of Hero_of_Player[(Player number of (Triggering player))]) Equal to Cleric
Then - Actions
Set SaveParts[9] = 4
Set SaveParts[10] = H
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of Hero_of_Player[(Player number of (Triggering player))]) Equal to Black Wizard
Then - Actions
Set SaveParts[9] = 5
Set SaveParts[10] = J
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of Hero_of_Player[(Player number of (Triggering player))]) Equal to Necromancer
Then - Actions
Set SaveParts[9] = 6
Set SaveParts[10] = L
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of Hero_of_Player[(Player number of (Triggering player))]) Equal to Undead Warrior
Then - Actions
Set SaveParts[9] = 7
Set SaveParts[10] = N
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of Hero_of_Player[(Player number of (Triggering player))]) Equal to Dark Ranger
Then - Actions
Set SaveParts[9] = 8
Set SaveParts[10] = P
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of Hero_of_Player[(Player number of (Triggering player))]) Equal to Red Wizard
Then - Actions
Set SaveParts[9] = 9
Set SaveParts[10] = R
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of Hero_of_Player[(Player number of (Triggering player))]) Equal to Shaman
Then - Actions
Set SaveParts[9] = 1
Set SaveParts[10] = U
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of Hero_of_Player[(Player number of (Triggering player))]) Equal to Wood Elf Ranger
Then - Actions
Set SaveParts[9] = 2
Set SaveParts[10] = X
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of Hero_of_Player[(Player number of (Triggering player))]) Equal to Orc Warrior
Then - Actions
Set SaveParts[9] = 3
Set SaveParts[10] = G
Else - Actions
Game - Display to (All players) the text: ((((()))))
Game - Display to (All players) the text: ((((()))))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item carried by Hero_of_Player[(Player number of (Triggering player))] in slot 1) Equal to No item
Then - Actions
Set SaveParts[1] = 0
Set SaveParts[2] = Z
Else - Actions
For each (Integer B) from 11 to 926, 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 Hero_of_Player[(Player number of (Triggering player))] in slot 1)) Equal to SaveItem[(Integer B)]
Then - Actions
Set SaveParts[1] = (Substring((String((Integer B))), 1, 1))
Set SaveParts[2] = (Substring(Alphabet, (Integer((Substring((String((Integer B))), 2, (Length of (String((Integer B)))))))), (Integer((Substring((String((Integer B))), 2, (Length of (String((Integer B))))))))))
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item carried by Hero_of_Player[(Player number of (Triggering player))] in slot 2) Equal to No item
Then - Actions
Set SaveParts[5] = 0
Set SaveParts[6] = Z
Else - Actions
For each (Integer B) from 11 to 926, 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 Hero_of_Player[(Player number of (Triggering player))] in slot 2)) Equal to SaveItem[(Integer B)]
Then - Actions
Set SaveParts[5] = (Substring((String((Integer B))), 1, 1))
Set SaveParts[6] = (Substring(Alphabet, (Integer((Substring((String((Integer B))), 2, (Length of (String((Integer B)))))))), (Integer((Substring((String((Integer B))), 2, (Length of (String((Integer B))))))))))
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item carried by Hero_of_Player[(Player number of (Triggering player))] in slot 3) Equal to No item
Then - Actions
Set SaveParts[7] = 0
Set SaveParts[8] = Z
Else - Actions
For each (Integer B) from 11 to 926, 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 Hero_of_Player[(Player number of (Triggering player))] in slot 3)) Equal to SaveItem[(Integer B)]
Then - Actions
Set SaveParts[7] = (Substring((String((Integer B))), 1, 1))
Set SaveParts[8] = (Substring(Alphabet, (Integer((Substring((String((Integer B))), 2, (Length of (String((Integer B)))))))), (Integer((Substring((String((Integer B))), 2, (Length of (String((Integer B))))))))))
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item carried by Hero_of_Player[(Player number of (Triggering player))] in slot 4) Equal to No item
Then - Actions
Set SaveParts[11] = 0
Set SaveParts[12] = Z
Else - Actions
For each (Integer B) from 11 to 926, 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 Hero_of_Player[(Player number of (Triggering player))] in slot 4)) Equal to SaveItem[(Integer B)]
Then - Actions
Set SaveParts[11] = (Substring((String((Integer B))), 1, 1))
Set SaveParts[12] = (Substring(Alphabet, (Integer((Substring((String((Integer B))), 2, (Length of (String((Integer B)))))))), (Integer((Substring((String((Integer B))), 2, (Length of (String((Integer B))))))))))
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item carried by Hero_of_Player[(Player number of (Triggering player))] in slot 5) Equal to No item
Then - Actions
Set SaveParts[13] = 0
Set SaveParts[14] = Z
Else - Actions
For each (Integer B) from 11 to 926, 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 Hero_of_Player[(Player number of (Triggering player))] in slot 5)) Equal to SaveItem[(Integer B)]
Then - Actions
Set SaveParts[13] = (Substring((String((Integer B))), 1, 1))
Set SaveParts[14] = (Substring(Alphabet, (Integer((Substring((String((Integer B))), 2, (Length of (String((Integer B)))))))), (Integer((Substring((String((Integer B))), 2, (Length of (String((Integer B))))))))))
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item carried by Hero_of_Player[(Player number of (Triggering player))] in slot 6) Equal to No item
Then - Actions
Set SaveParts[17] = 0
Set SaveParts[18] = Z
Else - Actions
For each (Integer B) from 11 to 926, 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 Hero_of_Player[(Player number of (Triggering player))] in slot 6)) Equal to SaveItem[(Integer B)]
Then - Actions
Set SaveParts[17] = (Substring((String((Integer B))), 1, 1))
Set SaveParts[18] = (Substring(Alphabet, (Integer((Substring((String((Integer B))), 2, (Length of (String((Integer B)))))))), (Integer((Substring((String((Integer B))), 2, (Length of (String((Integer B))))))))))
Else - Actions
Game - Display to (All players) the text: ((((()))))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Center X of HomePoint[(Player number of (Triggering player))]) Equal to (Center X of Hero Start <gen>)
Then - Actions
Set SaveParts[15] = 2
Set SaveParts[16] = R
Else - Actions
Game - Display to (All players) the text: ((((()))))
Set SaveParts[19] = (String((9 - (Integer(SaveParts[3])))))
Set SaveParts[21] = (String((9 - (Integer(SaveParts[9])))))
Set SaveParts[23] = (String((9 - (Integer(SaveParts[15])))))
For each (Integer A) from 1 to 3, do (Actions)
Loop - Actions
For each (Integer B) from 1 to 26, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SaveParts[((Integer A) x 4)] Equal to (Substring(Alphabet, (Integer B), (Integer B)))
Then - Actions
Set SaveParts[(26 - ((Integer A) x 2))] = (Substring(Alphabet, (27 - (Integer B)), (27 - (Integer B))))
Else - Actions
Game - Display to (All players) the text: ((((()))))
For each (Integer A) from 1 to 12, do (Actions)
Loop - Actions
Set SaveParts[((Integer A) x 2)] = ((|cffff8c00 + SaveParts[((Integer A) x 2)]) + |r)
Set SaveParts[(((Integer A) x 2) - 1)] = ((|cff0000ff + SaveParts[(((Integer A) x 2) - 1)]) + |r)
For each (Integer A) from 1 to 24, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Integer A) Equal to 6
(Integer A) Equal to 12
(Integer A) Equal to 18
Then - Actions
Set SavePass = (SavePass + (SaveParts[(Integer A)] + -))
Else - Actions
Set SavePass = (SavePass + (SaveParts[(Integer A)] + <Empty String>))
Game - Display to (Player group((Triggering player))) for 45.00 seconds the text: (SavePass + is your password. Type -load then your password to load this hero.) Yea some of my code is wierd but if you see why its being strange please respond. Thank you |
