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

I was trying to convert my hashtables into table

Status
Not open for further replies.
Oh yeah. It isn't a 1:1 correspondence with the hashtable function. The whole philosophy of Table revolves mostly around the idea of using a struct as the storage for a multitude of data.

Naïve hashtable usage involves long lists of data being stored:
JASS:
call SaveBoolean(hash, id, 0, true)
call SaveUnit(hash, id, 1, caster)
call SaveUnit(hash, id, 2, target)
Table usage revolves around storing the struct and letting that do everything for you:
JASS:
struct Data
    static Table storage = 0

    unit caster
    unit target
    boolean something
    
    private static method onInit takes nothing returns nothing
        set storage = Table.create()
    endmethod
endstruct

// ... some code
local Data d = Data.create()
set storage[id] = d

That is just a random example. The main concern is the line: set storage[id] = d. Rather than storing all data individually in the hashtable, you simply store the struct. Later on, you can load the struct from the same ID and then grab whatever data you want. In a sense, you can picture structs as "packing" the data into a box.
 
Status
Not open for further replies.
Top