| 07-27-2009, 09:36 PM | #1 |
I've been told countless times that TriggerSleepAction() is very evil and buggy, but when I ask why, I don't get an answer. Since only Hive members have told me that, and I feel they might be wrong, I'm asking you; What's the big deal? |
| 07-27-2009, 09:41 PM | #2 |
Innacurate, has severe limitations, doesn't work at all in a few situations. Not necessarily entirely useless though, perhaps. |
| 07-27-2009, 09:43 PM | #3 |
Well, like dynamic triggers, it used to be associated with some obscure bugs, it is likely possible to use TriggersleepAction without the risk of running into those bugs, we don't really know (did I mention they are very obscure bugs?) and since using timers is better (mainly, they are more accurate) than TSA anyway noone bothered to test that. |
| 07-27-2009, 10:00 PM | #4 |
I know that using Timers is better, especially with TimerUtils, but I can't seem to find a way to end my spell I'm working on without using TSA. If I remember correctly from browsing wc3c's data base (old threads etc.) I saw Vexorian mention that he didn't see the problem in using it if it was long. Mine is about 10 seconds, is that enough? By the way that was a while ago, and I can't find it again. |
| 07-27-2009, 10:33 PM | #5 |
10 second timer? |
| 07-27-2009, 10:41 PM | #6 | |
Sleep doesn't wait while game is paused (eg lagscreen) and is very inaccurate. I also read because of that inaccuracy it can cause desnyc, when having different duration on each computer So i'd say when displaying text or something like that you can safely use it. But in (a loop of) a spell its a no-go Quote:
Put all the variables you need after the wait in a struct, attach that struct to a timer and make that timer run a function. in this function you get the struct attached to the expired timer |
| 07-27-2009, 11:19 PM | #7 |
Damn... those structs must own huh. Everywhere I go people tell me to use em, but I can't xD My level is basically Jass, but with scope/library/private, free global decleration and array resizing. Got any ideas at my level? |
| 07-28-2009, 12:20 AM | #8 | |
Quote:
Structs are nothing to be afraid of. They're basically just parallel arrays, whenever you create a struct you essentially reserve an index in those arrays so you know nothing else will overwrite the data you store there, and when you destroy a struct you basically make the index available for use again, so your map doesn't run out of space in those arrays. |
| 07-28-2009, 12:24 AM | #9 |
structs are as easy to use as usefull just a small example: Sleep: JASS:function Actions takes nothing returns nothing call TriggerSleepAction(10) call KillUnit(GetTriggerUnit()) endfunction Struct + Timer: JASS:struct SpellData unit caster endstruct function SecondActions takes nothing returns nothing local timer t = GetExpiredTimer() local SpellData mystruct = SpellData( GetTimerData(t) ) //getting the struct attached to the timer which run this function call KillUnit( mystruct.caster ) //using the saved variables call mystruct.destroy() //destroying the struct call ReleaseTimer(t) set t = null endfunction function Actions takes nothing returns nothing local timer t = NewTimer() local SpellData mystruct = SpellData.create() //creating a struct set mystruct.caster = GetTriggerUnit() //saving the variables we need later call SetTimerData(t, mystruct) //attaching the struct to the timer call TimerStart(t, 10, false, function SecondActions ) //making the timer run the second function set t = null endfunction just read some tutorials |
| 07-28-2009, 12:25 AM | #10 |
You can try TimerData (TimerUtils) to pass whatever you need to pass. |
| 07-28-2009, 03:55 AM | #11 |
And if you're THAT afraid of structs, you could just use timer indexing utilities, which is basically TU Red before Vex copied it and added a struct attachment function to it, thus, technically speaking, making its direct use even more efficient than TU Red + struct allocation. Except that, at that point, you're so close to using structs (as in, the difference between this and using structs is that you're using the index of the allocated timer instead of an independant index) that, well, you might as well use structs for better organization and smoother flexibility. |
| 07-28-2009, 11:49 AM | #12 |
I never said I was afraid of structs, just that I don't know squat about them. I've tried reading tutorials, but I've got alot of questions regarding them, and I don't feel like posting a thread every time I've got some small issue. And I'd need help in some practice spell which I'm sure you'd give me, but I don't feel very comfortable spamming posts in your Scripts section. Flame_Phoenix stated that he'll make a tutorial about them on hive, and when it's released I'll do just like I did with his vJass tutorial: Spam questions. By the way Hans_Maulwurf, that simple post helped me alot, thanks. Damnit my issue still isn't solved... I gotta think this through, I might be able to pull it off but I'd need two more 40800 sized arrays, which add up to 10 totally. |
| 07-28-2009, 02:16 PM | #13 | |
All things considered, I'm glad Vex hating my implementation of Timer Indexing Utilities motivated him to create the red flavor. It was worth that thing being graveyarded for him to come out with that and keep TimerUtils the standard. You can use a happy wrapper struct to get it to work identically to TIU if you'd like, Tup. Quote:
|
| 07-28-2009, 11:35 PM | #14 |
sleep is just inaccurate... even in long... cus maybe u want it to be accurate long... i use sleep tho when i dont care of accuracy. It isnt evil bad and it works even while paused. So its nice if u wanna make some stuffs happening during a paused game. which could be cool if u wanna freeze particles ^^ |
| 07-29-2009, 12:23 PM | #15 | |
Quote:
Are you certain? Anitarf helped me to research this some time ago, but the only thing I found out was that Waits don't consider the Waiting-For-Players dialog. Which makes waits rather evil for most things. I personally only use wait as a thread yield to avoid op.limit (Do lots of things, Wait(0), Do lots of things). Eyecandy can of course also be added with waits (if it is something like create 3 effects over 3 seconds). |
