Hashtable Array

hgkjfhfdsj

Active Member
Reaction score
55
any ideas on how to store arrays into hashtable? i got confused when it asked for index..eg

JASS:
    local timer t = CreateTimer() 
    loop
        exitwhen i == 5
        set udg_Wisp<i> = CreateUnit() 
        call SaveUnit(Hashtable, 0, GetHandleId(t), udg_Wisp<i>)
        set i = i + 1
    endloop</i></i>

how does unit get saved into the hashtable? and my main question is how to i load it? do i need to make another loop?? and do i use that second '0' as an array index? if so how?

JASS:
    local timer t = CreateTimer() 
    loop
        exitwhen i == 5
        set udg_Wisp<i> = CreateUnit() 
        call SaveUnit(Hashtable, i, GetHandleId(t), udg_Wisp<i>)
        set i = i + 1
// ...
        set wisp<i> = LoadUnit(Hashtable, i, GetHandleId(t))

    endloop</i></i></i>
 

PrisonLove

Hard Realist
Reaction score
78
JASS:
    local timer t = CreateTimer() 
    loop
        exitwhen i == 5
        set udg_Wisp<i> = CreateUnit() 
        call SaveUnit(Hashtable, i, GetHandleId(t), udg_Wisp<i>)
        set i = i + 1
// ...
        set wisp<i> = LoadUnit(Hashtable, i, GetHandleId(t))

    endloop</i></i></i>


Well, the function you're looking for is [ljass]call SaveUnitHandle()[/ljass], but just an observation: you should switch i and GetHandleId(t), if t is always one units. This way all of the wisps will be stored under one parent. Right now you have slot 1-t through 5-t, if you switch it you will have t-1 through t-5. Do you understand the difference? You're using up 5 spots in the hashtable currently, if you switch it you will be using up 1.
 

hgkjfhfdsj

Active Member
Reaction score
55
SaveUnitHandle>> lol xD freehand
slot 1-t through 5-t> so mission key is the parent and key is the child? or the other way
 

PrisonLove

Hard Realist
Reaction score
78
The first key to pop up is the parent key because when you use [ljass]call FlushChildHashtable(udg_hash, key)[/ljass] the key is what is used to clear that section of the hashtable. With the way you're doing you would have to clear it 5 times, instead of just 1 by doing it the other way.

For instance:

Your way would be
JASS:
call FlushChildHashtable(Hashtable, 1)
call FlushChildHashtable(Hashtable, 2)
call FlushChildHashtable(Hashtable, 3)
call FlushChildHashtable(Hashtable, 4)
call FlushChildHashtable(Hashtable, 5)


The other way would just be:
JASS:
call FlushChildHashtable(Hashtable, GetHandleId(t))
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top