[vjass]How to take a struct by a element inside that

Iky

New Member
Reaction score
2
Well, the title said everything, i just want can take the struct by a unit named as a element of the struct
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
you mean how to get a struct from a member?
you could have a forward list of the allocated instances and itterate through them checking if each is it, if it reaches the beginning of the list, thats a nope, if not its not in that struct
but what im having an issue understanding is why you want to get which struct something is in, as any struct can contain the same data as another
Note: be prepared to be jumped by the dirac troll as i posted here and he has my sent...
 

Iky

New Member
Reaction score
2
the idea is a system that create struct by unit, add the unit to a unit group, and in another function, pick every unit in the group and take members of the struct that have the unit as a member
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
u mean get an instance from a unit or an actual struct
ie:
instance 40 - MyStruct(40).member
Struct - MyStruct

if thats what you want to do use a unit indexing system, i recommend AIDS or UnitIndexer
basically when a unit enters the map it assigns a number to that unit (saved in custom value of the unit)
and saves UnitVar[assigned integer] = entering unit
then you can use that as the instance of struct and both of those systems allow this via an ~onCreate method
ie:
JASS:
private method AIDS_onCreate takes nothing returns nothing
    set this.someMember = someval
    set this.someOtherMember = someotherval
endmethod

//! runtextmacro AIDS()

//OR ---------> (for UnitIndexer)

private method index takes nothing returns nothing
    set this.someMember = someval
    set this.someOtherMember = someotherval
endmethod

implement UnitIndexStruct


These make it so that when a unit is created you can save default info on them, which is nice...
also allows you to save values for each unique unit in a simple struct
the implement and textmacro are to make them an AIDS/UnitIndexer struct (instanced with each unit)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top