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

[Solved] Saving Structs

Status
Not open for further replies.
Level 3
Joined
Sep 10, 2012
Messages
39
**solved**

I am creating a system that assigns various attributes to each unit on a map. I am attempting to base the system primarily on structs, where a struct is created that holds all pertinent information. The problem I am having is that I cannot find a way of associated the struct with the unit. I attempted to save the struct to a hashtable, but, after loading the struct from the table, any attempt to retrieve information held within generates an exception. I know that the index of the struct is what is given to the hashtable, and it would seem that the conversion is one-way.

For example:

JASS:
       static method create takes unit subject returns Attributes
           local Attributes this = Attributes.allocate()

           set this.SubjectID = GetHandleId(subject)
           set this.TypeID = GetUnitTypeId(subject)

           set this.RegenLife = LoadReal (udg_HashTable_Attributes, this.TypeID, 71)
           set this.RegenMana = LoadReal (udg_HashTable_Attributes, this.TypeID, 72)
         
           call SaveInteger(AttributesTable, 1, this.SubjectID, this)

           return this
       endmethod

JASS:
    local unit RegenUnit = GetEnumUnit()
   local integer RegenUnitID = GetHandleId(RegenUnit)
   local Attributes attributes = LoadInteger(AttributesTable, 1, RegenUnitID)
 
   local RegenRateLife = attributes.RegenLife



throws the JassHelper error
Unexpected:".RegenLife"
 
Last edited:
Level 3
Joined
Sep 10, 2012
Messages
39
Oh, jeez. A simple syntax error... bleh. They trip me up more than I would like to admit, and they're so easy to overlook...

Anyway, thank you much for the assistance, and I'll give your indexer a try.
 
Status
Not open for further replies.
Top