• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Searching a Jass Tutorial...

Status
Not open for further replies.
Level 40
Joined
Dec 14, 2005
Messages
10,532
It's in the basic syntax.

JASS:
function myFunction takes paramArgs returns value
    //function contents
endfunction

//for example

function myFunction takes integer i, unit u returns real
    return GetWidgetLife(u) + i
endfunction

//somewhere else

local real r = myFunction(5,GetTriggerUnit())

//or just, if you don't need the return

call myFunction(5,GetTriggerUnit())
 
Level 5
Joined
Dec 18, 2007
Messages
205
If you want to learn JASS basically try the tutorial in my signature. It really helped me, i don't know what other people think about it.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Edit: Can I use in any trigger I want?

PurplePoot is right as usual ;) (this is becoming a habit of mine :p )
but I will go a bit further.
While being able to call them from other triggers, the function has to be before the place where you call it from.
JASS:
//Trigger 1
function a takes nothing returns nothing
call b()//Does not work
endfunction
function b takes nothing returns nothing
call a()//works
call c()//Does not work
endfunction

JASS:
//Trigger 2
function c takes nothing returns nothing
call a()//works
call b()//works
endfunction
P.s. In vJass, there are libraries and other ways to call functions.
 
Status
Not open for further replies.
Top