Hashtable syntax help needed

Status
Not open for further replies.
Level 24
Joined
Aug 1, 2013
Messages
4,658
Hi all.

I am using a lot of hashtables lately but I don't know if I do it right.

I use SaveInteger(hashtable, objectId, parameterId, value) to save integers for example.
(call SaveInteger(udg_Hashtable, GetHandleId(whichUnit), udg_Hash_Unit_Speed, 900.))

But when the unit is removed, I do not need the values any more.
To remove the data (I assume that I have to do it to save memory) I can only clear the "child" of a hashtable.

So I can only remove either the X or the Y.
However I do not know if my syntax is right or if I have to do (udg_Hash_Unit_Speed, GetHandleId(whichUnit)) instead.

Also my editor does not highlight any hashtable functions at all. Neither red nor pink.
Is this a known thing that Blizzard makes functions but they are not saved in the hightlighting list?

Help would be appreciated very much ;)
 
JNGP was made from an older version of the editor, so it doesnt contain them(and I guess TESH cant find them). They will compile correctly, though. I suggest you put all hastable related(or basically everything that isnt in TESH) in a something.j in the '\jass'(I think?) '\tesh\includes' folder of your JNGP directory.
E:
native SaveInteger takes hashtable table, integer parentKey, integer childKey, integer value returns nothing to save
native LoadInteger takes hashtable table, integer parentKey, integer childKey returns integer to load
 
Isn't there an option that I can register my own functions as real functions?
Like I put very basic functions like B2S(Boolean to String) or I2B(Integer to Boolean) and stuff like that in a script and import it into JASSHelper.
So that those will be highlighted and maybe also show the description (which you make yourself) in the functions list?

(Still I have to know if my syntax is right.)
 
You can just put something like this:
JASS:
function foo takes nothing returns nothing
    //This is the best function ever
    call BJDebugMsg("It basically acts like a BJ, everything get shown when you ctrl + click it")
endfunction
and TESH will do the highlighting and autocompleting for you (you cant change the colors, I think)
E: You can also try the //!import "filename" feature of jasshelper if it give an error (which it should, I think)
 
Did you inclide the endfunction?
What TESH are you using? If its the one from JNGP 5 then I can give you mine(its the default, im pretty sure). You can just redownload looking_for_help's TESH and replace everything if its the one youre using(not much reason to stay with the old one, really).
 
ExtraFunctions is a custom set of functions from myself, so it is not supposed to be highlighted.
However, the problem you describe about highlighting comes from having an outdated TESH. I use the one from jngpe 1.5e and have not had problems with it so far.
 
E:
native SaveInteger takes hashtable table, integer parentKey, integer childKey, integer value returns nothing to save
native LoadInteger takes hashtable table, integer parentKey, integer childKey returns integer to load

Lol didnt see that. However that was not my question.

My question was in what order do I have to save.
Because I can flush a child from a hastable...
Flush parent looks like it will clear the whole hashtable.
So the parent/child in flush is definately not the same as parent/child in save/load.
 
Well it depends.

If you use the handleId of a unit as "main key" then use the handleId as parentkey:

JASS:
local integer id = GetHandleId(unit)
call SaveInteger(hash, id, 0, int_1)
call SaveInteger(hash, id, 1, int_2)
call SaveInteger(hash, id, 2, int_3)
...
call FlushChildHashtable(hash, id) // remove all attached integers
 
Status
Not open for further replies.
Back
Top