code variables save methods? +rep for help

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
would this compile and work just like using [ljass]local code c = function SomeFunction[/ljass]?

JASS:
struct MyStruct
    method SomeMethod takes nothing returns nothing
    endmethod

    method OtherMethod takes nothing returns nothing
        local code c = method SomeMethod //would this work correctly?
    endmethod
endstruct

function MyFunc takes nothing returns nothing
    local code c = method MyStruct.SomeMethod //would this also work correctly?
endfunction


also, would [ljass]call TriggerAddCondition(trigger, Filter(c))[/ljass] work if c is a code variable with a method saved?
 

Laiev

Hey Listen!!
Reaction score
188
JASS:
struct MyStruct
    static method SomeMethod takes nothing returns nothing
    endmethod

    method OtherMethod takes nothing returns nothing
        local code c = function thistype.SomeMethod() //this work
    endmethod
endstruct

function MyFunc takes nothing returns nothing
    local code c = function MyStruct.SomeMethod() //this work
endfunction


And yes for your question about [ljass]TriggerAddCondition[/ljass].
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
@Laiev: you might want to test thing out before replying/posting:

In vJass the only way (I know of and my jassheleper version supports) of assigning methods to code variables is if the methods are static, take no arguments and the function keyword is used and the struct's name is used with the method, like this:

JASS:
struct MyStruct
    static method SomeMethod takes nothing returns nothing
    endmethod

    method OtherMethod takes nothing returns nothing
        local code c = function MyStruct.SomeMethod
    endmethod
endstruct

function MyFunc takes nothing returns nothing
    local code c = function MyStruct.SomeMethod
endfunction
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
good to know both of u (luorax and sgqvur)
i was wondering primarily if i could create triggers in structs using just methods, didnt want to put a function above my struct in the library, im sure it would look terribly unorganized having my core actions there

i will keep this in mind when referencing code variables, does this count the same for normal functions? (no arguments)
 

PurgeandFire

zxcvmkgdfg
Reaction score
508
good to know both of u (luorax and sgqvur)
i was wondering primarily if i could create triggers in structs using just methods, didnt want to put a function above my struct in the library, im sure it would look terribly unorganized having my core actions there

Yeah you can use methods for them (preferably static) as the above posters said.

i will keep this in mind when referencing code variables, does this count the same for normal functions? (no arguments)

Yes this applies for normal functions.
 
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