Struct question

Viikuna

No Marlo no game.
Reaction score
265
I need to know from which child struct this one static method was called.

I tried .getType() -method, but I couldnt get it work in static method.

I need something like this:
JASS:
struct Parent

 static method findInstance takes handle h returns Parent
    local Parent this=0
    if < SomeCondition is true > then
        set this=GetStoredInteger(Cache, < child structs name >, I2S(H2I(h)))
    endif
    return this
 endmethod
   // some stuff
endstruct

struct Child1 extends Parent
    // some stuff
endstruct

struct Child2 extends Parent
    // some stuff
endstruct

function test takes handle h returns nothing
    local Child1 a=Child1.findInstance(h)
    local Child2 b=Child2.findInstance(h)
endfunction


Is there some way to do something like this?
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
this is only for a method, not a static method.
A static method is just a simple function, there is no "instance" of it like a method.
 

Viikuna

No Marlo no game.
Reaction score
265
this in findInstance -method is just a local integer ( or Parent ), it could be something else, but I kinda like use this as a name for local struct variable.

So, if there is no way to tell if it is Child1.findInstance or Child2.findInstance , I need to think something else.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
this in findInstance -method is just a local integer ( or Parent ), it could be something else, but I kinda like use this as a name for local struct variable.

So, if there is no way to tell if it is Child1.findInstance or Child2.findInstance , I need to think something else.
Oops sorry i have miss read your code, but anyway you shouldn't don't use this, it is internally use by vJass for methods.
I don't have the use of struct extends now, so sorry i can't really help you.
 

Viikuna

No Marlo no game.
Reaction score
265
you shouldn't don't use this, it is internally use by vJass for methods.

That is actually the reason why I use it :D Im so used to type this.something and this.somethingelse all the time.
 
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