Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local nStartTime = os.clock()
- os.loadAPI("fmt")
- os.loadAPI("sevseg")
- os.loadAPI("countAPI")
- term.redirect(peripheral.find("monitor"))
- local pEntity = peripheral.find("EntityDetector")
- term.setBackgroundColor(colors.lightGray)
- term.clear()
- local monX, monY = term.getSize()
- paintutils.drawLine(1, 1, monX, 1, colors.gray)
- term.setCursorPos(1, 1)
- term.write("TheWitch Dashboard")
- paintutils.drawFilledBox(1, 2, 13, monY, colors.lightBlue)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.gray)
- term.setCursorPos(15, 3)
- term.write("Total")
- term.setCursorPos(15, 6)
- term.write("Uptime")
- term.setCursorPos(15, 9)
- term.write("Average")
- term.setTextColor(colors.white)
- local nWitchCount = 0
- local sWitchCount = ""
- local nTotalWitchCount = 0
- local nOldWitchCount = 0
- local nUptime = 0
- local nUptimeMin = 0
- local nAvgWitch = 0
- local function round(val, decimal)
- if (decimal) then
- return math.floor( (val * 10^decimal) + 0.5) / (10^decimal)
- else
- return math.floor(val+0.5)
- end
- end
- local function main()
- while true do
- nOldWitchCount = nWitchCount
- nWitchCount = countAPI.getEntityCount(20, 3170, 68, 1188, "EntityWitch")
- sWitchCount = string.format("%02d", nWitchCount)
- sevseg.drawSevenSeg(tonumber(sWitchCount:sub(1, 1)), 2, 3, 3)
- sevseg.drawSevenSeg(tonumber(sWitchCount:sub(2, 2)), 9, 5, 2)
- if nWitchCount > nOldWitchCount then
- nTotalWitchCount = nTotalWitchCount + (nWitchCount - nOldWitchCount)
- end
- nAvgWitch = nTotalWitchCount / nUptimeMin
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(15, 4)
- term.write(tostring(nTotalWitchCount))
- term.setCursorPos(15, 7)
- term.write(fmt.formatSeconds(nUptime))
- term.setCursorPos(15, 10)
- term.write(tostring(round(nAvgWitch, 2)).." witch/min ")
- sleep(0.5)
- end
- end
- local function uptimer()
- while true do
- nUptime = os.clock() - nStartTime
- nUptimeMin = math.floor(nUptime / 60) + 1
- sleep(0.3)
- end
- end
- parallel.waitForAll(main, uptimer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement