| 05-15-2007, 05:19 AM | #1 |
Dunno of Vex recieved my PM, but I'd like to state a suggestion which can be commented upon on by anyone here. Since we use timers often, we use this kind of method: JASS:function SomeOtherFunc takes nothing returns nothing local timer t= GetExpiredTimer() //blah blah blah... if Something != true/false/Something then //This if structure checks if something is equal to something. So if that is true we release the timer. call ReleaseTimer(t) else <blah blah> ... endfunction function SomeFunc takes nothing returns nothing local timer t= NewTimer()//For efficient timer usage. call TimerStart(t, 0.03, true, function SomeOtherFunc) endfunction This is 'usually' how we work with timers. But, wouldn't it be easier if we removed that if structure and made a super timer? JASS:
call SuperTimerStart(t, 0.03, exitwhen Something != true/false/something, function SomeOtherFunc)//This would be awesome, it will automatically release the timer when the boolexpr is achieved.
What do you people think? I asked Vex last night but he didn't reply ![]() |
| 05-15-2007, 09:22 AM | #2 | |
Quote:
|
| 05-15-2007, 09:25 AM | #3 |
Did you even try to understand how it works before you commented? It works to reduce some lines of code. :/ Almost everything is "nothing special + i dont know who will use it" for you. [rant] No offense, but if you don't like something don't freaking say it out loud like "That's not special, I don't think there will be any use for it". Well have you even read what it's supposed to do? Srsly, GTFO if you think it's a stupid piece of shit puh leez. [/rant] :D |
| 05-15-2007, 10:03 AM | #4 |
What if you want it more complex than that? Normally on releasing the timer you do other stuff. Really, it won't be much use. |
| 05-15-2007, 11:06 AM | #5 |
well u always have options, adding something doesnt mean the other thing is removed :P and to tc: you need sex man |
| 05-15-2007, 11:08 AM | #6 |
But for simple things, you can reduce some lines of codes.. Might as well call them Simple Timers then. xD For example, fading units out.. JASS:function FadeUnit_Callback takes nothing returns nothing local timer t = GetExpiredTimer() local unit u = GetAttachedUnit(t, "u") local real alpha = GetAttachedReal(t, "alpha") call SetUnitVertexColor(u, 255, 255, 255, alpha) set alpha = alpha + 1 endfunction function FadeUnit takes nothing returns nothing local unit u = GetTriggerUnit() local real alpha = 0 local timer t = NewSimpleTimer() call AttachObject(t, "u", u) call AttachReal(t, "alpha", alpha) call SimpleTimerStart(t, 0.50, exitwhen alpha == 100.0, function FadeUnit_Callback) set u = null endfunction Really, this is just a simplification of timers. Take for example the 1-line-ifs Vex is working on, what if you need it to be more complex Griff? Then use the normal if structure. Same goes here, if you need more complexity, use the usual method. |
| 05-15-2007, 01:12 PM | #7 | |
Quote:
--- The problem is that I actually deprecated timers a long ago... And pipedream is better at having ideas, in his idea there is something like a delay call. something like: JASS:local integer i loop exitwhen i>=9 delay 4.5 endloop But I seriously thought that was over kill. Your idea itself could easily be made in manual way without extending syntax, just make a timer wraper that takes a function interface that returns boolean for condition to stop the timer. In fact, an interface might be better since it would allow data. Err. if you used TimeLib this wouldn't be even needed. -- I don't really get how do you expect that alpha example to work. You could always just use false in the first TimerStart call and then use recursion, seriously. It would actually be easier to code and understand than that... |
| 05-15-2007, 01:16 PM | #8 |
Aw gee, guess I suck then :( Anyway, what IS Pipedream's idea? It is very very interesting.. Oh puhleeze tell uz! |
| 05-15-2007, 01:19 PM | #9 |
your function would translate into this: JASS:function FadeUnit takes nothing returns nothing local unit u = GetTriggerUnit() local integer alpha = 0 call AttachObject(t, "u", u) call AttachReal(t, "alpha", alpha) loop exitwhen alpha>255 //men, were you using 100 or 255 based vertex colors? call SetUnitVertexColor(u,255,255,255,alpha) delay 0.5 set alpha=alpha+1 endloop set u = null endfunction |
| 05-15-2007, 01:21 PM | #10 |
Where did this 't' come from? I fucking like the idea, it's like a TSA loop without TSA! Please add it to NewGen pack, oh please oh please, oh please! |
| 05-15-2007, 01:27 PM | #11 |
The idea is fairly simple, but the application lacks in that it wouldn't know what to transfer, and would thus need to transfer everything - resulting in a less efficient process than doing it manually, unless you could make it smart somehow. |
| 05-15-2007, 01:30 PM | #12 |
What do you mean by this transferring ? |
| 05-15-2007, 01:33 PM | #13 |
In reference to PipeDream's idea (one I had and dismissed a while back), which would use a timer and attaching the locals to it to have accurate 'waits' (same syntax, but actually using timers). I suppose it could be made to use transfer only the locals used later on. |
| 05-15-2007, 02:05 PM | #14 | |
Quote:
|
| 05-15-2007, 02:45 PM | #15 |
WerD. |
