# A Question Involving Hashes

Status
Not open for further replies.

#### indomitable1319

Level 19
Alright, I've just been reading tutorials on the use of Hashtables.
Now, I wonder how to subtract the amount of time remaining the artificial waits I make in the spell.

So what I mean is, how do you use Hashtables to make an artificial wait?

#### mckill2009

Level 29
use loops then...

if WAIT greater than or equal to zero then
call SaveReal(HASH, KeyID, 1 , WAIT - 1)
else
Do actions AFTER the WAIT

#### indomitable1319

Level 19
I couldn't quite understand, sorry.

#### ThaAthael

Level 5
You save a real value () in a hashtable, using the key of a unit as 2nd value and a nubmer you like (e.g. 0 = unit, 2=real, 35 = location.... I'll use 0 as example).
Now, check with a periodic event every unit/whatever in the unit group. (like every 0.1 seconds)

hashtable -save real: arithmitic(load 0 of key(picked xyz) of examplehash -(whatever you want to decrease, in my example 0.1) in 0 of key (picked xyz) in examplehash).

if (0 of key (picked xyz) in examplehash is equal or less then 0)
then do - actions
remove xyz from group
clear all childs of key (xyz) in examplehash
whatever you want to happen as the actual actions

You can access all amount of data via the hashtable (units, regions, flying height, integer, .... you get it ), at the same time you get to check every affected unit via periodic event pick units in unit group
both are 'linked' together by the key of a unit you've used to save stuff in ^^

Is that a bit clearer or shall I rephrase it?

#### mckill2009

Level 29
Actually http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/hashtables-mui-133407/ already explained it all...

As you can see the example spell HealOverTime is like this...

Save the value first then add to a group the one who is holding the ID or key coz it will be picked latter during the loop to extract the data that he carry...
• Hashtable - Save 10.00 as 0 of (Key (Target unit of ability being cast)) in hashTable
As I mentioned above, the holder will be picked by the method below then extract the data he carried...
• Unit Group - Pick every unit in HealOverTimeUnits and do (Actions)
The data he carried is a real so load it...
• Set RemainingTime = (Load 0 of (Key (Picked unit)) from hashTable)
If the data is greater than 0 then save it again, deduct by 1
• Hashtable - Save (RemainingTime - 1.00) as 0 of (Key (Picked unit)) in hashTable is the
When it reaches 0 then the ELSE part will fire...

I hope this clears up a bit, btw it's better to store the ID/key into an integer like this...

set ID = GetHandleId(GetSpellTargetUnit())

and load it again like this...

set ID = GetHandleId(GetEnumUnit())

#### indomitable1319

Level 19
Thank you, ThaAthael. I had a hard time, but I'll re-read it again, to finally understand it.

mckill2009, the tutorial didn't really teach me when to put the actions in the loop and stuff, so I got really confused. :\
Thanks, I'll just re-read it to get the hang of it.

Level 19
Alright, I will.

#### ThaAthael

Level 5
Status
Not open for further replies.

Replies
12
Views
715
Replies
1
Views
712
Replies
2
Views
345
Replies
4
Views
1K
Replies
10
Views
283