hashtable - unithandle in array? why does this return the same value?

polo2005

Wana start playing LoL? http://tinyurl.com/369as27
Reaction score
97
Code:
Untitled Trigger 002
    Events
        Map initialization
    Conditions
    Actions
        Hashtable - Create a hashtable
        Set test_hashtable = (Last created hashtable)
        Hashtable - Save Handle OfMarine 0001 <gen> as (Key units_handle[1]) of 1 in test_hashtable
        Hashtable - Save Handle OfCaptain 0005 <gen> as (Key units_handle[2]) of 1 in test_hashtable

Code:
Untitled Trigger 003
    Events
        Player - Player 1 (Red) types a chat message containing debug as An exact match
    Conditions
    Actions
        Game - Display to (All players) the text: (Name of (Load [B](Key units_handle[1]) [/B]of 1 in test_hashtable))
        Game - Display to (All players) the text: (Name of (Load [B](Key units_handle[2])[/B] of 1 in test_hashtable))

why does the second trigger return Captain on both game messages?
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
you have to save the unit in a variable or the handle is just nothing, when you no longer reference a unit its handle is recycled because there is nothing pointing to it, but until then it will work, this is also what causes leaks, local variables pointing to handles after the trigger has already run its course, so that data is lost in the ram

instead do (Key Unit) and reference that unit, as that is never lost
 

ultimate11

Active Member
Reaction score
25
and try to use
Trigger:
  • Hashtable - Save Handle OfMarine 0001 &lt;gen&gt; as 1 of (key unit in test_hashtable
    • Hashtable - Save Handle OfCaptain 0005 &lt;gen&gt; as 2 of (key unit) in test_hashtable

Is more reliable.
 

polo2005

Wana start playing LoL? http://tinyurl.com/369as27
Reaction score
97
you have to save the unit in a variable or the handle is just nothing, when you no longer reference a unit its handle is recycled because there is nothing pointing to it, but until then it will work, this is also what causes leaks, local variables pointing to handles after the trigger has already run its course, so that data is lost in the ram

instead do (Key Unit) and reference that unit, as that is never lost

i see... that does make sense thank you

and try to use
Trigger:
  • Hashtable - Save Handle OfMarine 0001 &lt;gen&gt; as 1 of (key unit in test_hashtable
    • Hashtable - Save Handle OfCaptain 0005 &lt;gen&gt; as 2 of (key unit) in test_hashtable

Is more reliable.

why would this be better than virsa vera?
 
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