HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Creating Triggers on the fly?

08-16-2005, 09:59 AM#1
volatile
I'm curious for perhaps a mini-tutorial, explaining how to create triggers on the fly and WHY you would do such a thing? Mainly the why would be preferable. I never really understood the whole creating triggers thing even in the GUI. Could some people explain it please?
08-17-2005, 09:33 PM#2
shadow1500
uhh cant u just make a trigger in worldedit then convert to custom text?
creating triggers on the fly is useful in certain situations, for example u can check my MakeItemUndroppable and MakeItemUnmovable functions in the JASS section of wc3sear.ch.
08-18-2005, 03:38 PM#3
volatile
Ok, but how does this explain what creating triggers on the fly are/do?
Yes, you can create custom triggers using the trigger editor, however my question is NOT about creating triggers using the editor, it is about creating triggers INSIDE (hence on the fly) other triggers, sort of "virtual triggers."

Is the reason you create triggers on the fly to make something keep happening? For instance you mentioned your "make item undroppable" JASS script, do you use triggers on the fly to create a trigger that is ongoing? Some explanation would be helpful... Not directed just at you, but to anyone viewing this thread.
08-18-2005, 04:08 PM#4
shadow1500
i dont think u understand, when u make a trigger using the trigger editor, they are generated during map init,if u have a trigger called TriggerX then convert to custom text u will see that it has TriggerX_Actions function and a Init_TriggerX function which basically creates the trigger on the fly... at map init.
and my script works by making a trigger that runs every time that unit drops an item, then creates a timer to give the item back.
this is the portion that creates the trigger
Quote:
local trigger x = CreateTrigger()
call TriggerRegisterUnitEvent( x,whichUnit,EVENT_UNIT_DROP_ITEM)
call TriggerAddAction( x, function MakeItemUndroppable2_Actions )
thats all, now each time whichUnit drops an item the function MakeItemUndroppable2_Actions will run.
08-19-2005, 07:55 PM#5
Vexorian
Why create triggers in the fly?

- To detect events
- To detect events and conditions.
- so you can execute them with TriggerExecute()

Even World editor configures the script so it creates the triggers during map initialization, btw.
08-22-2005, 06:39 PM#6
volatile
Ok, so why not just create another trigger in the GUI and just use "runtriggercheckcondition" or whatever the JASS function is for it? Are you just creating the trigger on the fly so you can work within one "trigger" or does it have any other purpose? If WC3 generates the trigger during map init, then it's the same as having another trigger and just running the other trigger? example of what I mean:

trigger #1 = Spell
trigger #2 = Spell Additional Trigger

From spell #1 you say "runtrigcheckingconditions(spell additional trigger)

would be the same as saying in the trigger "Spell"
{Spell_Additional_Trigger_Actions
--Actions here--
Create trigger on the fly
run trigger} ??

So you can stay within the same trigger and not have to create another "separate" trigger? I hope I explained my point well enough, let me know if I'm being too vague, or havn't explained well enough.
08-27-2005, 11:17 PM#7
Vexorian
Because it would be retarded.

Apparentally you don't get it, Creating a trigger on the fly means Multi instancibility.