• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Save/Retrieve Location/Point of units in a Hashtable

Level 3
Joined
Jun 6, 2024
Messages
12
Hi! I just a have a simple question: is there a more direct way to save/retrieve the Point/Location of a unit or this is the only way?
  • Unit Group - Pick every unit in AOEGroup and do (Actions)
    • Loop - Actions
    • Hashtable - Save (X of (Position of (Picked unit))) as (Key (Picked unit)) of 0 in MyHashtable
    • Hashtable - Save (Y of (Position of (Picked unit))) as (Key (Picked unit)) of 1 in MyHashtable
    • Unit - Move (Picked unit) instantly to (Center of (Playable map area))

  • Unit Group - Pick every unit in AOEGroup and do (Actions)
    • Loop - Actions
      • Set X = (Load (Key (Picked unit)) of 0 from MyHashtable)
      • Set Y = (Load (Key (Picked unit)) of 1 from MyHashtable)
      • Set Point = (Point(X, Y))
      • Unit - Move (Picked unit) instantly to Point
This is part of a trigger ability that im trying to do. Should i erase/clean the hashtable at the end? The content is irrelevant for future executions of triggers, but i failed to find the function to do this.

Any hint is appreciated since Im a total newbie :D

Thanks in advance.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Hi! I just a have a simple question: is there a more direct way to save/retrieve the Point/Location of a unit or this is the only way?
  • Unit Group - Pick every unit in AOEGroup and do (Actions)
    • Loop - Actions
    • Hashtable - Save (X of (Position of (Picked unit))) as (Key (Picked unit)) of 0 in MyHashtable
    • Hashtable - Save (Y of (Position of (Picked unit))) as (Key (Picked unit)) of 1 in MyHashtable
    • Unit - Move (Picked unit) instantly to (Center of (Playable map area))

  • Unit Group - Pick every unit in AOEGroup and do (Actions)
    • Loop - Actions
      • Set X = (Load (Key (Picked unit)) of 0 from MyHashtable)
      • Set Y = (Load (Key (Picked unit)) of 1 from MyHashtable)
      • Set Point = (Point(X, Y))
      • Unit - Move (Picked unit) instantly to Point
This is part of a trigger ability that im trying to do. Should i erase/clean the hashtable at the end? The content is irrelevant for future executions of triggers, but i failed to find the function to do this.

Any hint is appreciated since Im a total newbie :D

Thanks in advance.
You have two Actions for clearing a Hashtable (and more when using Jass):
  • Actions
    • Hashtable - Clear (Last created hashtable)
    • Hashtable - Clear all child hashtables of child (Key (Picked unit).) in (Last created hashtable).
The first wipes the entire Hashtable, not a good if you have other important data being stored.

The second is likely what you want since it clears a Parent key.

But it's function name is misleading and has a typo. It doesn't clear all "child hashtables of a child", it clears all child keys of a parent key:
  • Hashtable - Clear all child Keys of parent (Key (Picked unit)) in (Last created hashtable).
^ It should really say something like that.

 
Top