• 🏆 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!

[Trigger] How do I put this in a hashtable? (Hashtable Problems)

Status
Not open for further replies.
Level 5
Joined
Nov 6, 2014
Messages
70
And I'm trying to put a categorization of 'ogres', 'trolls', and 'murlocs', because I'm using abilities like ancient spirit that will detect the race of these units.

Here's my preset variables.

JASS:
function Trig_RaceOgre_Copy_Actions takes nothing returns nothing
    set udg_RaceOgre[0] = 'o008'
    set udg_RaceOgre[1] = 'o00A'
    set udg_RaceOgre[2] = 'o00D'
    set udg_RaceOgre[3] = 'o00F'
    set udg_RaceOgre[4] = 'n005'
    set udg_RaceOgre[5] = 'n007'
    set udg_RaceOgre[6] = 'n006'
endfunction

//===========================================================================
function InitTrig_RaceOgre_Copy takes nothing returns nothing
    set gg_trg_RaceOgre_Copy = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_RaceOgre_Copy, 2.00 )
    call TriggerAddAction( gg_trg_RaceOgre_Copy, function Trig_RaceOgre_Copy_Actions )
endfunction

I need help because I'm stuck here @ handles, integers, and stuff in hashtables. Any I ideas how to succeed?

JASS:
function Trig_Preset_Copy_Actions takes nothing returns nothing
    call InitHashtableBJ(  )
    set udg_RaceOgreHahstable[1] = GetLastCreatedHashtableBJ()
endfunction

//===========================================================================
function InitTrig_Preset_Copy takes nothing returns nothing
    set gg_trg_Preset_Copy = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_Preset_Copy, 2.00 )
    call TriggerAddAction( gg_trg_Preset_Copy, function Trig_Preset_Copy_Actions )
endfunction
 
Last edited by a moderator:
Level 15
Joined
Nov 30, 2007
Messages
1,202
You want to save it as category "ogre"?

JASS:
hashtable hash = InitHashtable()

//
local integer i = 0
loop
call SaveInteger(hash, udg_RaceOgre[i], 0, StringHash("ogre"))
set i = i + 1
exitwhen i == MaxOgres // 7 in your example
endloop
//
if StringHash("ogre") == LoadInteger(hash, GetUnitTypeId(SomeUnit), 0) then
    call BJDebug("Ogre Detected!")
endif
 
Last edited:
Status
Not open for further replies.
Top