HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Question!

05-11-2007, 01:26 AM#1
Phish-Paste
Hi-
Just kinda starting JASS and was wondering about something. See code below.

Collapse JASS:
function lol takes string poo returns nothing
call DisplayTextToForce( GetPlayersAll(), poo)
endfunction

function spfx takes location a returns nothing
call AddSpecialEffectLocBJ( a, "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
endfunction

function unitmove takes unit a returns nothing
call IssuePointOrderLocBJ( a, "move", udg_Point )//Is it possible to integrate this line of code into function spfx so that I could save space?
endfunction

Thanks in advance.
05-11-2007, 02:44 AM#2
Pyrogasm
Yes. Why would you assume that you can't? A function can have as many f-ing function calls as you want:
Collapse JASS:
function spfx takes location a, unit u returns nothing
    call AddSpecialEffectLocBJ( a, "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
    call IssuePointOrderLocBJ( u, "move", udg_Point )
endfunction

I suppose the problem arises if you wanted to call the same function but do different things, AKA if you wanted to use the function to create the SFX but not order the move order. To do that, you'd need to do something like this, and pass "[ljass]null[/ljass" as the parameter you didn't want to do actions for:
Collapse JASS:
function spfx takes location a, unit u returns nothing
    if a != null then
        call AddSpecialEffectLocBJ( a, "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
    endif
    if u != null then
        call IssuePointOrderLocBJ( u, "move", udg_Point )
    endif
endfunction

function SomeFunction takes nothing returns nothing
    //...
    call spfx(SomeLoc, SomeUnit) //For both
    call spfx(SomeLoc, null) //For the SFX only
    call spfx(null, SomeUnit) //For the move order only
endfunction
I would also encourage you to use X/Y coordinates instead of locations, and in your Point issuing order call, you can pass udg_Point as a parameter.
05-11-2007, 04:33 AM#3
Ammorth
And stick away from functions with "BJ" "Simple" and "Swapped" in the name. Learn to use the natives early, and it won't be a problem later on.
05-11-2007, 11:06 AM#4
zen87
try take a look into vex's caster system, there is a small jass tutorial that really useful for beginner
05-11-2007, 11:14 PM#5
Phish-Paste
Oh, I see now, you have to create another function so that you can call that or the other...

Thanks!
05-12-2007, 12:34 AM#6
Pyrogasm
Well, yes. Everything in JASS is contained in a function or is itself a function; how else were you planning on calling it?