• 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.

[Solved] What am I doing wrong here?

Status
Not open for further replies.
Level 9
Joined
Apr 19, 2011
Messages
447
Hi.

It has been a while since I last used the world editor, and I think I forgot some things about using hashtables...

  • Set TempReal = (Distance between TempLoc and TempLoc02)
  • Game - Display to Player 1 (red) the text: (String(TempReal))
  • Hashtable - Save TempReal as 4 of Key in HASH
  • Set TempReal = (Load 4 of Key from HASH)
  • Game - Display to Player 1 (red) the text: (String(TempReal))
The first game message shows a number (about 900). The second one shows 0.
I don't really know, but I fear I'm missing something here... because it doesn't make sense to me that I can't retrieve from a hashtable a value I've just saved! I think I'm actually missing something important.
:ogre_icwydt:

Can anyone tell me what am I doing wrong? (I think I'm going to regret this...)

Kind Regards
 
Level 5
Joined
May 6, 2013
Messages
125
Reminds me of the last time someone posted totally fine triggers with hashtables that somewhow didn't work. It also ended up in people asking why he didn't use Key (Handle) as his index. Well, the last guy forgot to actually save a hastable handle into his HASH variable (Create Hashtable, then set HASH = Last Created Hashtable). Might want to check this one ;)
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
A standard Hashtable usage;
  • Initialize Hashtable
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set udg_Hashtable = InitHashtable()
  • Testing Hashtable
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • -------- //////////// --------
      • -------- SAVING --------
      • Set SavedValue = (Life of (Triggering unit))
      • Custom script: set udg_parentKey = GetHandleId(GetTriggerUnit())
      • Set childKey = 0
      • Hashtable - Save SavedValue as childKey of parentKey in Hashtable
      • -------- //////////// --------
      • -------- LOADING --------
      • Game - Display to (All players) the text: (String((Load childKey of parentKey from Hashtable)))
I can't see you set Key to what value.

And do you really understand how to use Hashtable ?
It needs a key from a handle such as units, this way it can be loaded.

Look at my trigger and how I assign my parentKey
The parentKey must get an Integer/ID from a handle (in this case: (Triggering unit))

However for the childKey, it can be anything from 0 ~ 8191 (it can also be from negative values).

Hashtable is saving something to a something2 and you're gonna load the value from something2 using it as parentKey.
 
Level 9
Joined
Apr 19, 2011
Messages
447
Reminds me of the last time someone posted totally fine triggers with hashtables that somewhow didn't work. It also ended up in people asking why he didn't use Key (Handle) as his index. Well, the last guy forgot to actually save a hastable handle into his HASH variable (Create Hashtable, then set HASH = Last Created Hashtable). Might want to check this one ;)

OK, kill me now...
:goblin_cry:

This was the problem... It was so easy and simple that I didn't even see this possibility. Basicly, I was frustrating myself while trying to make a spell, and I made a quick map for testing, but with the hurries I forgot to save the hashtable in the variable...

A standard Hashtable usage;
  • Initialize Hashtable
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set udg_Hashtable = InitHashtable()
  • Testing Hashtable
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • -------- //////////// --------
      • -------- SAVING --------
      • Set SavedValue = (Life of (Triggering unit))
      • Custom script: set udg_parentKey = GetHandleId(GetTriggerUnit())
      • Set childKey = 0
      • Hashtable - Save SavedValue as childKey of parentKey in Hashtable
      • -------- //////////// --------
      • -------- LOADING --------
      • Game - Display to (All players) the text: (String((Load childKey of parentKey from Hashtable)))
I can't see you set Key to what value.

And do you really understand how to use Hashtable ?
It needs a key from a handle such as units, this way it can be loaded.

Look at my trigger and how I assign my parentKey
The parentKey must get an Integer/ID from a handle (in this case: (Triggering unit))

However for the childKey, it can be anything from 0 ~ 8191 (it can also be from negative values).

Hashtable is saving something to a something2 and you're gonna load the value from something2 using it as parentKey.

Well, it may be a bit confusing to you, because the trigger I show in my post is just a part of the whole thing. Yes, I know how to use hashtables. In fact, in my full trigger, the "Key" variable is the handle of a unit (the caster of the spell).
(I think I should've just post the full trigger instead of a small part of it...)



Thanks for the help!

Kind Regards
 
Status
Not open for further replies.
Top