• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Setting Hastable Value to...nothing?

Status
Not open for further replies.
Level 7
Joined
Sep 19, 2012
Messages
204
Hey guys,

Is there a way to set a hashtable value to...nothing... basically (to clear it).

What i want to do is clear a saved Handle of a Unit out of the Hastable so when i check for "is equal to NoUnit" it triggers again...

i tried this:
  • Hashtable - Save Handle OfNo unit as Grp_temp_int of (Custom value of (Casting unit)) in Grp_UnitHash
but it doesnt work...i guess because im telling him to save nothing...so he does xD

greetings
CodeBlack
 
Level 13
Joined
May 10, 2009
Messages
868
You'll probably have to combine the following JASS functions in order to do what you want
JASS:
    native RemoveSavedHandle takes hashtable table, integer parentKey, integer childKey returns nothing
    native HaveSavedHandle takes hashtable table, integer parentKey, integer childKey returns boolean

    [...]
 
    // Flush handle data from the table
    call RemoveSavedHandle(udg_Grp_UnitHash, GetUnitUserData(GetTriggerUnit()), udg_Grp_temp_int)
 
    // If there's no handle stored here
    if not HaveSavedHandle(udg_Grp_UnitHash, GetUnitUserData(GetTriggerUnit()), udg_Grp_temp_int) then
        // Do stuff
    endif
 
Level 7
Joined
Sep 19, 2012
Messages
204
You'll probably have to combine the following JASS functions in order to do what you want
JASS:
    native RemoveSavedHandle takes hashtable table, integer parentKey, integer childKey returns nothing
    native HaveSavedHandle takes hashtable table, integer parentKey, integer childKey returns boolean

    [...]
 
    // Flush handle data from the table
    call RemoveSavedHandle(udg_Grp_UnitHash, GetUnitUserData(GetTriggerUnit()), udg_Grp_temp_int)
 
    // If there's no handle stored here
    if not HaveSavedHandle(udg_Grp_UnitHash, GetUnitUserData(GetTriggerUnit()), udg_Grp_temp_int) then
        // Do stuff
    endif

alright :)
This did the Trick:
  • Custom script: call RemoveSavedHandle(udg_Grp_UnitHash, GetUnitUserData(GetTriggerUnit()), udg_Grp_temp_int)
i used it as custom Code since im trying to keep it as "jass free" as possible...

Thanks a lot! +rep
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
To emphisize what Tasyen said, the function...
JASS:
native FlushParentHashtable takes hashtable table returns nothing
Is actually the hashtable destructor. It will effectively destroy the passed hashtable, making it unable to be used ever again. This is clearly a case of incorrect naming that can confuse.
 
Status
Not open for further replies.
Top