HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Executing triggers with parameters

07-27-2002, 08:04 PM#1
Guest
Does anyone know if it is possible to execute a trigger with a incoming parameter?

I havent seen it anywhere in the standard trigger view but i was hoping that there was some way to do it in custom text.

Something like

function Trig_Untitled_Trigger_001_Actions takes integer foobar returns nothing
// some actions based on the value of foobars
endfunction


And then another trigger with the action

call Trig_Untitled_Trigger_001( [integer param] )

Unfortunalty the compiler doesnt accept "Trig_Untitled_Trigger_001" as a valid function even though it has been previously declared. And the function TriggerExecute doesnt take any extra parameters like:

TriggerExecute( Trig_Untitled_Trigger_001, [integer param] )
07-27-2002, 08:35 PM#2
weaaddar
You actually go Function Trigger_name_here. I don't know about parameters but thats how you call another trigger whats intresting in custom text you can REgestir events to triggers instead of triggers to even.
07-27-2002, 09:20 PM#3
Guest
Thanks for the quick reply

1) "You actually go Function Trigger_name_here"
Are you sure about that? If i convert a gui trigger that calls another trigger it converts it to
call ConditionalTriggerExecute( gg_trg_Trigger_Name )
or
call TriggerExecute( gg_trg_Trigger_Name )
depending on if you want it to check conditions
Doesnt function and endfuntion only define triggers?

2) What do you mean with "you can register events to triggers"?
Do you mean the action call TriggerRegister[eventToRegister]?

Ive mange to create a trigger that really takes an incoming parameter but war3 crashes as soon as the trigger is executed since i havent managed to address it with a proper value.
07-27-2002, 11:36 PM#4
weaaddar
Here is an example to prove some of the points...Its a dumb trigger that generates an error message after 35 seconds but it does the job and well.
Code:
//===========================================================================
function EndGameScore takes nothing returns nothing
    call EndGame( false )
endfunction
//===========================================================================
function Trig_Check_your_name_Actions takes nothing returns nothing
//local varaibles becuase man is it annoying to go into that variable menu and No unforutnatly I can't define global or constant varaibles in triggers (you can in an AI file wink wink)which geniunly sucks
    local dialog  D = DialogCreate() 
    local trigger t = CreateTrigger()
    call DialogSetMessageBJ( D, "|C00FF0000FATAL ERROR:|r |CFFFFFFFF Your playing a stolen MAP!|r" )

//right here i'm creating a new trigger 

TriggerRegisterDialogButtonEvent( t, DialogAddButton( D, GetLocalizedString( "GAMEOVER_QUIT_GAME" ), GetLocalizedHotkey("GAMEOVER_QUIT_GAME") ) )

    call TriggerAddAction( t, function EndGameScore )    //Yup function called here. You actually won't go trigger name but the actions function name    
    call TriggerSleepAction( 0.10 )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 12
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call DialogDisplayBJ( true, D, ConvertedPlayer(GetForLoopIndexA()) )

        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Check_your_name takes nothing returns nothing
    set gg_trg_Check_your_name = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_Check_your_name, 35 )
    call TriggerAddAction( gg_trg_Check_your_name, function Trig_Check_your_name_Actions )
endfunction