Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function turtleFunc()
- while true do
- turtle.turnLeft()
- end
- end
- local turtleCoroutine = coroutine.create(turtleFunc)
- coroutine.resume(turtleCoroutine) --# The function needs no parameters for its first resume.
- local function rednetFunc()
- while true do
- local sender, message = rednet.receive(1)
- print(message)
- --# Maybe do something with the message here.
- end
- end
- local rednetCoroutine = coroutine.create(rednetFunc)
- coroutine.resume(rednetCoroutine)
- while true do
- local myEvent = { os.pullEvent() }
- if myEvent[1] == "turtle_response" then
- coroutine.resume( turtleCoroutine, unpack( myEvent ) ) --# See http://www.lua.org/pil/5.1.html regarding unpack
- elseif myEvent[1] == "rednet_message" or myEvent[1] == "timer" then
- coroutine.resume( rednetCoroutine, unpack( myEvent ) )
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement