- Joined
- Jul 1, 2008
- Messages
- 1,314
Good Day Ladies and Gentlemen,
I would like to know, if there is a way to use a very simple way in vJass, to find the corresponding struct instance of a member variable. Like an operator method?
I got a treasure chest struct and want to find out the corresponding struct instance, given the treasure chest's unit!
Example:
Is there a direct way?
thanks for any help!
I would like to know, if there is a way to use a very simple way in vJass, to find the corresponding struct instance of a member variable. Like an operator method?
I got a treasure chest struct and want to find out the corresponding struct instance, given the treasure chest's unit!
Example:
JASS:
sruct chest
unit u
boolean open
endstruct
private function IsChestClosed takes unit ChestUnit returns boolean
local chest c
if GetUnitTypeId(ChestUnit) == CHEST_OBJECT_ID then
// CAN I DO THIS?
set c = GetInstanceOf( ChestUnit)
// CAN I DO THIS?
if c.open then
return true
endif
endif
return false
endfunction
JASS:
struct chest
static group allChests = CreateGroup()
static method register takes unit U returns thistype
local thistype this = 0
// CAN I DO THIS?
// How can I access this static group?
if not IsUnitInGroup( U, thistype.allChests) then
set this = thistype.allocate()
call GroupAddUnit( thistype.allChests, U)
set this.u = U
endif
return this
endmethod
endstruct
Is there a direct way?
thanks for any help!
Last edited: