[AceHart] Save/Load stats help.

Zonagle

New Member
Reaction score
1
Help with saving attributes

Original problem solved. New problem.
When I pick up two potions (not the potions in the save item list), save, load, drop both potions, save again, then load. I get 1 potion in the first slot.

What would I need to put in, to prevent loading more than once per game? I'd prefer to fix the item problem, rather than limiting the amount of times you're able to save.

AceHarts Save/Load system: http://www.thehelper.net/forums/showthread.php?t=49392

The code I'm currently using.
Trigger:
  • SaveLoad Initialization All Copy
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- List of Heroes --------
      • Set SaveLoad_Heroes[1] = |cffff0000Nature Protector|r
      • Set SaveLoad_Heroes[2] = Void Golem
      • Set SaveLoad_Heroes[3] = |cffeffa1bCarnifex|r
      • Set SaveLoad_Heroes[4] = |cffff0000Lich King|r
      • Set SaveLoad_Heroes[5] = |cff00bfffElemental Mage|r
      • Set SaveLoad_Heroes[6] = |cfff8fb68Arch Angel|r
      • Set SaveLoad_Heroes[7] = |cff7cfc00Ranger|r
      • Set SaveLoad_Heroes[8] = |cffff0000Fighter|r
      • -------- Number of Heroes --------
      • Set SaveLoad_Heroes_LastIndex = 8
      • -------- List of Items --------
      • -------- Number of Items --------
      • Set SaveLoad_Items_LastIndex = 21
      • -------- List of Abilities --------
      • Set SaveLoad_Abilities[1] = Bash
      • Set SaveLoad_Abilities[2] = Flame Strike
      • Set SaveLoad_Abilities[3] = Phoenix
      • Set SaveLoad_Abilities[4] = Siphon Mana
      • -------- Number of Abilities --------
      • Set SaveLoad_Abilities_LastIndex = 4
      • -------- These three lines may be changed if needed --------
      • Set SaveLoad_Alphabet = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
      • Set SaveLoad_CaseSensitive = False
      • Set SaveLoad_UsePlayername = True
      • -------- Required: false --------
      • Set SaveLoad_Initialized = False
      • -------- Leave as is. Used to autocreate variables when copy & pasting to a new map --------
      • Set Code = AceHart
      • Set Save[1] = 0
      • Set SaveCount = 1
      • Set Validate = False
      • Set SaveLoad_Compress[1] = 0
      • Set SaveLoad_Uncompress[1] = 0




Trigger:
  • SaveLoad Save All Copy
    • 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
      • -------- Prepare the save array with this player's Hero --------
      • Set SaveCount = 0
      • Set UnitGroup = (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))
      • Unit Group - Pick every unit in UnitGroup 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 )
          • Game - Display to (All players) the text: (Save[1]= + (String(Save[SaveCount])))
          • -------- Hero level --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Hero experience of (Picked unit))
          • -------- Player's Gold --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = ((Triggering player) Current gold)
          • -------- Savehero STR/AGI/INT --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Strength of (Picked unit) (Exclude bonuses))
          • Game - Display to (All players) the text: (STR: + (String(Save[SaveCount])))
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Agility of (Picked unit) (Exclude bonuses))
          • Game - Display to (All players) the text: (AGI: + (String(Save[SaveCount])))
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Intelligence of (Picked unit) (Exclude bonuses))
          • Game - Display to (All players) the text: (INT: + (String(Save[SaveCount])))
          • -------- How many items does he carry --------
          • Set SaveCount = (SaveCount + 1)
          • Set Save[SaveCount] = (Number of items carried by (Picked unit))
          • -------- Add all items --------
          • 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 )
                  • Game - Display to (All players) the text: (SAVED ITEM: + (Name of TempItem))
                • 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



Trigger:
  • SaveLoad Load All Copy
    • 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, 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 --------
      • 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
      • -------- Restore Hero --------
      • Game - Display to (All players) the text: (String(Save[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
      • -------- Position --------
      • -------- Restore Gold --------
      • Set SaveCount = (SaveCount + 1)
      • Player - Set (Triggering player) Current gold to Save[SaveCount]
      • Set SaveCount = (SaveCount + 1)
      • -------- Set stats STR/AGI/INT --------
      • Hero - Modify Strength of (Last created unit): Set to Save[SaveCount]
      • Set SaveCount = (SaveCount + 1)
      • Hero - Modify Agility of (Last created unit): Set to Save[SaveCount]
      • Set SaveCount = (SaveCount + 1)
      • Hero - Modify Intelligence of (Last created unit): Set to Save[SaveCount]
      • Set SaveCount = (SaveCount + 1)
      • -------- Recreate all items --------
      • 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)
      • 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)
      • 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)
      • 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)
      • 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)
      • Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
      • Hero - Create TempItemType and give it to (Last created unit)


As always, any help is appreciated.
 
Strange.. It worked in my last map, which i didnt complete and deleted..
Have you changed anything more than the units?
 
You load the experience and position of the hero in the load trigger, but you never save them in the save trigger. Removing the actions for loading position and experience should fix the problem with the attributes (Unless you want the position and experience, in which case you should add them to the save trigger).
 
You load the experience and position of the hero in the load trigger, but you never save them in the save trigger. Removing the actions for loading position and experience should fix the problem with the attributes (Unless you want the position and experience, in which case you should add them to the save trigger).

Alright, thanks, I'll try that and edit with results.


Edit: Alright, I deleted the load position, and the stats saved fine. What do you mean I don't save the experience? Isn't that what's saved in the Hero Level part? "Set Save[SaveCount] = (Hero experience of (Picked unit))"

Edit2: New problem. When I pick up two potions (not the potions in the save item list), save, load, drop both potions, save again, then load. I get 1 potion in the first slot. What would I need to put in, to prevent loading more than once per game?
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good
  • The Helper The Helper:
    I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
  • The Helper The Helper:
    This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top