• 🏆 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!

Save/load system (Aceharts) fixing the item charges.

Status
Not open for further replies.
Level 8
Joined
Apr 8, 2009
Messages
499
Hey guys, i need some help on the triggers for saving/loading the amount of charges a item has.

  • SaveLoad Save Property
    • 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
    • Conditions
    • Actions
      • -------- Prepare the save array with this player's Hero --------
      • Set SaveCount = 0
      • -------- Player's Gold --------
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = ((Triggering player) Current gold)
      • -------- Player's Lumber --------
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = ((Triggering player) Current lumber)
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching ((Matching unit) Equal to Player_Hero_Array[(Player number of (Triggering player))])) 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 Experience --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Hero experience of (Picked unit))
          • -------- Add all items --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Number of items carried by (Picked unit))
          • For each (Integer Integer_A_Replacement) 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_Replacement) 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_Replacement)
                  • 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 Integer_A_Replacement))
                • 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
  • SaveLoad Load Property
    • 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
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to (Matched chat string)
      • (Length of (Entered chat string)) Greater than 6
    • 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 --------
      • Set SaveCount = 1
      • -------- Restore Gold --------
      • Player - Set (Triggering player) Current gold to Save[SaveCount]
      • Set SaveCount = (SaveCount + 1)
      • -------- Restore Lumber --------
      • Player - Set (Triggering player) Current lumber to Save[SaveCount]
      • 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
      • For each (Integer B) from 1 to 1, do (Actions)
        • Loop - Actions
          • -------- Restore Hero --------
          • Set SaveCount = (SaveCount + 1)
          • Custom script: set udg_TempUnitType = SaveLoad_Integer2Unit(udg_Save[udg_SaveCount])
          • Unit - Create 1 TempUnitType for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
          • -------- Set Experience --------
          • Set SaveCount = (SaveCount + 1)
          • Hero - Set (Last created unit) experience to Save[SaveCount], Hide level-up graphics
          • Set SaveCount = (SaveCount + 1)
          • For each (Integer Integer_A_Replacement) from 1 to Save[SaveCount], do (Actions)
            • Loop - Actions
              • -------- The actual 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)
              • Set SaveCount = (SaveCount + 1)
              • Item - Set charges remaining in (Last created item) to Save[SaveCount]
so far when testing, this is what happens:

-If i have 5 different potions with different amounts of charges, it saves/loads correctly.
-If i have 5 different potions with different amounts of charges And a non-charged item in the 6th slot, only the 5 potions will be loaded.
-If i move the non-charged item to the 3rd slot and have the potions occupying the other 5 slots, only the first 3 slots will get loaded.

My guess: the trigger has problems reading non-charged items as a 1 charge and will set automaticly set it to 0 or whatever. not sure about it o_O" .

if anyone is able to help me with this, +rep ofc ^___^
 
I know use an if-then-else, so if the item has no charge, save 1 as the value but if it has a charge, then save the charge...

  • -------- The actual item --------
  • Set SaveCount = (SaveCount + 1)
  • Set TempItem = (Item carried by (Picked unit) in slot Integer_A_Replacement)
  • Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
  • Set SaveCount = (SaveCount + 1)
  • If-then-else
    • If - Conditions
      • Charges remaining in (Item carried by (Picked unit) in slot Integer_A_Replacement) is greater than 0
    • Then-Actions
      • Set Save[SaveCount] = (Charges remaining in (Item carried by (Picked unit) in slot Integer_A_Replacement))
    • Else - Actions
      • Set Save[SaveCount] = 1
  • Else - Actions
 
Level 8
Joined
Apr 8, 2009
Messages
499
why don't you try to make save a "bonus" variabile ?

what?



I know use an if-then-else, so if the item has no charge, save 1 as the value but if it has a charge, then save the charge...

  • -------- The actual item --------
  • Set SaveCount = (SaveCount + 1)
  • Set TempItem = (Item carried by (Picked unit) in slot Integer_A_Replacement)
  • Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
  • Set SaveCount = (SaveCount + 1)
  • If-then-else
    • If - Conditions
      • Charges remaining in (Item carried by (Picked unit) in slot Integer_A_Replacement) is greater than 0
    • Then-Actions
      • Set Save[SaveCount] = (Charges remaining in (Item carried by (Picked unit) in slot Integer_A_Replacement))
    • Else - Actions
      • Set Save[SaveCount] = 1
  • Else - Actions

