Functions

Ryuu

I am back with Chocolate (:
Reaction score
64
Is there any specific order in which functions must be arranged in?

For example this

JASS:
function Whatever takes nothing returns nothing
   call AnotherWhatever()
endfunction

function AnotherWhatever takes nothing returns nothing
   call DisplayTextToForce( GetPlayersAll(), "Lol" )
endfunction


Is it the same as this

JASS:
function AnotherWhatever takes nothing returns nothing
   call DisplayTextToForce( GetPlayersAll(), "Lol" )
endfunction

function Whatever takes nothing returns nothing
   call AnotherWhatever()
endfunction


?
 

XeNiM666

I lurk for pizza
Reaction score
138
function no. 1 wont work. function no. 2 will.

to call a function (AnotherWhatever), it must be up the function your declaring in. (Whatever)
 

Ryuu

I am back with Chocolate (:
Reaction score
64
Ooh.. but what if you declare two functions in one function? The other two functions, must they be in any order?
 

XeNiM666

I lurk for pizza
Reaction score
138
yes. they must be above (finally i got the right term) the function your declaring them in.
 

Ryuu

I am back with Chocolate (:
Reaction score
64
JASS:
function AnotherWhatever takes nothing returns nothing
   call DisplayTextToForce( GetPlayersAll(), "Lol" )
endfunction

function YetAnotherWhatever takes nothing returns nothing
   call DisplayTextToForce( GetPlayersAll(), "Lol again" )
endfunction

function Whatever takes nothing returns nothing
   call AnotherWhatever()
endfunction


or

JASS:
function YetAnotherWhatever takes nothing returns nothing
   call DisplayTextToForce( GetPlayersAll(), "Lol again" )
endfunction

function AnotherWhatever takes nothing returns nothing
   call DisplayTextToForce( GetPlayersAll(), "Lol" )
endfunction

function Whatever takes nothing returns nothing
   call AnotherWhatever()
endfunction


which?
 

XeNiM666

I lurk for pizza
Reaction score
138
any of the 2 as long as AnotherWhatever or YetAnotherWhatever is above Whatever, it will work.

This will work:
JASS:
function YetAnotherWhatever takes nothing returns nothing
   call DisplayTextToForce( GetPlayersAll(), "Lol again" )
endfunction

function AnotherWhatever takes nothing returns nothing
   call DisplayTextToForce( GetPlayersAll(), "Lol" )
endfunction

function Whatever takes nothing returns nothing
   call AnotherWhatever()
   call YetAnotherWhatever()
endfunction


This wont:
JASS:
function YetAnotherWhatever takes nothing returns nothing
   call DisplayTextToForce( GetPlayersAll(), "Lol again" )
endfunction

function Whatever takes nothing returns nothing
   call AnotherWhatever() //Syntax error because AnotherWhatever is not above this function.
   call YetAnotherWhatever()
endfunction

function AnotherWhatever takes nothing returns nothing
   call DisplayTextToForce( GetPlayersAll(), "Lol" )
endfunction
 
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