HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Wait less than 0.1 seconds

04-08-2007, 05:39 AM#1
Amaroqwlf
How does one wait for very small increments of time? I did a forum search and I could find no answers, but I figured that a solution should've been relatively easy to come by. It seemed like a standard issue to me.

Anyway, I want to make a Blizzard effect spawn every 0.025 seconds, instead of a wall of ice falling down, but was unable to do so. I attempted a loop that checked the time remaining in a timer (as well as PolledWait(), which I didn't expect to work anyway).

In my search I did find an answer as to why what I tried did not work. According to what I read, Timers only move if the Trigger is not being executed (hence, you must still use TriggerSleepAction to allow Timers to countdown in the middle of triggers).

A nice function would be to add a delay of some sort to the spawning of the effect so that I wouldn't have to even try to wait in the middle of my trigger. However, I am completely fine with whatever works, as it is the end result that matters to me.

All I want is just a method to wait less than the minimum time for TriggerSleepAction.
04-08-2007, 05:50 AM#2
Earth-Fury
Use a periodic event on a trigger, or a periodic timer.
04-08-2007, 06:23 AM#3
Amaroqwlf
How do I use that to wait a certain period of time?

I know about the Periodic Event in the GUI, but I don't want to make a separate trigger for this. Also, I know I didn't mention this before, but I'm making my trigger in JASS, so if you have a suggestion, then please include the script I can use to do it.

I suppose I'll get more specific with my request though. I'd like a script (or at least a simple description of how to make the script) that allows me to simulate this effect:

Every [x] seconds do [Actions]

It can be any kind of script and however complicated, but I'd like to stay within the same trigger (I don't know how to use Events in JASS. I only convert from GUI).
04-08-2007, 06:25 AM#4
Earth-Fury
Collapse JASS:
local timer t = CreateTimer()
call TimerStart(t, 0.03, true, function callback_function)
set t = null

callback_function will be called every 0.03 seconds after the timer is started.

look in to handle vars for a way to attatch data to timers.
04-08-2007, 06:26 AM#5
grim001
no don't do that, look to structs instead
04-08-2007, 06:38 AM#6
MaD[Lion]
grim, the world is a bit far from structs atm. U must give them time ;)
Preprocessing is something not all know and use yet. only some
04-08-2007, 07:22 AM#7
Amaroqwlf
Ah, I just studied up on the handle vars you mentioned and I'm left with a question.

How do I specify the number of times to execute the timer?

For instance, the TimerStart function's periodic boolean is set as true. Wouldn't this make the timer continue to execute eternally in a repetitious matter?

One solution I thought of was to use a TriggerSleepAction with a duration relative to the number of times I want the callback_function to execute and then destroy the timer, but I'm not sure if that would work.
04-08-2007, 08:42 AM#8
grim001
You need to stop the timer from within the timer using some condition and PauseTimer/DestroyTimer

And you also need to learn to use structs instead of gamecache
04-08-2007, 09:10 AM#9
Anitarf
To explain in more detail, you should attach an integer to the timer which you would decrement in the callback function. Once that integer reached 0, destroy the timer from the callback function, thus ending the sequence.
04-08-2007, 01:45 PM#10
Amaroqwlf
Thanks, everyone. Things are working well, now, and I've learned quite a bit.

grim001 : I'm fine with learning about preprocessing/structs or whatever, but I'd like a link to visit in order to learn about them. I've heard game caches can only have 255 values and can run slowly, so I'm open to alternatives if it will improve my map.

I should probably go and sleep to rest my mind, but I have a question (unrelated to this thread, but related to my map). I want to interrupt my spell when the caster stops casting. I figured the best solution would be to simply exit my loop if the unit receives an order. However, I haven't been able to figure out the correct method.

What do I do to check if a unit has received an order (and hence is no longer casting) without using globals?
04-08-2007, 01:47 PM#11
Banana
If you base your spell on Channel ability and set it to channeling, that'll do just what you wanted.
04-08-2007, 07:23 PM#12
Captain Griffen
Quote:
Originally Posted by Amaroqwlf
grim001 : I'm fine with learning about preprocessing/structs or whatever, but I'd like a link to visit in order to learn about them.

Vex's JASSHelper, basically. Got a section in vex's section. Also in tools, I think, not sure.

Quote:
I've heard game caches can only have 255 values

You can only save 255 game caches. This only affects SP, not MP, I think. That is game caches files, not bits in each cache.

Quote:
and can run slowly

Around 1/5 of the speed of an array look up, which you get with structs.

However, small scale use of GC is perfectly fine.

Quote:
so I'm open to alternatives if it will improve my map.

Take a look at my TimerAttach function and use it with structs, if you feel confident with them. TimerAttach is a lightweight easy way to attach an integer to a timer, with GC, and fast.
04-09-2007, 05:29 AM#13
Amaroqwlf
Banana: My spell is based on Channel. However, I have it set to run a trigger when a unit casts that spell. At this point, the spell and the effects created by the trigger are no longer linked. I am looking for a way to keep them linked.

Captain Griffen: I looked up information on JASSHelper, and viewed Vexorian's online readme. I enjoyed reading it, so thanks for helping me find it, as well as clearing up some other information for me. However, I wasn't entirely sure on how to implement it (which could mean I didn't entirely understand it). But heck, I didn't fully understand the system using the game cache, anyway, and was only attracted to it because it conveniently provided me with a feature that might be hard to recreate on my own.

Perhaps I will begin to experiment with the two to try and understand them more.