• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[vJASS] About "keyword".

Status
Not open for further replies.
Level 11
Joined
Oct 11, 2012
Messages
711
Hey guys, why the following does not work? Thanks a lot.
JASS:
scope example 
    keyword B
    //private keyword B does not work neither
    
    private function A takes nothing returns nothing
        local timer t = CreateTimer()
        call TimerStart(t,period,true,function B)
        set t = null
    endfunction
    
    private function B takes nothing returns nothing
        local timer t = GetExpiredTimer()
        .....
        set t = null
    endfunction
endscope
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
Your code will not work nevertheless, because this is vJass feature and in Jass you cannot reference functions that are defined below your function, so even if

JASS:
keyword B

function A takes nothing returns nothing
    call B.execute()
endfunction

function B takes nothing returns nothing
endfunction

works, if you put TimerStart, or Condition or anything that takes code as parameter into function A, you cannot make it work and you will have to move the function above A
 
Level 11
Joined
Oct 11, 2012
Messages
711
Your code will not work nevertheless, because this is vJass feature and in Jass you cannot reference functions that are defined below your function, so even if

JASS:
keyword B

function A takes nothing returns nothing
    call B.execute()
endfunction

function B takes nothing returns nothing
endfunction

works, if you put TimerStart, or Condition or anything that takes code as parameter into function A, you cannot make it work and you will have to move the function above A

Got it, thnx, +Rep
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
JASS:
scope example initializer init
    globals
        private code B_CODE
    endglobals
    
    private function A takes nothing returns nothing
        local timer t = CreateTimer()
        call TimerStart(t,period,true,B_CODE)
        set t = null
    endfunction
    
    private function B takes nothing returns nothing
        local timer t = GetExpiredTimer()
        .....
        set t = null
    endfunction

    private function init takes nothing returns nothing
        set B_CODE = function B
    endfunction
endscope
 
Level 11
Joined
Oct 11, 2012
Messages
711
JASS:
scope example initializer init
    globals
        private code B_CODE
    endglobals
    
    private function A takes nothing returns nothing
        local timer t = CreateTimer()
        call TimerStart(t,period,true,B_CODE)
        set t = null
    endfunction
    
    private function B takes nothing returns nothing
        local timer t = GetExpiredTimer()
        .....
        set t = null
    endfunction

    private function init takes nothing returns nothing
        set B_CODE = function B
    endfunction
endscope

Beautiful, +Rep!
 
Status
Not open for further replies.
Top