thought i'd have to use an if/then/else, but didn't exactly know how to put it in there, tyvm i'll try it out now. will report back in a few minutes ^___^


----EDIT----

tried it with 5 different potions with different charges, will only load 3 of the 5 potions for some reason o_O;;

  • SaveLoad Save Property
    • 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
    • Conditions
    • Actions
      • -------- Prepare the save array with this player's Hero --------
      • Set SaveCount = 0
      • -------- Player's Gold --------
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = ((Triggering player) Current gold)
      • -------- Player's Lumber --------
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = ((Triggering player) Current lumber)
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching ((Matching unit) Equal to Player_Hero_Array[(Player number of (Triggering player))])) 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 Experience --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Hero experience of (Picked unit))
          • -------- Add all items --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Number of items carried by (Picked unit))
          • For each (Integer Integer_A_Replacement) 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_Replacement) 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_Replacement)
                  • Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
                  • Set SaveCount = (SaveCount + 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Charges remaining in (Item carried by (Picked unit) in slot Integer_A_Replacement)) Greater than 0
                    • Then - Actions
                      • Set Save[SaveCount] = (Charges remaining in (Item carried by (Picked unit) in slot Integer_A_Replacement))
                    • Else - Actions
                      • Set Save[SaveCount] = 1
                • 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
 
Level 11
Joined
Sep 12, 2008
Messages
657
1.i dont get the owned part.. what does it mean?

  • ((Item carried by (Picked unit) in slot Integer_A_Replacement) is owned) Equal to True
2. i dont get this part

JASS:
For each (Integer B) from 1 to 1, do (Actions)

just remove it, you make it run once, so it doesnt matter AT all.

3. i readed your code, couldnt find much..
but since i dont see the actual code, i cant realy tell how it works..
sorry =]
just do what i sayd in part 2 of my answer,
since its VERY useless.. (if you can give me a link of his system, i might be able to add a extra function to save items)
 
Level 8
Joined
Apr 8, 2009
Messages
499
Is Code gen easier to emplant?
does it not bug with overload on data's?
does it save everything i want it to save? (hero, exp, items, item charges, gold, lumber, extra variables)
 
Is Code gen easier to emplant?
does it not bug with overload on data's?
does it save everything i want it to save? (hero, exp, items, item charges, gold, lumber, extra variables)

I've yet to try it... anyway it works the same (well save-load systems really work the same, you provide them data and they turn it to code and vice-versa)...

but its more updated than AceHart's...
 
hmm... i guess i'll try it out since Aceharts is really a pain .___.

good luck... tell me if it works... have so much more work to do... anyway I dont need it right now since my proj is an SG, I'll be doing a game cache save system for it... but I need a code save system for portability...
 
Level 8
Joined
Apr 8, 2009
Messages
499
well, it works, but it does require vjass, which reqiures jass new gen pack, or jasshelper. (a compiler).

you talking about iGen (by Hanky) or CodeGen (by HappyTauren) ?

because so far, CodeGen doesn't seem to require Jasshelper .__.
 
Level 11
Joined
Sep 12, 2008
Messages
657
yeah.. i was gonna say "theres another save/load system called Igen", but it does require blah blah

probably didnt notice..
i didnt try the CodeGen, but its by HappyTauren so.. how bad it can be ;p
and Igen is amazing =]
 
Level 8
Joined
Apr 8, 2009
Messages
499
yeah.. i was gonna say "theres another save/load system called Igen", but it does require blah blah

probably didnt notice..
i didnt try the CodeGen, but its by HappyTauren so.. how bad it can be ;p
and Igen is amazing =]

meh, i wanted to try out iGen, but for some reason the jasshelper is failing lol, probably just me misusing it. anyways i'm trying out the CodeGen since i like GUI better ^__^
 
Level 8
Joined
Apr 8, 2009
Messages
499
CodeGen is by TriggerHappy? idk, maybe i just misread it :D

