52 posts
Posted 17 May 2015 - 07:43 PM
Hi All, I Was Just Wondering How I Could Make A Chat Function That Would ALWAYS Receive Msgs, But Still Be Able To Do Other Things. I Want To Be Able To Message A Computer, But If Im Msging, I Dont Want To Miss A Msg. Would This Be Possible? And, If So, Would It Be Better To Send The Msgs To A Server, Then Have That Send It To The Specified Computer?
Thanks In Advance!
656 posts
Posted 17 May 2015 - 09:43 PM
Yup that's entirely possible. No, it would not help to centralize your events. Take a look at
this tutorial.
695 posts
Location
In my basement.
Posted 18 May 2015 - 10:46 AM
You can have the computer catch events using os.pullEvent() while still being able to do other thibgs. This is achieved using the paralell API. The docs for it can be found on the CC wiki.
Edited on 18 May 2015 - 08:46 AM
1847 posts
Location
/home/dannysmc95
Posted 18 May 2015 - 01:44 PM
You can have the computer catch events using os.pullEvent() while still being able to do other thibgs. This is achieved using the paralell API. The docs for it can be found on the CC wiki.
Not really? you could easily do the following:
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
-- Run timer code
elseif args[1] == "mouse_click" then
-- Run mouse_click code, I use it in all my programs, do not use the parallel API at all.
end
end
I made this tutorial for making touch screen events, but it can be used for waiting for multiple events to fire.
http://www.computercraft.info/forums2/index.php?/topic/16925-how-to-create-a-touch-screen-on-a-terminal/page__fromsearch__1Just use an if statement, and args[1] will be the event and args[2], args[3] and up to args[5] will be any returns as it is stored in a table.
52 posts
Posted 18 May 2015 - 10:50 PM
Thanks All!