Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ Power Monitoring Program Written By: 0_Mr_Redstone_0 AKA MoJoCreatior
- This code is considered free for use both commercial and private and can be redistributed so long as it meats following criteria:
- 1: 0_Mr_Redstone_0 and MoJoCreatior are credited as the original authors
- 2: You do not try to take full ownership of the code/written program
- 3: If you modify the code for re-upload you must provide it under the same conditions. as in- Open Source, and credited to me as original author]]
- --Power Monitoring Program
- --Version 2
- --Setup
- term.setTextColour(colors.lime)
- print("Power Monitor Setup")
- term.setTextColour(colors.lightBlue)
- print("Launching Configuration...")
- term.setTextColour(colors.red)
- print("What is the name of your Monitor?")
- term.setTextColour(colors.yellow)
- mon = io.read()
- term.setTextColour(colors.red)
- print("What is the name of your Energy Storage Device?")
- term.setTextColour(colors.yellow)
- cube = io.read()
- term.setTextColour(colors.red)
- print("What is the Power Monitor going to be Titled? 36 Characters Max!")
- term.setTextColour(colors.yellow)
- title = io.read()
- term.setTextColour(colors.red)
- print("Confirm Settings")
- term.setTextColour(colors.blue)
- print("Monitor: "..mon)
- print("Battery: "..cube)
- print("Title: "..title)
- term.setTextColour(colors.red)
- print("Hold CTRL+R to redo settings.")
- sleep(2)
- print("Settings Saved!")
- --Center Text Function
- function centerText(text,yVal)
- length = string.len(text)
- minus = math.floor(36-length)
- x = math.floor(minus/2)
- mon.setCursorPos(x+1,yVal)
- mon.write(text)
- end
- --Wraps the Peripherals
- cube = peripheral.wrap(cube)
- mon = peripheral.wrap(mon)
- --Sets the BackGround to White (Messy! I know!)
- function clearScreen()
- mon.clear()
- mon.setBackgroundColour(colors.white)
- mon.setCursorPos(1,1)
- mon.write(string.rep(" ",36))
- mon.setCursorPos(1,2)
- mon.write(string.rep(" ",36))
- mon.setCursorPos(1,3)
- mon.write(string.rep(" ",36))
- mon.setCursorPos(1,4)
- mon.write(string.rep(" ",36))
- mon.setCursorPos(1,5)
- mon.write(string.rep(" ",36))
- mon.setCursorPos(1,6)
- mon.write(string.rep(" ",36))
- mon.setCursorPos(1,7)
- mon.write(string.rep(" ",36))
- mon.setCursorPos(1,8)
- mon.write(string.rep(" ",36))
- mon.setCursorPos(1,9)
- mon.write(string.rep(" ",36))
- mon.setCursorPos(1,10)
- mon.write(string.rep(" ",36))
- end
- clearScreen()
- --Centers and Displays Title On Monitor
- mon.setBackgroundColour(colors.lightGray)
- mon.setTextColour(colors.red)
- mon.setTextScale(0.5)
- mon.setCursorPos(1,1)
- centerText(string.rep(" ",string.len(title)+2),1)
- centerText(title,1)
- while true do
- --Variables for Calculations
- maxE = cube.getMaxEnergyStored("top")
- curE = cube.getEnergyStored("top")
- rawPer = curE/maxE
- percent = math.floor((rawPer*100)+0.5)
- bar = math.floor((rawPer*34)+0.5)
- mon.setBackgroundColour(colors.white)
- mon.setTextColour(colors.blue)
- centerText("Current Energy: "..curE.." RF",3)
- mon.setTextColour(colors.green)
- centerText(percent.."% Full",6)
- --Loading Bar Code Re-Written Much MUCH simpler than before
- mon.setCursorPos(2,8)
- mon.setBackgroundColour(colors.gray)
- mon.write(string.rep(" ",34))
- mon.setCursorPos(2,8)
- mon.setBackgroundColour(colors.lime)
- mon.write(string.rep(" ",bar))
- mon.setCursorPos(2,9)
- mon.setBackgroundColour(colors.gray)
- mon.write(string.rep(" ",34))
- mon.setCursorPos(2,9)
- mon.setBackgroundColour(colors.lime)
- mon.write(string.rep(" ",bar))
- end
Add Comment
Please, Sign In to add comment