• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 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!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

[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