Also here's the triggers for you to see Adiktuz.

  • SaveLoad 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
    • Conditions
    • Actions
      • -------- Find the players hero, and save it. I realize it leaks but it's just for demonstration. --------
      • Set SaveCount = 0
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching ((Matching unit) Equal to Player_Hero_Array[(Player number of (Triggering player))])) and do (Set Hero = (Picked unit))
      • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertUnit(GetUnitTypeId(udg_Hero))
      • Set SaveCount = (SaveCount + 1)
      • -------- Save players gold. --------
      • Set Save[SaveCount] = ((Triggering player) Current gold)
      • Set SaveCount = (SaveCount + 1)
      • -------- Save players lumber. --------
      • Set Save[SaveCount] = ((Triggering player) Current lumber)
      • Set SaveCount = (SaveCount + 1)
      • -------- Save heroes EXP. --------
      • Set Save[SaveCount] = (Hero experience of Hero)
      • Set SaveCount = (SaveCount + 1)
      • -------- Save heroes items. --------
      • Set Save[SaveCount] = (Number of items carried by Hero)
      • Set SaveCount = (SaveCount + 1)
      • For each (Integer Integer_A_Replacement) from 1 to 6, 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 in slot Integer_A_Replacement)) Not equal to (Item-type of No item)
            • Then - Actions
              • Set Item = (Item carried by Hero in slot Integer_A_Replacement)
              • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertItem(GetItemTypeId(udg_Item))
              • Set SaveCount = (SaveCount + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Charges remaining in (Item carried by Hero in slot Integer_A_Replacement)) Greater than 0
                • Then - Actions
                  • Set Save[SaveCount] = (Charges remaining in (Item carried by Hero in slot Integer_A_Replacement))
                • Else - Actions
                  • Set Save[SaveCount] = 1
              • Set SaveCount = (SaveCount + 1)
            • Else - Actions
      • -------- Show Code --------
      • Custom script: set udg_Code = CodeGen_Compile()
      • Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code
  • SaveLoad 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
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to -load
    • Actions
      • -------- Check if load is valid --------
      • Set Code = (Substring((Entered chat string), 7, 999))
      • Custom script: call CodeGen_Load(udg_Code)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SaveLoad_Valid Equal to False
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: Invalid code.
          • Skip remaining actions
        • Else - Actions
      • -------- Start loading, load the hero first. --------
      • Set LoadCount = 0
      • Unit Group - Pick every unit in (Units owned by (Triggering player)) and do (Unit - Remove (Picked unit) from the game)
      • Unit - Create 1 SaveLoad_Hero[Load[LoadCount]] for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
      • Set Hero = (Last created unit)
      • Selection - Select (Last created unit) for (Triggering player)
      • -------- Now load players gold --------
      • Set LoadCount = (LoadCount + 1)
      • Player - Set (Triggering player) Current gold to Load[LoadCount]
      • -------- Now load players Lumber --------
      • Set LoadCount = (LoadCount + 1)
      • Player - Set (Triggering player) Current lumber to Load[LoadCount]
      • -------- Load heroes EXP --------
      • Set LoadCount = (LoadCount + 1)
      • Hero - Set Hero experience to Load[LoadCount], Hide level-up graphics
      • -------- Now items --------
      • Set LoadCount = (LoadCount + 1)
      • For each (Integer Integer_A_Replacement) from 0 to Load[LoadCount], do (Actions)
        • Loop - Actions
          • Set LoadCount = (LoadCount + 1)
          • Hero - Create SaveLoad_Item[Load[LoadCount]] and give it to Hero
          • Set LoadCount = (LoadCount + 1)
          • Item - Set charges remaining in (Last created item) to Load[LoadCount]
-----EDIT---------
Its working still so far.
-hero gets loaded with correct amount of exp.
-Gold/Lumber gets loaded.
-all 6 items get loaded

Only thing left is to save/load the correct amount of charges.
----EDIT----------

Once again, the same problem. if i have a inventory full with 6 different potions and charges from 1,2,3, to 6. they save and load correctly.
if however, i have 2 potions which both have 4 charges left and i have 4 non-charged items in my inventory aswell, it somehow saves/loads the first 2 items (both non-chargable) and gives them a charge of 1.

so myeah, imma play around a bit with it again, i hope you can help me with this x.x
 
Last edited:
NOTE: I'm not sure if any of this is related to the problem, just observations...

on the load, use 1 to Load[LoadCount] because 0 to x could bug if its not the last part of the load trigger... example you have Load[LoadCount] of 6, 0 to 6 would mean the loop will run 7 times so 2 extra LoadCount + 1...


I suggest removing the Set SaveCount = SaveCount + 1 after the saving of the number of items and place it before set Item = x and remove the Set SaveCount = SaveCount + 1 at the end coz it gives you an extra SaveCount value on the last loop (because that line will be the last one to be called before the compile)...

  • -------- Save heroes items. --------
  • Set Save[SaveCount] = (Number of items carried by Hero)
  • For each (Integer Integer_A_Replacement) from 1 to 6, 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 in slot Integer_A_Replacement)) Not equal to (Item-type of No item)
        • Then - Actions
          • Set SaveCount = (SaveCount + 1)
          • Set Item = (Item carried by Hero in slot Integer_A_Replacement)
          • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertItem(GetItemTypeId(udg_Item))
          • Set SaveCount = (SaveCount + 1)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Charges remaining in (Item carried by Hero in slot Integer_A_Replacement)) Greater than 0
              • Then - Actions
                • Set Save[SaveCount] = (Charges remaining in (Item carried by Hero in slot Integer_A_Replacement))
                • Else - Actions
                  • Set Save[SaveCount] = 1
 
Level 8
Joined
Apr 8, 2009
Messages
499
sooo, i made the changes you told me to, and when i have 6 different potions with different charges in my inventory now, it only loads the one in the first slot.
 
sooo, i made the changes you told me to, and when i have 6 different potions with different charges in my inventory now, it only loads the one in the first slot.

told ya, I'm not sure... ^^... hmmm.... maybe you can try to save all 6 slots without checking if there is an item or not...

anyway the best way to solve this is to play with the code, put debug messages to see where the trigger stops or encounter errors....
 
Level 8
Joined
Apr 8, 2009
Messages
499
told ya, I'm not sure... ^^... hmmm.... maybe you can try to save all 6 slots without checking if there is an item or not...

anyway the best way to solve this is to play with the code, put debug messages to see where the trigger stops or encounter errors....

It seems, that whenever there's an item withouth charges, the code stops and refuses the save any items after that x___x, as you said i'm gonna try playing around a bit, trying to find a condition that checks if it actually is an item with charges
 
It seems, that whenever there's an item withouth charges, the code stops and refuses the save any items after that x___x, as you said i'm gonna try playing around a bit, trying to find a condition that checks if it actually is an item with charges

I know!!! remove the if-then-else on the save that checks if the item has charges... then on the load, after the item load do this

  • If-Then-Else
    • If - Conditions
      • Load[LoadCount] is greater then 0
    • Then - Actions
      • Item - Set charges remaining in (Last created item) to Load[LoadCount]
    • Else - Actions
so it wont try to add charges to a non-charged item...
 
Level 8
Joined
Apr 8, 2009
Messages
499
tried this, works the same as what i had before x___x it does seem more logical this way too work tho.

i tried getting 6 different potions again, all different charges. all saved/loaded np.
replaced potion in 6th slot with a glove, all except the glove got loaded
got the glove again and moved it to the 3rd slot, all after the 3rd slot didn't get saved/loaded.

i'm SO confuzed right now. i have absolutely no clue why this is happenening.
is it the same reason as with Aceharts System? simply a integer overload? the compressor can't handle this amount of values x.x ?
 
tried this, works the same as what i had before x___x it does seem more logical this way too work tho.

i tried getting 6 different potions again, all different charges. all saved/loaded np.
replaced potion in 6th slot with a glove, all except the glove got loaded
got the glove again and moved it to the 3rd slot, all after the 3rd slot didn't get saved/loaded.

i'm SO confuzed right now. i have absolutely no clue why this is happenening.
is it the same reason as with Aceharts System? simply a integer overload? the compressor can't handle this amount of values x.x ?

logically it should work... hmm... and it cant be overload coz there's only a little amount of data... can you post the edited trigger? maybe just some error...
 
