This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
JokerRH's profile picture

Events on startup

Started by JokerRH, 30 March 2013 - 07:05 AM
JokerRH #1
Posted 30 March 2013 - 08:05 AM
After a couple hours of searching I managed to find what I think is a bug.
To show what I mean: This is the skript that goes into the startup file:

os.queueEvent("Test")
print(coroutine.yield())


os.queueEvent("Test")
print(coroutine.yield())

It looks like the computer will always ignore os.queueEvent unless you once force an event using a keypress or similar

JokerRH
Cloudy #2
Posted 30 March 2013 - 08:11 AM
Why would you even want to do that anyway?
JokerRH #3
Posted 30 March 2013 - 08:18 AM
Why would you even want to do that anyway?

Where would be the point if you can't do that?
For now I have to write "press any key to start" at the beginning of my program, but that get's annoying :D/>
Cloudy #4
Posted 30 March 2013 - 08:50 AM
Or you can just not do pullEvent at the beginning of your program at all? Why do you need to queue an event, purely to have it pulled using pullEvent?
JokerRH #5
Posted 30 March 2013 - 09:01 AM
Or you can just not do pullEvent at the beginning of your program at all? Why do you need to queue an event, purely to have it pulled using pullEvent?

no, I have multiple coroutines that pass each others informations using queueEvent.
And I think that is the concept of queueEvent, isn't it?
Cloudy #6
Posted 30 March 2013 - 10:48 AM
Can you just not have them use a shared variable?

One thing you could add, however, is a sleep(0.05) at the front of your program. I will look into it anyway, but I don't see why you'd need to queue an event at startup in any sane use.
JokerRH #7
Posted 30 March 2013 - 11:45 AM
What you mean is like Direwolf does it: sleep for 2 seconds and then check for a change, but in the worst case that means it'll get the change 2 seconds after it was saved to the variable. I could of course make it sleep for 0 seconds, but that is going to slow down every other coroutine and therefor not that efficient.
Using events it'll yield and then get the information instantly… :D/>
But anyway, thanks for looking at it :)/>
Cloudy #8
Posted 30 March 2013 - 11:48 AM
No, what I mean is sleep when starting your program - it should get rid of the problem you're having.
JokerRH #9
Posted 30 March 2013 - 12:00 PM
No, what I mean is sleep when starting your program - it should get rid of the problem you're having.
Yeah, I actually noticed that, too.
But doesn't sleep use queueEvent, too?
-I mean it works, but it's a bit strange :D/>
Lyqyd #10
Posted 30 March 2013 - 12:33 PM
No, how could it? queueEvent queues events immediately, while timers are delayed.