Advertisement
Keridos

Untitled

Mar 18th, 2013
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. function getVersion()
  2.     return 0.1
  3. end
  4.  
  5. function sendData(side,data)
  6.     local stringint
  7.     rs.setBundledOutput(side,512)
  8.     os.sleep(1)
  9.     for i=1,string.len(data) do
  10.         stringint = string.byte(string.sub(data,i))
  11.         rs.setBundledOutput(side,colors.combine(768,stringint))
  12.         os.sleep(0.25)
  13.         rs.setBundledOutput(side,colors.combine(512,stringint))
  14.         os.sleep(0.25)
  15.     end
  16.     os.sleep(0.5)
  17.     rs.setBundledOutput(side,0)
  18.     return true
  19. end
  20.  
  21. function receiveData(side)
  22.     local stringdata = ""
  23.     while colors.test(rs.getBundledInput(side),512) do
  24.         local event = os.pullEvent("redstone")
  25.         if colors.test(rs.getBundledInput(side),256) then
  26.             stringdata = stringdata..string.char(rs.getBundledInput(side)-768)
  27.         end
  28.         os.sleep(0.1)
  29.     end
  30.     print("success")
  31.     print(stringdata)
  32.     return stringdata
  33. end
  34.  
  35. waitfordata = (function (side)
  36.     print("test123")
  37.     while true do
  38.         local event = os.pullEvent()
  39.         if (event == "redstone")and(colors.test(rs.getBundledInput(side),512)) then
  40.             os.queueEvent("RSData",receiveData(side))
  41.         elseif (event == "stopListening") then
  42.             coroutine.yield(thread)
  43.         end
  44.     end
  45. end)
  46.  
  47. function startListening(side)
  48.     listeningthread = coroutine.create(waitfordata)
  49.     coroutine.resume(listeningthread,side)
  50.     --waitForData("left")
  51.     print("test")
  52.     return "RSData"
  53. end
  54.  
  55. function stopListening()
  56.     os.queueEvent("stopListening")
  57.     return true
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement