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

Rednet Chat

Started by Zenon, 17 May 2015 - 05:43 PM
Zenon #1
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!
flaghacker #2
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.
Mackan90096 #3
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
DannySMc #4
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__1

Just 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.
Zenon #5
Posted 18 May 2015 - 10:50 PM
Thanks All!