wc3edit.net
https://forum.wc3edit.net/

First Script!
http://forum.wc3edit.net/deprotection-cheating-f64/first-script-t1134.html
Page 1 of 4

Author:  namespoofer [ June 14th, 2007, 3:13 am ]
Post subject:  First Script!

It's my first JASS written trigger.. I used the 'New Trigger' template in JC..
Code:
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:
function InitTrig_NewTrigger
TriggerAddCondition(gg_trg_NewTrigger
TriggerAddAction(gg_trg_NewTrigger


Correct?

Author:  Xantan [ June 14th, 2007, 3:18 am ]
Post subject: 

every time you see a x_NewTrigger_x
or whatever, I'd change it there too.

Author:  namespoofer [ June 14th, 2007, 3:28 am ]
Post subject: 

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 -.-

Author:  Xantan [ June 14th, 2007, 3:32 am ]
Post subject: 

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.

Author:  namespoofer [ June 14th, 2007, 3:37 am ]
Post subject: 

What do I type to call a function? -.-
Just
call myfunc?

Now tell me what's wrong with this?

Code:
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

Author:  Totti_8 [ June 14th, 2007, 6:04 am ]
Post subject: 

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>)"

Author:  namespoofer [ June 14th, 2007, 7:46 am ]
Post subject: 

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:
call TriggerAddCondition(gg_trg_spell2, (Condition (function spell2_cond))


And here is the whole trigger!
Code:
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

Author:  Totti_8 [ June 14th, 2007, 11:25 am ]
Post subject: 

Code:
(Condition (function spell2_cond))


you should delete the Space " " after "Condition" ;)

Author:  namespoofer [ June 14th, 2007, 5:14 pm ]
Post subject: 

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? :?

Author:  Dekar [ June 14th, 2007, 5:37 pm ]
Post subject: 

The WE(U)-syntax-check is sometimes wrong... Just don't worry about it,
as long as jasscraft reports no errors. ;)

Page 1 of 4 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/