[vJass] Function callback

0zaru

Learning vJASS ;)
Reaction score
60
i think that you can't as far i know but have you tryed using method instead of function ? I think that you can't but you can have a try
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
timelib..?
Never heard of it though..

@uber
I think that uber got the answer for me...I havent tried it out though.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
Well, I have another problem that is similar to this.
How can I do this:
JASS:
struct ss
group p = CreateGroup()

method Cond takes nothing returns boolean
  return GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE) >0 and IsUnitInGroup(GetFilterUnit(),.p) == false
endmethod

method Act takes nothing returns nothing
  call KillUnit(GetEnumUnit())
  call GroupAddUnit(.p,GetEnumUnit())
endmethod
endstruct

function somefunc takes nothing returns nothing
local ss ii = ss.create()
  call GroupEnumUnitsInRange(ii.p,0,0,200, Condition(function ii.Cond))
  call ForGroup(ii.p,function ii.Act)
endfunction
 

Silvenon

New Member
Reaction score
19
Whoa, whoa, slow down guys.

Isn't it the other way around?

JASS:
struct A
    method AMethod takes nothing returns nothing
    // ...
    endmethod
endstruct

function RunMethod takes nothing returns nothing
    local A a = A.create()
    call a.AMethod()
endfunction


And:

JASS:
struct A
    static method AMethod takes nothing returns nothing
    // ...
    endmethod
endstruct

function RunMethod takes nothing returns nothing
    call A.AMethod()
endfunction


Because .create is a static method and it is called like <struct name>.create(), not <struct instance (var) name>.create().

Btw, you're missing endmethod in Cond method.

What's BJS_DamagedCond supposed to be?

Why would you use ForGroup anyways?

I still don't get Timelib, because there's no explanation on how to use it or what it is anyways. Can someone explain?
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>Because .create is a static method and it is called like <struct name>.create(), not <struct instance (var) name>.create().
Hmm, I think I know this.

>>Btw, you're missing endmethod in Cond method.
Silly mistake caused by fast typing.

>>Why would you use ForGroup anyways?
Because I can't use ForGroupBJ.

@Silvernon
Hmm, you don't get my question.
Saw my method that uses this. ? I wanted method to be used as a ConditionFunc of my group picking...understand?
Well, I can't use static method. As I need to get back the value that is being set in the struct instance.
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
JASS:
struct ss
group p = CreateGroup()

method Cond takes nothing returns boolean
  return GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE) &gt;0 and IsUnitInGroup(GetFilterUnit(),.p) == false
endmethod

method Act takes nothing returns nothing
  call KillUnit(GetEnumUnit())
  call GroupAddUnit(.p,GetEnumUnit())
endmethod
endstruct

function somefunc takes nothing returns nothing
local ss ii = ss.create()
  call GroupEnumUnitsInRange(ii.p,0,0,200, Condition(function ii.Cond))
  call ForGroup(ii.p,function ii.Act)
endfunction

Why do you need that condition to be a struct method anyway? The last check is not needed since it doesn't matter if you add a unit to a group twice, the same thing applies to the ss.Act method.

It seems as you are using structs just because you "want" to use them, if it makes the solution more complex then you are wasting time.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top