Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --ComputerCraft Draconic Energy Core Client by Teki 0.1
- local monitor = peripheral.wrap("right")
- monitor.setTextScale(1)
- local sizeX,sizeY = monitor.getSize()
- rednet.open("back")
- local id, msg = nil
- local getEnergyStored = 0
- local getMaxEnergyStored = 0
- local lastEnergyStored = 0
- local energyFluctuation = 0
- local energyRatio = 0
- local length = 0
- local mult = 1
- local function roundTo(num, n)
- mult = 10^(n or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- function catchData()
- -- Querry All ?
- rednet.broadcast("getAll", "CCDECClient")
- id, msg = rednet.receive("CCDECServeur")
- -- Energy Stored ?
- getEnergyStored = msg[1]
- -- Max Energy Stored ?
- getMaxEnergyStored = msg[2]
- energyFluctuation = (getEnergyStored - lastEnergyStored)/20
- lastEnergyStored = getEnergyStored
- energyRatio = (getEnergyStored/getMaxEnergyStored)
- -- Energy Stored Rounded Milliards
- getEnergyStored = math.floor(getEnergyStored/1000000000)
- -- Max Energy Rounded Milliards
- getMaxEnergyStored = math.floor(getMaxEnergyStored/1000000000)
- end
- function drawData()
- -- MONITORING SCREEN
- term.redirect(monitor)
- term.clear()
- term.setCursorPos(1,1)
- paintutils.drawBox(3, 7, sizeX-2, 10, colors.green)
- length = (sizeX-6)*energyRatio
- paintutils.drawBox(4, 8, 4+length, 9, colors.red)
- monitor.setBackgroundColour(colors.black)
- --if getActive == "ACTIVE" then
- -- paintutils.drawBox(1, 1, 39, 19, colors.green)
- --else
- -- paintutils.drawBox(1, 1, 39, 19, colors.orange)
- --end
- monitor.setTextColor(colors.white)
- term.setCursorPos(3,3)
- print(getEnergyStored .. "/" .. getMaxEnergyStored .. " MRF (" .. roundTo(energyRatio*100, 3) .. "%)")
- term.setCursorPos(3,5)
- if energyFluctuation > 0 then
- monitor.setTextColor(colors.green)
- print("+" .. energyFluctuation .. " RF/t")
- else
- monitor.setTextColor(colors.red)
- print(energyFluctuation .. " RF/t")
- end
- os.queueEvent("monitor_touch", "right", 1, 1)
- end
- function catchEvents()
- -- EVENTS
- event, side, xPos, yPos = os.pullEvent("monitor_touch")
- if (side == "right") then
- sleep(1)
- end
- end
- function drawAll()
- while true do
- catchData()
- drawData()
- sleep(1)
- end
- os.queueEvent("monitor_touch", "right", 1, 1)
- end
- while true do
- parallel.waitForAny(drawAll, catchEvents)
- sleep(0)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement