Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.startTimer(5)
- r1 = peripheral.wrap("iron_note_32")
- r2 = peripheral.wrap("iron_note_34")
- f1 = peripheral.wrap("iron_note_31")
- f2 = peripheral.wrap("iron_note_33")
- local function rear(inst,pitch)
- r1.playNote(inst,pitch)
- r2.playNote(inst,pitch)
- end
- local function front(inst,pitch)
- f1.playNote(inst,pitch)
- f2.playNote(inst,pitch)
- end
- local radios = {}
- local function isRadio(msg)
- if type(msg) ~= "table" then
- return false
- end
- if msg.sType ~= "radio" then
- return false
- end
- return true
- end
- print("Scanning for online radio stations...")
- while true do
- local tEvent = {os.pullEvent()}
- if isRadio(tEvent[3]) then
- radios[tEvent[3].sChannel] = tEvent[3].sChannel
- end
- if tEvent[1] == "timer" then
- break
- end
- end
- i = 0
- for k,v in pairs(radios) do
- i = i + 1
- print(i..": "..v)
- end
- write("Connect to: ")
- local chan = read()
- function updateTime()
- if cont.cur ~= ocur then
- ges = cont.all
- cur = cont.cur
- allm = math.floor(ges/60)
- alls = ges%60
- curm = math.floor(cur/60)
- curs = cur%60
- text = string.format("%2i:%2i",curm,curs):gsub(" ","0").." / "..string.format("%2i:%2i",allm,alls):gsub(" ","0").." - "..cont.name
- x,y = term.getCursorPos()
- term.setCursorPos(1,y)
- term.clearLine()
- term.write(text)
- ocur = cur
- end
- end
- ocur = -1
- block = peripheral.find("iron_note")
- while true do
- e = {os.pullEvent("bitnet_message")}
- msg = e[3]
- if msg.sType == "radio" and msg.sChannel == chan then
- cont = msg.tMessage
- updateTime()
- for i,v in pairs(cont.notes) do
- if v and v.pitch then
- if (v.inst == 4 and v.pitch <= 20) or (v.inst == 1 and v.pitch <= 12) or (v.inst == 2 and v.pitch <= 6) or (v.int==1 and v.pitch <= 2) then
- pcall(function() rear(v.inst,v.pitch) end)
- else
- pcall(function() front(v.inst,v.pitch) end)
- end
- end
- --pcall(function() block.playNote(v.inst,v.pitch) end)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement