• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Hashtables, Handles what are they?

Status
Not open for further replies.
Level 2
Joined
Apr 9, 2012
Messages
8
So if someone could direct me to a section or a post or what to search or even explanation on Hashtables, Handles and anything that relates to them. I see a lot about them and I'm curious as to what they are/what they do.

Anything is appreciated :D
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Noob Version :

A hashtable is kinda like a variable array with 2 []s but u can store more than just one type of variable in it. So you could like store "myvariable" in 1 of 2 into hashtable and it would basically store "myvariable" as a string in MyHash[1][2].

Handles, every reference in-game is a handle besides string, text, reals, and integers. Everything besides that has a special memmory allocation, handle, that it functions off of. With the introduction of hashtables, handles also became better because hashtables dont have a limit of B192 on arrays so you can save handles. For example

Save "whatever" as Handle Of (casting unit) of 2 in MyHash and it will save Whatever as MyHash[Handle of Casting Unit][2] and since all handles are unique this allows scripters to create MUI scripts (or scripts where multiple units can function them at the same time)

Advanced :

http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/hashtables-mui-133407/
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hashtables works with integers. Integers are whole numbers. That's why most people use Handles: these are integers that refers to almost anything in the game.

You se a Footman, but that footman can be something like 205712423773. That number is unique for it. Trees, Special Effects, Units, Buildings, Regions, etc., have also a unique ID.

Hashtables uses 3 values: You save Z as X of Y in HashName

Lets say i want to save the number of kills each unit in my map has:
Z = Number of Kills
X = Slot #0
Y = The unit Handle ID.

Whenever a unit dies, I take the Handle ID of the Killing Unit. I save a +1 on its slot 0 (The formula would be Slot#0 = Slot#0 + 1). Then, when I want to see it on screen, I just make the game display the value saved in Slot#0 of that unit.

The interesting part is that X and Y are infinite. So, you can save any amount of information about almost anything in a hashtable. Indeed, you can create hundred of abilities just making a good use of the infinite indexes...

Etc... xD
 
Status
Not open for further replies.
Top