| 05-04-2007, 01:23 PM | #1 |
i'm trying to figure out a way to do a timer compare. i have a timer with an array size of 10 and i am going to make a camera pan per each individual timer array expiring. i really dont want to have 10 triggers that watch for each timer. is it possible to use conditions to see which trigger is the trigger that expires. i was thinking of doing this: "for each integer a from 1 to 10".. then do an if then else with something like "if VarTimer(integer a) = Expiring timer.. then do" but i can't seem to find something like this. the only thing i can find that references the "expiring timer" is if i did a "Real" comparison .. but i'm not looking for a real value.. i just want a timer comparison.. if timer is equal to timer. is there no way to do this? |
| 05-04-2007, 01:27 PM | #2 |
This is one of those reasons not to use GUI. |
| 05-04-2007, 01:32 PM | #3 |
In JASS, you can get the exipred timer with the function GetExpiredTimer(). There is probobly an equivilent of this in GUI. (unless it only works in a TimerStart callback. in which case, learn JASS) |
| 05-04-2007, 01:55 PM | #4 |
couldn't i just throw in a custom script? this way i dont have to make the whole thing jass. |
| 05-04-2007, 02:06 PM | #5 |
You can't do it in GUI. In JASS, attach an integer(unique of course) to each timer. That way you can tell timers apart by reading the attached integer and checking whether it is integer X. |
| 05-04-2007, 02:15 PM | #6 |
You could do it with a custom script as well. A timer comparison would look something like this: if GetExpiredTimer() == udg_yourTimerArray[GetForLoopIndexA()] then and endif, you would put this at the start and at the end of your loop actions. But it's really simpler to use JASS and atachable vars. |
| 05-04-2007, 02:17 PM | #7 |
Oh that would work too XD You should get the hang with JASS, you can compare alot of stuff you can't in GUI and gives you a whole lot more.. |
| 05-04-2007, 02:27 PM | #8 | |
Quote:
i dont know what you mean by attaching an integer. how do you attach such a variable to another? to Vexorian, Anitarf, and Earth-Fury: although i'm not really familiar with jass I did try a convert trig to script and modified an existing condition check somewhat and came up with this and it let me save. whoo: JASS:function Trig_Pancam_Func001Func001C takes nothing returns boolean if ( not ( GetExpiredTimer() == udg_PanCamTimer[GetForLoopIndexA()] ) ) then return false endif return true endfunction function Trig_Pancam_Actions takes nothing returns nothing set bj_forLoopAIndex = 1 set bj_forLoopAIndexEnd = 10 loop exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd if ( Trig_Pancam_Func001Func001C() ) then call PanCameraToTimedLocForPlayer( GetOwningPlayer(udg_UnitVar[GetForLoopIndexA()]), udg_centerpoint, 1.50 ) else call DoNothing( ) endif set bj_forLoopAIndex = bj_forLoopAIndex + 1 endloop endfunction //=========================================================================== function InitTrig_Pancam takes nothing returns nothing set gg_trg_Pancam = CreateTrigger( ) call TriggerAddAction( gg_trg_Pancam, function Trig_Pancam_Actions ) endfunction btw, this has no event cuz i'm using this trigger to add an event: |
| 05-04-2007, 02:44 PM | #9 |
Do not use the JASS:call DoNothing() JASS:
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
if ( Trig_Pancam_Func001Func001C() ) then
call PanCameraToTimedLocForPlayer( GetOwningPlayer(udg_UnitVar[GetForLoopIndexA()]), udg_centerpoint, 1.50 )
endif
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
If you have no actions for else then remove the else from the if-then-else structure. So it is actually just a if-then structure. |
| 05-04-2007, 03:13 PM | #10 | |
Quote:
okay thx. wouldn't have known that. what about the alternative way you mentioned with attaching an integer? how do you do this? is that like a custom value attached to a unit? can it be done in gui? |
| 05-04-2007, 03:28 PM | #11 |
The alternative way is.. slower. It uses gamecache. As for attachable vars, they are attached using handle vars, which are functions that can 'attach' a variable to another variable. It does that by using gamecache and stores it. If you want to be able to get that attached variable you call the handle vars functions and it returns that variable. It was made to be able to use locals in more than one function. JASS:function MyOtherFunction takes nothing returns nothing local timer t = GetExpiredTimer() local unit u = GetAttachedUnit(t, "u")//Calls a function to get the unit 'called' "u" which is attached to the timer t) endfunction function MyFunction takes nothing returns nothing local unit u = GetTriggerUnit() local timer t = CreateTimer() call AttachObject(t, "u", u)//Calls a function which attaches the variable u to the variable t with the 'name' of "u". call TimerStart(t, 0.01, false, function MyOtherFunction) set u= null endfunction Just a demonstration, but Anitarf's suggestion is a whole lot easier and faster.. |
| 05-04-2007, 03:41 PM | #12 |
You need to get a feel for JASS before doing things like this. I would suggest taking a look at the various tutorials around the site for JASS. |
| 05-04-2007, 03:54 PM | #13 |
That means "take a look at me and darkwulv's tutorials" |
| 05-05-2007, 11:29 AM | #14 |
Actualy, no, I would say that means "look at Vexorian's Introduction to JASS". |