Level 8
Joined
Apr 8, 2009
Messages
499
My Current Triggers:


  • SaveLoad 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
    • Conditions
    • Actions
      • -------- Find the players hero, and save it. I realize it leaks but it's just for demonstration. --------
      • Set SaveCount = 0
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching ((Matching unit) Equal to Player_Hero_Array[(Player number of (Triggering player))])) and do (Set Hero = (Picked unit))
      • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertUnit(GetUnitTypeId(udg_Hero))
      • Set SaveCount = (SaveCount + 1)
      • -------- Save players gold. --------
      • Set Save[SaveCount] = ((Triggering player) Current gold)
      • Set SaveCount = (SaveCount + 1)
      • -------- Save players lumber. --------
      • Set Save[SaveCount] = ((Triggering player) Current lumber)
      • Set SaveCount = (SaveCount + 1)
      • -------- Save heroes EXP. --------
      • Set Save[SaveCount] = (Hero experience of Hero)
      • Set SaveCount = (SaveCount + 1)
      • -------- Save heroes items. --------
      • Set Save[SaveCount] = (Number of items carried by Hero)
      • For each (Integer Integer_A_Replacement) from 1 to 6, 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 in slot Integer_A_Replacement)) Not equal to (Item-type of No item)
            • Then - Actions
              • Set SaveCount = (SaveCount + 1)
              • Set Item = (Item carried by Hero in slot Integer_A_Replacement)
              • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertItem(GetItemTypeId(udg_Item))
              • Set SaveCount = (SaveCount + 1)
              • Set Save[SaveCount] = (Charges remaining in (Item carried by Hero in slot Integer_A_Replacement))
            • Else - Actions
      • -------- Show Code --------
      • Custom script: set udg_Code = CodeGen_Compile()
      • Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code
  • SaveLoad 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
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to -load
    • Actions
      • -------- Check if load is valid --------
      • Set Code = (Substring((Entered chat string), 7, 999))
      • Custom script: call CodeGen_Load(udg_Code)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SaveLoad_Valid Equal to False
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: Invalid code.
          • Skip remaining actions
        • Else - Actions
      • -------- Start loading, load the hero first. --------
      • Set LoadCount = 0
      • Unit Group - Pick every unit in (Units owned by (Triggering player)) and do (Unit - Remove (Picked unit) from the game)
      • Unit - Create 1 SaveLoad_Hero[Load[LoadCount]] for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
      • Set Hero = (Last created unit)
      • Selection - Select (Last created unit) for (Triggering player)
      • -------- Now load players gold --------
      • Set LoadCount = (LoadCount + 1)
      • Player - Set (Triggering player) Current gold to Load[LoadCount]
      • -------- Now load players Lumber --------
      • Set LoadCount = (LoadCount + 1)
      • Player - Set (Triggering player) Current lumber to Load[LoadCount]
      • -------- Load heroes EXP --------
      • Set LoadCount = (LoadCount + 1)
      • Hero - Set Hero experience to Load[LoadCount], Hide level-up graphics
      • -------- Now items --------
      • Set LoadCount = (LoadCount + 1)
      • For each (Integer Integer_A_Replacement) from 0 to Load[LoadCount], do (Actions)
        • Loop - Actions
          • Set LoadCount = (LoadCount + 1)
          • Hero - Create SaveLoad_Item[Load[LoadCount]] and give it to Hero
          • Set LoadCount = (LoadCount + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Load[LoadCount] Greater than 0
            • Then - Actions
              • Item - Set charges remaining in (Last created item) to Load[LoadCount]
            • Else - Actions
 
Level 8
Joined
Apr 8, 2009
Messages
499
Mkay, Win incoming. ^________^

Remade the Whole part for items. it works 100% now.


  • SaveLoad Save JT
    • 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
    • Conditions
    • Actions
      • -------- Find the players hero, and save it. I realize it leaks but it's just for demonstration. --------
      • Set SaveCount = 0
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching ((Matching unit) Equal to Player_Hero_Array[(Player number of (Triggering player))])) and do (Set Hero = (Picked unit))
      • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertUnit(GetUnitTypeId(udg_Hero))
      • Set SaveCount = (SaveCount + 1)
      • -------- Save players gold. --------
      • Set Save[SaveCount] = ((Triggering player) Current gold)
      • Set SaveCount = (SaveCount + 1)
      • -------- Save players lumber. --------
      • Set Save[SaveCount] = ((Triggering player) Current lumber)
      • Set SaveCount = (SaveCount + 1)
      • -------- Save heroes EXP. --------
      • Set Save[SaveCount] = (Hero experience of Hero)
      • Set SaveCount = (SaveCount + 1)
      • -------- Save heroes items. --------
      • Set Save[SaveCount] = (Number of items carried by Hero)
      • For each (Integer Integer_A_Replacement) from 1 to 6, 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 in slot Integer_A_Replacement)) Not equal to (Item-type of No item)
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Charges remaining in (Item carried by Hero in slot Integer_A_Replacement)) Greater than 0
                • Then - Actions
                  • Set SaveCount = (SaveCount + 1)
                  • Set Save[SaveCount] = 1
                  • Set SaveCount = (SaveCount + 1)
                  • Set Item = (Item carried by Hero in slot Integer_A_Replacement)
                  • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertItem(GetItemTypeId(udg_Item))
                  • Set SaveCount = (SaveCount + 1)
                  • Set Save[SaveCount] = (Charges remaining in (Item carried by Hero in slot Integer_A_Replacement))
                • Else - Actions
                  • Set SaveCount = (SaveCount + 1)
                  • Set Save[SaveCount] = 2
                  • Set SaveCount = (SaveCount + 1)
                  • Set Item = (Item carried by Hero in slot Integer_A_Replacement)
                  • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertItem(GetItemTypeId(udg_Item))
                  • Set SaveCount = (SaveCount + 1)
            • Else - Actions
              • Set SaveCount = (SaveCount + 1)
              • Set Save[SaveCount] = 0
              • Set SaveCount = (SaveCount + 2)
      • Set SaveCount = (SaveCount + 1)
      • -------- Show Code --------
      • Custom script: set udg_Code = CodeGen_Compile()
      • Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code
      • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: Credits to JTtheGho...
  • SaveLoad Load JT
    • 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
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to -load
    • Actions
      • -------- Check if load is valid --------
      • Set Code = (Substring((Entered chat string), 7, 999))
      • Custom script: call CodeGen_Load(udg_Code)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SaveLoad_Valid Equal to False
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: Invalid code.
          • Skip remaining actions
        • Else - Actions
      • -------- Start loading, load the hero first. --------
      • Set LoadCount = 0
      • Unit Group - Pick every unit in (Units owned by (Triggering player)) and do (Unit - Remove (Picked unit) from the game)
      • Unit - Create 1 SaveLoad_Hero[Load[LoadCount]] for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
      • Set Hero = (Last created unit)
      • Selection - Select (Last created unit) for (Triggering player)
      • -------- Now load players gold --------
      • Set LoadCount = (LoadCount + 1)
      • Player - Set (Triggering player) Current gold to Load[LoadCount]
      • -------- Now load players Lumber --------
      • Set LoadCount = (LoadCount + 1)
      • Player - Set (Triggering player) Current lumber to Load[LoadCount]
      • -------- Load heroes EXP --------
      • Set LoadCount = (LoadCount + 1)
      • Hero - Set Hero experience to Load[LoadCount], Hide level-up graphics
      • -------- Now items --------
      • Set LoadCount = (LoadCount + 1)
      • For each (Integer Integer_A_Replacement) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set LoadCount = (LoadCount + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Load[LoadCount] Not equal to 0
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Load[LoadCount] Equal to 1
                • Then - Actions
                  • Set LoadCount = (LoadCount + 1)
                  • Hero - Create SaveLoad_Item[Load[LoadCount]] and give it to Hero
                  • Set LoadCount = (LoadCount + 1)
                  • Item - Set charges remaining in (Last created item) to Load[LoadCount]
                • Else - Actions
                  • Set LoadCount = (LoadCount + 1)
                  • Hero - Create SaveLoad_Item[Load[LoadCount]] and give it to Hero
                  • Set LoadCount = (LoadCount + 1)
            • Else - Actions
              • Set LoadCount = (LoadCount + 2)

-----EDIT------
made it so you dont have to put a condition in for every different potion, its universal for all charged items now ;D
 
Last edited:
Level 8
Joined
Apr 8, 2009
Messages
499
wow, nice... though can be kinda long especially when you add more items... ^^

Nope, code has a set lenght, it'll show "AAAA-AAAA" for empty item slots. so the code lenght wont ever change depending on the amount of item you have ^___^

or did you mean adding conditions for the chargable items lol?


btw, you have a map dev thread?

Sadly, not yet. i'm gonna make one at the end of this week probably (i have vacation atm) because i MIGHT have a open beta ready at the end of this week. ^___^ shal i notify you when i make it?
 
Level 6
Joined
Jul 22, 2015
Messages
65
Mkay, Win incoming. ^________^

Remade the Whole part for items. it works 100% now.


  • SaveLoad Save JT
    • 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
    • Conditions
    • Actions
      • -------- Find the players hero, and save it. I realize it leaks but it's just for demonstration. --------
      • Set SaveCount = 0
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching ((Matching unit) Equal to Player_Hero_Array[(Player number of (Triggering player))])) and do (Set Hero = (Picked unit))
      • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertUnit(GetUnitTypeId(udg_Hero))
      • Set SaveCount = (SaveCount + 1)
      • -------- Save players gold. --------
      • Set Save[SaveCount] = ((Triggering player) Current gold)
      • Set SaveCount = (SaveCount + 1)
      • -------- Save players lumber. --------
      • Set Save[SaveCount] = ((Triggering player) Current lumber)
      • Set SaveCount = (SaveCount + 1)
      • -------- Save heroes EXP. --------
      • Set Save[SaveCount] = (Hero experience of Hero)
      • Set SaveCount = (SaveCount + 1)
      • -------- Save heroes items. --------
      • Set Save[SaveCount] = (Number of items carried by Hero)
      • For each (Integer Integer_A_Replacement) from 1 to 6, 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 in slot Integer_A_Replacement)) Not equal to (Item-type of No item)
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Charges remaining in (Item carried by Hero in slot Integer_A_Replacement)) Greater than 0
                • Then - Actions
                  • Set SaveCount = (SaveCount + 1)
                  • Set Save[SaveCount] = 1
                  • Set SaveCount = (SaveCount + 1)
                  • Set Item = (Item carried by Hero in slot Integer_A_Replacement)
                  • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertItem(GetItemTypeId(udg_Item))
                  • Set SaveCount = (SaveCount + 1)
                  • Set Save[SaveCount] = (Charges remaining in (Item carried by Hero in slot Integer_A_Replacement))
                • Else - Actions
                  • Set SaveCount = (SaveCount + 1)
                  • Set Save[SaveCount] = 2
                  • Set SaveCount = (SaveCount + 1)
                  • Set Item = (Item carried by Hero in slot Integer_A_Replacement)
                  • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertItem(GetItemTypeId(udg_Item))
                  • Set SaveCount = (SaveCount + 1)
            • Else - Actions
              • Set SaveCount = (SaveCount + 1)
              • Set Save[SaveCount] = 0
              • Set SaveCount = (SaveCount + 2)
      • Set SaveCount = (SaveCount + 1)
      • -------- Show Code --------
      • Custom script: set udg_Code = CodeGen_Compile()
      • Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code
      • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: Credits to JTtheGho...
  • SaveLoad Load JT
    • 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
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to -load
    • Actions
      • -------- Check if load is valid --------
      • Set Code = (Substring((Entered chat string), 7, 999))
      • Custom script: call CodeGen_Load(udg_Code)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SaveLoad_Valid Equal to False
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: Invalid code.
          • Skip remaining actions
        • Else - Actions
      • -------- Start loading, load the hero first. --------
      • Set LoadCount = 0
      • Unit Group - Pick every unit in (Units owned by (Triggering player)) and do (Unit - Remove (Picked unit) from the game)
      • Unit - Create 1 SaveLoad_Hero[Load[LoadCount]] for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
      • Set Hero = (Last created unit)
      • Selection - Select (Last created unit) for (Triggering player)
      • -------- Now load players gold --------
      • Set LoadCount = (LoadCount + 1)
      • Player - Set (Triggering player) Current gold to Load[LoadCount]
      • -------- Now load players Lumber --------
      • Set LoadCount = (LoadCount + 1)
      • Player - Set (Triggering player) Current lumber to Load[LoadCount]
      • -------- Load heroes EXP --------
      • Set LoadCount = (LoadCount + 1)
      • Hero - Set Hero experience to Load[LoadCount], Hide level-up graphics
      • -------- Now items --------
      • Set LoadCount = (LoadCount + 1)
      • For each (Integer Integer_A_Replacement) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set LoadCount = (LoadCount + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Load[LoadCount] Not equal to 0
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Load[LoadCount] Equal to 1
                • Then - Actions
                  • Set LoadCount = (LoadCount + 1)
                  • Hero - Create SaveLoad_Item[Load[LoadCount]] and give it to Hero
                  • Set LoadCount = (LoadCount + 1)
                  • Item - Set charges remaining in (Last created item) to Load[LoadCount]
                • Else - Actions
                  • Set LoadCount = (LoadCount + 1)
                  • Hero - Create SaveLoad_Item[Load[LoadCount]] and give it to Hero
                  • Set LoadCount = (LoadCount + 1)
            • Else - Actions
              • Set LoadCount = (LoadCount + 2)

-----EDIT------
made it so you dont have to put a condition in for every different potion, its universal for all charged items now ;D
I know it too late 13 years but.. Thanks a lot!! ^o^ being searching save/load with charged item is freaking time consuming.. :D
But finally i found it!
 
Status
Not open for further replies.
Top