• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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