Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local signals = {}
- local mon = peripheral.wrap("monitor_0")
- local lastsignal = -1
- local peak = -1
- local mark = -1
- local xMax = -1
- local yMax = -1
- mon.setTextScale(0.5)
- xMax, yMax = mon.getSize()
- local maxsignals = xMax - 2
- local maxheight = yMax - 4
- local bar = ""
- for i = 1,maxsignals do bar = bar .. "-" end
- function drawScreen()
- mon.clear()
- local curColor = colors.white
- mon.setTextColor(curColor)
- for i,s in pairs(signals) do
- xs = maxsignals - i + 2
- ys = math.floor((maxheight * (15 - s) + 8) / 15)
- clr = curColor
- if s >= 14 then
- clr = colors.red
- elseif s >= 10 then
- clr = colors.yellow
- elseif s >= 5 then
- clr = colors.green
- else
- clr = colors.white
- end
- if clr ~= curColor then
- mon.setTextColor(clr)
- curColor = clr
- end
- for y = ys,maxheight do
- mon.setCursorPos(xs,y + 3)
- mon.write("|")
- end
- mon.setCursorPos(xs,ys + 3)
- mon.write(".")
- end
- mon.setTextColor(colors.lightBlue)
- mon.setCursorPos(2,2)
- mon.write(bar)
- mon.setCursorPos(2,yMax-1)
- mon.write(bar)
- end
- function addSignal(s)
- table.insert(signals,1,s)
- -- Keep the size of the table limite
- if table.getn(signals) > maxsignals then
- table.remove(signals)
- end
- end
- --for i = 0,15 do addSignal(i) end
- drawScreen()
- mark = os.clock() + 60
- while true do
- signal = rs.getAnalogInput("top")
- if signal ~= lastsignal then
- if signal > 10 then
- print("Meteor Signal: "..signal.." at "..os.day().." "..os.time())
- end
- if signal < lastsignal then
- -- Meteor hit so it drops to 0
- print("Meteor Detected! "..os.day().." "..os.time())
- peak = 15
- mark = -1
- elseif signal > peak then
- peak = signal
- end
- lastsignal = signal
- end
- if mark <= os.clock() then
- if peak >= 0 then
- addSignal(peak)
- end
- peak = signal
- drawScreen()
- mark = os.clock() + 60
- end
- -- addSignal(signal)
- -- drawScreen()
- sleep(10)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement