Custom Value Save/Load

Killerphill

New Member
Reaction score
1
I am trying to make a simple save/load trigger that only remembers the custom value of a unit. I have looked through all the tutorials i can find, but none of these have custom values. The load works when i load the code on the same map, but when i restart, it loads with the custom value reset to 0. I have it that the custom value is converted to a string, saved in a variable, then later converted back to a custom value and given to a unit. I dont know why this trigger isn't working, and would like if someone could help me out.


Trigger:
  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set CusValCode = ((Name of Player 1 (Red)) + (((String((Count structures controlled by Player 1 (Red) (Exclude incomplete structures)))) + (String((Count non-structure units controlled by Player 1 (Red) (Exclude incomplete units))))) + ((String((Player 1 (Red) Current gold)))
      • Trigger - Turn off (This trigger)


Trigger:
  • Save
    • Events
      • Player - Player 1 (Red) types a chat message containing -save as An exact match
    • Conditions
    • Actions
      • Set FinalCode = Empty String
      • Set CusVal = (Custom value of Paladin 0005 <gen>)
      • Set FinalCode = CusValCode
      • Set CusValString = (String((Custom value of Paladin 0005 <gen>)))
      • Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: ...
      • Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: ( + FinalCode)
      • Trigger - Turn off (This trigger)


Trigger:
  • Load
    • Events
      • Player - Player 1 (Red) types a chat message containing -load as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to -load
    • Actions
      • Set FinalCode = (Substring((Entered chat string), 1, (Length of (Entered chat string))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring(FinalCode, 7, (Length of (Entered chat string)))) Equal to CusValCode
        • Then - Actions
          • Wait 0.30 seconds
          • Unit - Replace Paladin 0005 <gen> with a Paladin using The new unit's default life and mana
          • Selection - Select (Last replaced unit) for Player 1 (Red)
          • Wait 1.00 seconds
          • Unit - Set the custom value of (Last replaced unit) to (Integer(CusValString))
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Do nothing


Another question: do i need to have like a game cache sort of thing in order for this to work?

thanks.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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