77 posts
Location
United Kingdom, Earth
Posted 13 August 2013 - 07:03 AM
How would I use so something like co-routines or parallels.waitForAny() with a mouse click event
event, button, x, y = os.pullEvent("mouse_click")
if y == 18 then
--do stuff
end
Since os.pullevent() calls coroutine.yeild(), how would I have 2 functions, one of them using the mouse click event, run at the same time?
EDIT: The other function would be read() [For a login screen with shutdown and restart buttons]
Making an OS called CraftedOS which I would like to use this help for
758 posts
Location
Budapest, Hungary
Posted 13 August 2013 - 07:10 AM
Again? I understood you have one function which processes a mouse_click event, but what would the other do?
101 posts
Location
Norway
Posted 13 August 2013 - 08:58 AM
77 posts
Location
United Kingdom, Earth
Posted 13 August 2013 - 12:21 PM
Thanks for that, will probably be helpful but I forgot to mention that the other function will be running read() so I don't think that it will help
[EDIT] would be helpful for some buttons with a clock that auto updates
997 posts
Location
Wellington, New Zealand
Posted 14 August 2013 - 04:04 AM
Put the mouse click code in a function, and the read() code in a function, and use parallel.waitForAny(mouseClickFunctionName, readFunctionName).
It will run both of them at the same time until either returns.
77 posts
Location
United Kingdom, Earth
Posted 15 August 2013 - 08:27 AM
Put the mouse click code in a function, and the read() code in a function, and use parallel.waitForAny(mouseClickFunctionName, readFunctionName).
It will run both of them at the same time until either returns.
Thanks, I think I have tried this but it didn't work, I'll just look over my code
199 posts
Location
Switzerland
Posted 15 August 2013 - 08:34 AM
maybe post your code then we can give you better help :)/>
77 posts
Location
United Kingdom, Earth
Posted 17 August 2013 - 10:36 AM
maybe post your code then we can give you better help :)/>/>
Hopefully I will soon, it's just I reworte the code to say to the user "Use ctrl+S to shutdown"
Hopefully shouldn't take too long to write it back in