PDA

View Full Version : LUA - TIME_Sleep & TriggerEvent



DCypher
July 8th, 2004, 11:38 AM
I'm seeing weird behavior with TIME_Sleep & triggerEvent...

I'm basically parsing off 3 digits and triggering an event for each, but i want a 300 ms delay between events... simple enough.
My script is along the lines of:

for i = 1,3 do
TriggerEvent("foo", 18);
TIME_Sleep(300);
end

When i run this, i see nothing for 1 second, then i see 3 triggered events back to back (no delay). I logged the output and sure enough, here's what's happening... The triggerEvents don't actually fire until AFTER the script finishes... it queues them up and sends them with no delay! Ugh! Is there a fix for this? Has anyone else seen this behavior?

I'm running Girder 3.2 with the latest WinLuaEx plugin.

TIA!

Jeff

Promixis
July 8th, 2004, 11:51 AM
TriggerEvents are placed in a que while a lua script is executing.

To do this, have the script call a multigroup, 1 command the command you want then one command using the wait command.

DCypher
July 8th, 2004, 11:51 AM
I should have searched the forums a bit more before posting... seems i'm not the only one that has run into this before:

http://www.girder.nl/phpBB2/viewtopic.php?t=4658&highlight=timesleep+triggerevent

I'll try that and see if it works for me!

Promixis
July 8th, 2004, 11:54 AM
Ok, let me know!

DCypher
July 8th, 2004, 11:56 AM
TriggerEvents are placed in a que while a lua script is executing.

To do this, have the script call a multigroup, 1 command the command you want then one command using the wait command.

When the triggered events finally do get called, are the calls serialized? Does the 2nd triggerEvent wait until the first handler finishes?

I did try this, but it didn't seem to work for me, but something else may have been wrong.

Thanks,
jeff

Promixis
July 8th, 2004, 11:57 AM
Jeff,

The events should be serialized.

DCypher
July 9th, 2004, 04:09 AM
Making a trigger for a delay worked great! The events get serialized and i get the appropriate delay(s) between commands.

Jeff

Promixis
July 9th, 2004, 05:59 AM
Great!

skavan
March 29th, 2005, 07:19 AM
aaarggh - the link above doesn't connect anymore!

I am having exactly the same problem and need some genius to prod me out of my dopiness.

I need:
TriggerEvent("A",18,"P1")
WAIT 2 SECS
TriggerEvent("B",18,"P1")

etc...

I can't say I understand Mike C's explanation!

Mark F
March 29th, 2005, 10:36 AM
I believe the link should now be:

http://www.promixis.com/phpBB2/viewtopic.php?t=4658