Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if fs.exists("bcapi") == false then
- shell.run("pastebin get XZJfiqnH bcapi")
- end
- os.loadAPI("bcapi")
- function broadcast(str, side)
- local enc = bcapi.encode(str)
- bcapi.send(enc, side)
- end
- function receive(side)
- local ret = {}
- while true do
- local event, p1 = os.pullEvent()
- if event == "redstone" then
- bcapi.decode(rs.getBundledInput(side))
- elseif event == "BCAPI_start" then
- ret.id = p1
- ret.tmsg = {}
- elseif event == "BCAPI_byte" then
- ret.tmsg[#ret.tmsg+1] = p1
- elseif event == "BCAPI_end" then
- ret.msg = string.char(unpack(ret.tmsg))
- break
- end
- end
- return ret.id, ret.msg
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement