Guest User

Untitled

a guest
Nov 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.34 KB | None | 0 0
  1. recieve = function()
  2.     local x = select(2,coroutine.resume(producer))
  3.     return x
  4. end
  5.    
  6. producer = coroutine.create(function()
  7.     local x
  8.     while true do
  9.         while true do
  10.             x = io.read()
  11.             if not tonumber(x) then
  12.                 break
  13.             end
  14.         end
  15.         coroutine.yield(x)
  16.     end
  17. end)
  18.  
  19. print("Do not enter a number!")
  20. while true do print(recieve()) end
Add Comment
Please, Sign In to add comment