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

Hashtables Values - Load or Set Variables?

Status
Not open for further replies.

Tzi

Tzi

Level 4
Joined
Jan 7, 2009
Messages
57
Hi,

I've got a little question about the using of values of hashtables.
In every tutorial I've seen that the posters first of all saved the loads of hashtables in additional variables and then used this variables for another actions.

e.g.
  • Set Integer = (Load 0 of (Key (Triggering unit)) from Hashtable)
  • Set Integer = (Integer + 1)
  • Hashtable - Save Integer as 0 of (Key (Triggering unit)) in Hashtable
So I'm doing it this way:
  • Hashtabelle - Save Integer as ((Load 0 of (Key (Triggering unit)) from Hashtable) + 1) of (Key (Triggering unit)) in Hashtable
Is inefficient or are these steps only there to keep holding the overview?
 
The first part is saving the value, you can call it whichValue. The second part determines how the value will be labelled.

Now, if you want to load the value back, you need to use that little "label". In the first way you've presented, the label to load the "Integer" value, is "0", because this is how you saved it, to recognize it yourself.
In the second way, the label is the (old label + 1). However, you are saving the value, you are not loading it, which means that the "Integer" variable will not replace the old label, it will save it as a new one, since (old label) != (old label + 1).

Definitely follow the first way, which creates a static label for the "Integer" variable.
 
This is the one which is identical to the first
  • Hashtable - Save ((Load 0 of (Key (Triggering unit)) from Hashtable) + 1) as 0 of (Key (Triggering unit)) in Hashtable
Since what the first two parts do is to load the value saved on the hashtable, and then increase it by 1...

if ur not reusing it in the same trig, I guess its more efficient this way, but if you're using the value several times in the same trigger, do the first method...
 
Status
Not open for further replies.
Top