HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to use 1.23b functions with regular JASS?

06-13-2009, 06:15 PM#1
skullzilla
Could someone explain how to use these new natives? What exactly can I do with them?
I can make a 2d array I assume? I don't really know what all they can do so I'm not sure what to ask.
I don't use anything other than normal world editor so if you could please explain using normal JASS.
Thanks.
06-13-2009, 10:27 PM#2
Rising_Dusk
Quote:
Originally Posted by Rising_Dusk
Newest JNGP + Patched WC3 + 1.21 WorldEdit.exe = Successful Work Station
When you've done all of that, you have access to everything in the current 1.23b build.
06-14-2009, 01:41 PM#3
ToukoAozaki
First, you have to create a hashtable variable.

The next thing you have to do is initializing the variable.
Let's say the name of the variable is "ht" (udg_ht).

Collapse JASS:
function Trig_Initialization_Actions takes nothing returns nothing
    set udg_ht = InitHashtable() // initialize hashtable instance
endfunction

Once that code is executed, you can now use other natives to access it.

For instance, if you want to save an integer, the function looks like this.
SaveInteger(hashtable table, integer parentKey, integer childKey, integer value)
Example:

call SaveInteger(udg_ht, 0, 0, 35)
To retrieve the value, you can use this function:

LoadInteger(hashtable table, integer parentKey, integer childKey)
Example:

call BJDebugMsg(I2S(LoadInteger(udg_ht, 0, 0))) // will print 35
There are natives to check whether there is a saved value. However, currently only one for handle functions correctly.

HaveSavedInteger(hashtable table, integer parentKey, integer childKey) // doesn't work for now
To remove the single value:

RemoveSavedInteger(hashtable table, integer parentKey, integer childKey)
To remove all values associated to parentKey:

FlushChildHashtable(hashtable table, integer parentKey)
To remove everything from the hashtable:

FlushParentHashtable(hashtable table)
You can only use integers for the keys. If you want to use other things like handle or string, you need to make them integers. Use GetHandleId for handles and StringHash for strings.

Example code:

Collapse JASS:
function Test takes nothing returns nothing
    call SaveInteger(udg_ht, 0, 0, 256) // save 256 to [0, 0]

    set bj_forLoopAIndex = LoadInteger(udg_ht, 0, 0) // load the saved value

    //if HaveStoredInteger(udg_ht, 0, 0) then // this doesn't work properly; always returns false
        call RemoveSavedInteger(udg_ht, 0, 0) // remove the stored value
    //endif
    call BJDebugMsg(I2S(bj_forLoopAIndex)) // prints 256
    call BJDebugMsg(I2S(LoadInteger(udg_ht, 0, 0))) // prints 0
endfunction

If you want to store and retrieve other types, then find and use appropriate one.
06-14-2009, 09:21 PM#4
skullzilla
Thanks ToukoAozaki!

I got it now.