Page 1 of 4
First Script!
Posted: June 14th, 2007, 3:13 am
by namespoofer
It's my first JASS written trigger.. I used the 'New Trigger' template in JC..
Code: Select all
function Trig_NewTrigger_Conditions takes nothing returns boolean
return ( GetPlayerName(GetTriggerPlayer()) == "WorldEdit" )
endfunction
function Trig_NewTrigger_Actions takes nothing returns nothing
local integer i
set i = 0
loop
exitwhen i==3
call DisplayTextToForce( GetPlayersAll(), "test x3")
set i = i+1
endloop
endfunction
//==== Init Trigger NewTrigger ====
function InitTrig_NewTrigger takes nothing returns nothing
set gg_trg_NewTrigger = CreateTrigger()
//call TriggerRegister__(gg_trg_NewTrigger, )
call TriggerRegisterPlayerChatEvent (gg_trg_NewTrigger, Player(0), "-test", true)
call TriggerAddCondition(gg_trg_NewTrigger, Condition(function Trig_NewTrigger_Conditions))
call TriggerAddAction(gg_trg_NewTrigger, function Trig_NewTrigger_Actions)
endfunction
I can't figure out how to change the name of my trigger.. I only need to change it at
Code: Select all
function InitTrig_NewTrigger
TriggerAddCondition(gg_trg_NewTrigger
TriggerAddAction(gg_trg_NewTrigger
Correct?
Posted: June 14th, 2007, 3:18 am
by Xantan
every time you see a x_NewTrigger_x
or whatever, I'd change it there too.
Posted: June 14th, 2007, 3:28 am
by namespoofer
But functions can have any name, and can be called under the InitTrig right? So if I were to make a new trigger, and just call the cond/act function, it would work.. right? Or are function names specified to a certin trigger and that trigger only.. ahhh -.-
Posted: June 14th, 2007, 3:32 am
by Xantan
functions sure, but you'll need to make sure your event etc is hooked up to that - and the condition check..
also you have a few other places that NewTrigger shows up that are important to change... not all need to - but a lot do.
Posted: June 14th, 2007, 3:37 am
by namespoofer
What do I type to call a function? -.-
Just
call myfunc?
Now tell me what's wrong with this?
Code: Select all
function func1 takes nothing returns nothing
call DisplayTextToForce(GetPlayersAll(), "You pressed ESC!")
endfunction
//==== Init Trigger NewTrigger ====
function InitTrig_test3 takes nothing returns nothing
set gg_trg_test3 = CreateTrigger()
//call TriggerRegister__(gg_trg_NewTrigger, )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_test3, Player(0))
call func1
endfunction
Posted: June 14th, 2007, 6:04 am
by Totti_8
you can't write "call func1"
the InitTrig Action runs at Initalization of the map and so it wouldn't work if you only write this. There should be "call TriggerAddAction(<yourTrigger>, <yourFunction>)"
Posted: June 14th, 2007, 7:46 am
by namespoofer
What's the script for a weather effect variable? (I mean a local too)
Edit: I still would like to know the local name above, but for now I just declared it in globals.. -.-
I'm having trouble with this trigger, the world editor is telling me that this line is an 'invalid argument type (unitevent)'
Code: Select all
call TriggerAddCondition(gg_trg_spell2, (Condition (function spell2_cond))
And here is the whole trigger!
Code: Select all
function spell2_cond takes nothing returns boolean
return GetSpellAbilityId() == 'A002'
endfunction
function spell2_act takes nothing returns nothing
call AddWeatherEffect( gg_rct_blizzard_spell3, 'SNbs')
set udg_weather = GetLastCreatedWeatherEffect()
call TriggerSleepAction( 6.00)
call RemoveWeatherEffectBJ(udg_weather)
set udg_weather = null
endfunction
//==== Init Trigger NewTrigger ====
function InitTrig_spell2 takes nothing returns nothing
set gg_trg_spell2 = CreateTrigger()
//call TriggerRegister__(gg_trg_NewTrigger, )
call TriggerRegisterAnyUnitEventBJ( gg_trg_spell2, EVENT_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_spell2, (Condition (function spell2_cond))
call TriggerAddAction(gg_trg_spell2, function spell2_act)
endfunction
Spoofzz
Posted: June 14th, 2007, 11:25 am
by Totti_8
Code: Select all
(Condition (function spell2_cond))
you should delete the Space " " after "Condition"
Posted: June 14th, 2007, 5:14 pm
by namespoofer
Ooo again you help me! Thank you Totti!
Edit: Still doesn't work! -.- I tried deleteing other spaces.. but I thought spaces didn't matter?
Posted: June 14th, 2007, 5:37 pm
by Dekar
The WE(U)-syntax-check is sometimes wrong... Just don't worry about it,
as long as jasscraft reports no errors.