| 01-14-2009, 08:18 PM | #1 |
To avoid dynamic triggers, I've created udg_DynamicTimer[] and udg_DynamicTrigger[] When udg_DynamicTimer[1] expires it invokes a trigger that was created during initialisation I want that trigger to call ConditionalTriggerExecute(udg_DynamicTrigger[1]) My problem is that I don't know how to set up the trigger at runtime so that the Actions has that line of code in it. I tried this: JASS:function Trig_InitDynamicTriggers_Conditions takes nothing returns boolean local integer iDynamic = 0 local trigger t = null loop set t = CreateTrigger() call TriggerAddAction(t, "call ConditionalTriggerExecute(udg_DynamicTrigger[" + I2S(iDynamic) + "])") exitwhen iDynamic == 8190 set iDynamic = iDynamic + 1 endloop set t = null return false endfunction Does anyone know how I can achieve my goal? |
| 01-14-2009, 11:46 PM | #2 |
You're going the wrong way about this. TrriggerAddAction works like this: JASS:call TriggerAddAction(udg_DynamicTrigger[iDynamic], function Action) JASS:function Action... call ConditionalTriggerExecute(udg_DynamicTrigger[1]) endfunction function Action2 call Whatever("awesome") endfunction function Init call TimerStart(timer, time, false, function Action) //made up variables of course. call TriggerAddAction(t, function Action2) endfunction But I don't really understand the point of what you're trying. There shouldn't be any situations where you are forced to dynamic triggers in the first place. |
| 01-15-2009, 07:31 AM | #3 |
I have 8190 timers which each need to call whatever trigger is stored in a trigger array. Timer[1] calls Trigger[1] Timer[2] calls Trigger[2] Timer[3] calls Trigger[3] and so on. The contents of Trigger[] could change frequently during play. I could type each trigger in manually but I don't fancy doing 8190 triggers by hand so wanted to do it automatically. No idea what the correct way is to achieve this? |
| 01-15-2009, 08:55 AM | #4 |
I thing you should use TimerUtils(board search!) and attach the array indexes to your timers. That would be something like this: (have not tested it, sorry) JASS:function timercallback takes nothing returns nothing local timer t = GetExpiredTimer() local integer idx = GetTimerData(t) call ConditionalTriggerExecute(udg_DynamicTrigger[idx]) call ReleaseTimer(t)//never ever null timers! endfunction //start a timer function starttimer takes integer i returns nothing local timer t = NewTimer() call SetTimerData(t, i) call TimerStart(t, 10000, false, function timercallback) endfunction |
| 01-15-2009, 09:35 AM | #5 |
C2H3NaO2's way is going to be the best probably. But, you shouldn't be having to do that in the first place. If you're using triggers like that, you're doing it wrong. |
| 01-18-2009, 10:28 AM | #6 |
Thanks C2H3NaO2, that gave me what I needed to make it work. I have created a system of global arrays and some functions that allow me to have a trigger run with parameters determined in another trigger on a timer end or an endcast, and to be able to do this for any given instance of the cast. I can now have upto 8190 triggers registered with various parameters and events at any given moment, without using dynamic triggers. Basically this allows me to have fully MUI spells without using a WE patch and without using a gamecache :) |
| 01-18-2009, 02:02 PM | #7 |
I still don't quite understand what you can do with this that you couldn't do with regular timer use... |
| 01-19-2009, 07:28 AM | #8 |
Well, nothing. Except I'm reusing timers and indeed any other variable type. Not sure how I would get full-MUI otherwise (without using gamecache or WE hacks). |
| 01-19-2009, 02:49 PM | #9 |
You're still very vague. I'm asking for a specific usage example. |
| 01-19-2009, 08:15 PM | #10 |
Event: Unit casts Temporary Charm local integer i = GetDynamicSlot() set udg_DynamicTrigger[i] = gg_trg_UnCharm set udg_DynamicUnit[i] = GetSpellTargetUnit() set udg_DynamicInteger[i] = GetPlayerId(udg_DynamicUnit[i]) call StartTimer(udg_DynamicTimer[i], 30.00, false, null) gg_trg_Uncharm: local integer i = udg_DynamicSlot //set by calling trigger call SetUnitOwner(udg_DynamicUnit[i], udg_Player[udg_DynamicInteger[i]], true) call ReleaseDynamicSlot(i) |
| 01-19-2009, 08:40 PM | #11 |
Ah, now I see. Well, TimerUtils lets you do pretty much the same thing in a far far far far more elegant manner. |
