• 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.

Destroy location and hashtable

Status
Not open for further replies.
Level 4
Joined
Jan 5, 2014
Messages
79
I have something like this:

Set TempPoint1 = somewhere
Create 1 unit of some type at TempPoint1
Save Handle of TempPoint1 as 0 of last created unit in Hash
call RemoveLocation(udg_TempPoint1)

and the custom script seems to erase even the point from the hashtable. Is it really possible, or have I done something else wrong?
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Yes it works like that.
Variables just point to things they are assigned to - in this case, the variable TempPoint1 points to the location you created.

If you do "Save Handle of TempPoint1 as 0 in Hash" then both TempPoint and the handle saved in Hashtable point to the same thing. So if you delete the location via custom script, both variable and the handle inside hash will point to nothing (since the location has been destroyed).
 
Level 4
Joined
Jan 5, 2014
Messages
79
And if i did this:

Set TempPoint1 = somewhere
Create 1 unit of some type at TempPoint1
Save Handle of TempPoint1 as 0 of last created unit in Hash
Set TempPoint1 = somewhere else
call RemoveLocation(udg_TempPoint1)

Than it wouldn't erase it from the hash, am I right?
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
yes it wouldn't erase the one in hashtable, but there's no reason to create new location and delete it.

If you don't want TempPoint1 to point anywhere once you save the location inside hashtable, then change this
  • Custom script: call RemoveLocation(udg_TempPoint1)
into this line:
  • Custom script: set udg_TempPoint1 = null
The line I wrote will make TempPoint1 point to nothing, but the location it previously pointed to will remain.
 
Level 4
Joined
Jan 5, 2014
Messages
79
yes it wouldn't erase the one in hashtable, but there's no reason to create new location and delete it.

If you don't want TempPoint1 to point anywhere once you save the location inside hashtable, then change this
  • Custom script: call RemoveLocation(udg_TempPoint1)
into this line:
  • Custom script: set udg_TempPoint1 = null
The line I wrote will make TempPoint1 point to nothing, but the location it previously pointed to will remain.

OK, thank you
 
Status
Not open for further replies.
Top