- Joined
- Mar 15, 2012
- Messages
- 2,878
Well I finally got items to save and load working again after a while...
Now it won't save and load stats properly, but it does everything else correctly.
The events are added from another trigger, so that is not the reason this doesn't work.
[TRIGGER=]Save
Events
Conditions
Actions
-------- Prepare the save array with this player's Hero --------
Set SaveCount = 0
-------- Take all Heroes (assumes there is only one) --------
Unit Group - Pick every unit in (Units owned by (Triggering player) matching ((((Matching unit) is A Hero) Equal to True) and ((Unit-type of (Matching unit)) Not equal to Picker))) and do (Actions)
Loop - Actions
-------- Save the Hero --------
Set SaveCount = (SaveCount + 1)
Set TempUnit = (Picked unit)
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Unit2Integer( udg_TempUnit )
-------- Hero level --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Hero experience of (Picked unit))
-------- Hero stats --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = saveagi[(Player number of (Owner of (Picked unit)))]
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = saveint[(Player number of (Owner of (Picked unit)))]
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = savestr[(Player number of (Owner of (Picked unit)))]
-------- How many items does he carry --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Number of items carried by (Picked unit))
-------- Add all items --------
Set SaveCount = (SaveCount + 1)
Set TempItem = (Item carried by (Picked unit) in slot 1)
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Charges remaining in (Item carried by (Picked unit) in slot 1))
Set SaveCount = (SaveCount + 1)
Set TempItem = (Item carried by (Picked unit) in slot 2)
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
Set SaveCount = (SaveCount + 1)
Set TempItem = (Item carried by (Picked unit) in slot 3)
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
Set SaveCount = (SaveCount + 1)
Set TempItem = (Item carried by (Picked unit) in slot 4)
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
Set SaveCount = (SaveCount + 1)
Set TempItem = (Item carried by (Picked unit) in slot 5)
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
Set SaveCount = (SaveCount + 1)
Set TempItem = (Item carried by (Picked unit) in slot 6)
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Item carried by (Picked unit) in slot (Integer A)) is owned) Equal to True
Then - Actions
-------- The actual item --------
Set SaveCount = (SaveCount + 1)
Set TempItem = (Item carried by (Picked unit) in slot (Integer A))
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
-------- The number of charges it has --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Charges remaining in (Item carried by (Picked unit) in slot (Integer A)))
Else - Actions
-------- 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
Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: You can also look i...
[/TRIGGER]
[TRIGGER=]Load
Events
Conditions
(Substring((Entered chat string), 1, 6)) Equal to (Matched chat string)
(Length of (Entered chat string)) Greater than 6
((Triggering player) is in loaders) Equal to True
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 --------
Player Group - Remove (Triggering player) from new
Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
Loop - Actions
Unit - Remove (Picked unit) from the game
Set SaveCount = 1
Custom script: set udg_TempUnitType = SaveLoad_Integer2Unit(udg_Save[udg_SaveCount])
Unit - Create 1 TempUnitType for (Triggering player) at (Random point in Region 009 <gen>) facing Default building facing degrees
Unit - Set level of Bite werewolf for (Last created unit) to 2
Unit - Set level of Bite wyvern for (Last created unit) to 2
Unit - Set level of Fregar for (Last created unit) to 3
Set SaveCount = (SaveCount + 1)
Hero - Set (Last created unit) experience to Save[SaveCount], Hide level-up graphics
-------- Hero stats --------
Set SaveCount = (SaveCount + 1)
Hero - Modify Agility of (Last created unit): Add Save[SaveCount]
Set SaveCount = (SaveCount + 1)
Hero - Modify Intelligence of (Last created unit): Add Save[SaveCount]
Set SaveCount = (SaveCount + 1)
Hero - Modify Strength of (Last created unit): Add Save[SaveCount]
-------- Hero stats --------
Set SaveCount = (SaveCount + 1)
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
Hero - Create TempItemType and give it to (Last created unit)
-------- item --------
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
Hero - Create TempItemType and give it to (Last created unit)
-------- item --------
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
Hero - Create TempItemType and give it to (Last created unit)
-------- item --------
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
Hero - Create TempItemType and give it to (Last created unit)
-------- item --------
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
Hero - Create TempItemType and give it to (Last created unit)
-------- item --------
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
Hero - Create TempItemType and give it to (Last created unit)
-------- item --------
Set SaveCount = (SaveCount + 1)
Item - Set charges remaining in (Last created item) to Save[SaveCount]
Player - Add -10 to (Triggering player) Current lumber
Player Group - Remove (Triggering player) from loaders
[/TRIGGER]
EDIT: It can't take number values past 400 it seems.... I thought it supported more then 30 items and past 400..... owell. Anyone know of a way to fix this?
Now it won't save and load stats properly, but it does everything else correctly.
The events are added from another trigger, so that is not the reason this doesn't work.
[TRIGGER=]Save
Events
Conditions
Actions
-------- Prepare the save array with this player's Hero --------
Set SaveCount = 0
-------- Take all Heroes (assumes there is only one) --------
Unit Group - Pick every unit in (Units owned by (Triggering player) matching ((((Matching unit) is A Hero) Equal to True) and ((Unit-type of (Matching unit)) Not equal to Picker))) and do (Actions)
Loop - Actions
-------- Save the Hero --------
Set SaveCount = (SaveCount + 1)
Set TempUnit = (Picked unit)
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Unit2Integer( udg_TempUnit )
-------- Hero level --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Hero experience of (Picked unit))
-------- Hero stats --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = saveagi[(Player number of (Owner of (Picked unit)))]
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = saveint[(Player number of (Owner of (Picked unit)))]
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = savestr[(Player number of (Owner of (Picked unit)))]
-------- How many items does he carry --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Number of items carried by (Picked unit))
-------- Add all items --------
Set SaveCount = (SaveCount + 1)
Set TempItem = (Item carried by (Picked unit) in slot 1)
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Charges remaining in (Item carried by (Picked unit) in slot 1))
Set SaveCount = (SaveCount + 1)
Set TempItem = (Item carried by (Picked unit) in slot 2)
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
Set SaveCount = (SaveCount + 1)
Set TempItem = (Item carried by (Picked unit) in slot 3)
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
Set SaveCount = (SaveCount + 1)
Set TempItem = (Item carried by (Picked unit) in slot 4)
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
Set SaveCount = (SaveCount + 1)
Set TempItem = (Item carried by (Picked unit) in slot 5)
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
Set SaveCount = (SaveCount + 1)
Set TempItem = (Item carried by (Picked unit) in slot 6)
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Item carried by (Picked unit) in slot (Integer A)) is owned) Equal to True
Then - Actions
-------- The actual item --------
Set SaveCount = (SaveCount + 1)
Set TempItem = (Item carried by (Picked unit) in slot (Integer A))
Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
-------- The number of charges it has --------
Set SaveCount = (SaveCount + 1)
Set Save[SaveCount] = (Charges remaining in (Item carried by (Picked unit) in slot (Integer A)))
Else - Actions
-------- 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
Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: You can also look i...
[/TRIGGER]
[TRIGGER=]Load
Events
Conditions
(Substring((Entered chat string), 1, 6)) Equal to (Matched chat string)
(Length of (Entered chat string)) Greater than 6
((Triggering player) is in loaders) Equal to True
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 --------
Player Group - Remove (Triggering player) from new
Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
Loop - Actions
Unit - Remove (Picked unit) from the game
Set SaveCount = 1
Custom script: set udg_TempUnitType = SaveLoad_Integer2Unit(udg_Save[udg_SaveCount])
Unit - Create 1 TempUnitType for (Triggering player) at (Random point in Region 009 <gen>) facing Default building facing degrees
Unit - Set level of Bite werewolf for (Last created unit) to 2
Unit - Set level of Bite wyvern for (Last created unit) to 2
Unit - Set level of Fregar for (Last created unit) to 3
Set SaveCount = (SaveCount + 1)
Hero - Set (Last created unit) experience to Save[SaveCount], Hide level-up graphics
-------- Hero stats --------
Set SaveCount = (SaveCount + 1)
Hero - Modify Agility of (Last created unit): Add Save[SaveCount]
Set SaveCount = (SaveCount + 1)
Hero - Modify Intelligence of (Last created unit): Add Save[SaveCount]
Set SaveCount = (SaveCount + 1)
Hero - Modify Strength of (Last created unit): Add Save[SaveCount]
-------- Hero stats --------
Set SaveCount = (SaveCount + 1)
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
Hero - Create TempItemType and give it to (Last created unit)
-------- item --------
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
Hero - Create TempItemType and give it to (Last created unit)
-------- item --------
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
Hero - Create TempItemType and give it to (Last created unit)
-------- item --------
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
Hero - Create TempItemType and give it to (Last created unit)
-------- item --------
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
Hero - Create TempItemType and give it to (Last created unit)
-------- item --------
Set SaveCount = (SaveCount + 1)
Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
Hero - Create TempItemType and give it to (Last created unit)
-------- item --------
Set SaveCount = (SaveCount + 1)
Item - Set charges remaining in (Last created item) to Save[SaveCount]
Player - Add -10 to (Triggering player) Current lumber
Player Group - Remove (Triggering player) from loaders
[/TRIGGER]
EDIT: It can't take number values past 400 it seems.... I thought it supported more then 30 items and past 400..... owell. Anyone know of a way to fix this?
Last edited: