- 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: