• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Solved] Storing item type in hashtable question

Status
Not open for further replies.
Level 11
Joined
Oct 9, 2015
Messages
721
I wanted to ask if storing item-type in a hashtable works the same way as storing unit-type:
  • Set Item_Type = Bronze Dagger
  • Custom script: set udg_TempInteger = udg_Item_Type
  • Hashtable - Save 0.70 as 1 of TempInteger in My_Hashtable
I'm doing this actions but when I try to load the value it returns "0"

So how can I do it properly ?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
I wanted to ask if storing item-type in a hashtable works the same way as storing unit-type:
You mean mapping a value to an item type (what is shown above)? Yes it works in exactly the same way as it is also an integer type code like unit type is.
I'm doing this actions but when I try to load the value it returns "0"
Make sure you initialize the hash table before trying to use it. You will be surprised how often this is overlooked or forgotten.
So how can I do it properly ?
Initialize hash table, write the mapping and then try loading the mapping.
 
Level 11
Joined
Jun 2, 2004
Messages
849
The code you posted looks fine, so yeah it's likely either an uninitialized hashtable or something wrong with the code that loads from the hashtable later.

Just to be sure, the value you're trying to save is 0.7, right? The GUI hashtable functions are honestly bizarrely presented so lots of people get confused. The code you posted would be in c-like syntax: "My_Hashtable[TempInteger][1] = 0.7;"
 

EdgeOfChaos

E

EdgeOfChaos

For information: ability type, item type, unit type, buff type, etc. These are all the same thing. They are represented internally as integers, so anything you can do with one of them you can do with all.
 
Level 11
Joined
Oct 9, 2015
Messages
721
Saving:
  • Hashtable - Create a hashtable
  • Set HASH_Weapons = (Last created hashtable)
  • Set OBJECT_Weapon_Type = Bronze Dagger
  • Custom script: set udg_OBJECT_WeaponInteger = udg_OBJECT_Weapon_Type
  • Hashtable - Save 0.70 as OBJECT_WP_Reach of OBJECT_WeaponInteger in HASH_Weapons
Loading
  • Set OBJECT_WP_Reach = (Load OBJECT_WP_Reach of OBJECT_WeaponInteger from HASH_Weapons)
  • Game - Display to Player Group - Player 1 (Red) the text: (String(OBJECT_WP_Reach))
 
Level 11
Joined
Oct 9, 2015
Messages
721
yeah, it's a INTEGER and it stands for the item-type's attack reach. I think I was able to load the value using the function:
  • Set TempRealNew[1] = (Load OBJ_WP_Reach of OBJECT_WeaponInteger from HASH_Weapons)
as it now returns the correct message when used a "Display text" function
 
Status
Not open for further replies.
Top