How to remove value from hashtable?

Level 4
Joined
May 10, 2024
Messages
28
Hi. I want to manually remove stored integer value under specific key from hashtable. Built in functions is not working.

Script below saves random integer under Key (Picked unit) in hastbale and removes it if that integer exists. Stored value should change every 2 seconds from nothing to number but it is not changing.

  • Tick
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Paladin
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Key (Picked unit).) is stored as a Integer of 0 in hashtable..) Equal to True
                • Then - Actions
                  • Game - Display to (All players) the text: (Value is stored: + (String((Load (Key (Picked unit).) of 0 from hashtable.))))
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit).) in hashtable.
                  • Set VariableSet handleId = (Key (Picked unit).)
                  • Custom script: call RemoveSavedInteger(udg_hashtable,udg_handleId,0)
                • Else - Actions
                  • Game - Display to (All players) the text: (Value is not stored: + (String((Load (Key (Picked unit).) of 0 from hashtable.))))
                  • Hashtable - Save (Random integer number between 1 and 999) as (Key (Picked unit).) of 0 in hashtable.
            • Else - Actions
I tried Clear all child hashtables of child which should remove all values under (Key (Picked unit) but it is not working as well. How to remove integer value from hastbale? What about other types?
 

Attachments

  • hashtable1.png
    hashtable1.png
    3.8 MB · Views: 5
  • hastbaleTest.w3m
    18 KB · Views: 3
Level 4
Joined
May 10, 2024
Messages
28
It works fine now. :infl_thumbs_up:

  • Tick
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Paladin
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (0 is stored as a Integer of (Key (Picked unit).) in hashtable..) Equal to True
                • Then - Actions
                  • Game - Display to (All players) the text: (Value is stored: + (String((Load 0 of (Key (Picked unit).) from hashtable.))))
                  • Set VariableSet handleId = (Key (Picked unit).)
                  • Custom script: call RemoveSavedInteger(udg_hashtable,udg_handleId,0)
                • Else - Actions
                  • Game - Display to (All players) the text: (Value is not stored: + (String((Load 0 of (Key (Picked unit).) from hashtable.))))
                  • Hashtable - Save (Random integer number between 1 and 999) as 0 of (Key (Picked unit).) in hashtable.
            • Else - Actions
 
Top