Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getVersion()
- return 0.1
- end
- function sendData(side,data)
- local stringint
- rs.setBundledOutput(side,512)
- os.sleep(1)
- for i=1,string.len(data) do
- stringint = string.byte(string.sub(data,i))
- rs.setBundledOutput(side,colors.combine(768,stringint))
- os.sleep(0.25)
- rs.setBundledOutput(side,colors.combine(512,stringint))
- os.sleep(0.25)
- end
- os.sleep(0.5)
- rs.setBundledOutput(side,0)
- return true
- end
- function receiveData(side)
- local stringdata = ""
- while colors.test(rs.getBundledInput(side),512) do
- local event = os.pullEvent("redstone")
- if colors.test(rs.getBundledInput(side),256) then
- stringdata = stringdata..string.char(rs.getBundledInput(side)-768)
- end
- os.sleep(0.1)
- end
- print("success")
- print(stringdata)
- return stringdata
- end
- waitfordata = (function (side)
- print("test123")
- while true do
- local event = os.pullEvent()
- if (event == "redstone")and(colors.test(rs.getBundledInput(side),512)) then
- os.queueEvent("RSData",receiveData(side))
- elseif (event == "stopListening") then
- coroutine.yield(thread)
- end
- end
- end)
- function startListening(side)
- listeningthread = coroutine.create(waitfordata)
- coroutine.resume(listeningthread,side)
- --waitForData("left")
- print("test")
- return "RSData"
- end
- function stopListening()
- os.queueEvent("stopListening")
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement