HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Trigger just doesn't work...

03-18-2008, 03:02 AM#1
Salbrismind
My map only has two triggers:

Trigger:
Presets
Collapse Events
Map initialization
Conditions
Collapse Actions
Set Cameramen[1] = Camera Man 0011 <gen>


Collapse JASS:
function Trig_Camera_Presets_Actions takes nothing returns nothing
    local integer num = 0
    loop 
        exitwhen num == 10
        set num = num + 1
        call BJDebugMsg(I2S(num))
        call SetCameraTargetControllerNoZForPlayer( Player(num-1), udg_Cameramen[num], 0, 0, false )
        call SetCameraFieldForPlayer( Player(num-1), CAMERA_FIELD_ANGLE_OF_ATTACK, -45.00, 0 )
    endloop

endfunction

//===========================================================================
function Trig_Camera_Presets takes nothing returns nothing
    set gg_trg_Camera_Presets = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_Camera_Presets, 1.0 )
    call TriggerAddAction( gg_trg_Camera_Presets, function Trig_Camera_Presets_Actions )
endfunction

But when I run the map the second trigger doesn't seem to run at all. Can someone please take a quick look at this? Thanks to anyone who can help!

My map: Millipede Defense v0.1 Test.w3x
Attached Files
File type: w3xMillipede Defense v0.1 Test.w3x (116.1 KB)
03-18-2008, 03:09 AM#2
Rising_Dusk
Your second trigger needs its InitTrig to be named as follows -- "InitTrig_Camera_Presets"
Expand JASS:
03-18-2008, 03:24 AM#3
Salbrismind
Oh my bad, I removed that because I thought it was some useless prefix. Isn't there a way to get around use so many words in a line? I swear I saw some spells that didn't have that prefix. Either way thanks again for saving me.
03-18-2008, 03:41 AM#4
Zandose
Quote:
Originally Posted by Salbrismind
Oh my bad, I removed that because I thought it was some useless prefix. Isn't there a way to get around use so many words in a line? I swear I saw some spells that didn't have that prefix. Either way thanks again for saving me.
Use vJASS. By using scopes (and public/private prefixes before functions) "InitTrig_Camera_Presets" becomes "InitTrig" and "Trig_Camera_Presets_Actions" becomes just "Actions".

Collapse JASS:
scope CameraMan

private function Actions takes nothing returns nothing
    local integer num = 0
    loop 
        exitwhen num == 10
        set num = num + 1
        call BJDebugMsg(I2S(num))
        call SetCameraTargetControllerNoZForPlayer( Player(num-1), udg_Cameramen[num], 0, 0, false )
        call SetCameraFieldForPlayer( Player(num-1), CAMERA_FIELD_ANGLE_OF_ATTACK, -45.00, 0 )
    endloop
endfunction

public function InitTrig takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle(t, 1.0 )
    call TriggerAddAction(t, function Actions )
endfunction

endscope
03-18-2008, 07:35 PM#5
Salbrismind
Quote:
Originally Posted by Zandose
Use vJASS. By using scopes (and public/private prefixes before functions) "InitTrig_Camera_Presets" becomes "InitTrig" and "Trig_Camera_Presets_Actions" becomes just "Actions".

Collapse JASS:
scope CameraMan

private function Actions takes nothing returns nothing
    local integer num = 0
    loop 
        exitwhen num == 10
        set num = num + 1
        call BJDebugMsg(I2S(num))
        call SetCameraTargetControllerNoZForPlayer( Player(num-1), udg_Cameramen[num], 0, 0, false )
        call SetCameraFieldForPlayer( Player(num-1), CAMERA_FIELD_ANGLE_OF_ATTACK, -45.00, 0 )
    endloop
endfunction

public function InitTrig takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle(t, 1.0 )
    call TriggerAddAction(t, function Actions )
endfunction

endscope

I see, I was going to start learning all about scopes today but thank you for this. Definitely very helpful. I was just wondering then, what are the advantages to using a scope versus the method I layed out?