Well, first of all, you would need to initialize the hashtable:
-
Map Ini
-

Events
-

Conditions
-

Actions
-


Hashtable - Create a hashtable
-


Set VariableSet ItemsHashtable = (Last created hashtable)
Then you need to get reference to the item somehow. If it is items in inventory, then loop through unit's inventory. If it is on ground, then pick all items in region and loop through them. Or, if it is some item of interest, then when it is created, you track it in some array variable.
To load data from hashtable, you use the "Hasthable - Load {type} Value" function which requires two keys - the child and parent key (the format is "Load childKey of parentKey from hashtable").
For keys, you use "Hashtable - Get String ID" and "Hashtable - Get Handle ID" functions.
- HandleID is the unique number of an object in game.
- StringID creates a number from string - do note that this is case sensitive. There will be different StringID for "myKey" vs "MyKey".
Example:
-
Item - Pick every item in (Playable map area) and do (Actions)
-

Loop - Actions
-


Set VariableSet Agi = (Load (Key Agility.) of (Key (Picked item).) from ItemsHashtable.)
-


Set VariableSet Int = (Load (Key Intelligence.) of (Key (Picked item).) from ItemsHashtable.)
-


Set VariableSet Str = (Load (Key Strength.) of (Key (Picked item).) from ItemsHashtable.)
In the above, child keys Agility/Intelligence/Strength are StringIDs, while (Key (Picked item)) is HandleID.
When using the "Get Handle ID" function, there is a huge list of functions as it contains functions for all possible types (i.e. units, destructibles, items, etc.)
This is how you could iterate through inventory:
-
For each (Integer A) from 1 to 6, do (Actions)
-

Loop - Actions
-


Set VariableSet Agi = (Load (Key Agility.) of (Key (Item carried by your_unit in slot (Integer A)).) from ItemsHashtable.)
-


Set VariableSet Int = (Load (Key Intelligence.) of (Key (Item carried by your_unit in slot (Integer A)).) from ItemsHashtable.)
-


Set VariableSet Str = (Load (Key Strength.) of (Key (Item carried by your_unit in slot (Integer A)).) from ItemsHashtable.)
I believe the "Get Handle ID" function does not allow you to reference a variable - for those cases you will need a bit of JASS to get it:
-
Set VariableSet MyItem = (Last created item)
-
Custom script: set udg_HandleId = GetHandleId(udg_MyItem)
-
Set VariableSet Agi = (Load (Key Agility.) of HandleId from ItemsHashtable.)
The HandleId variable is of type 'integer'.