SHOW:
|
|
- or go back to the newest paste.
| 1 | - | --[[ Power Monitoring Program Written By: 0_Mr_Redstone_0 AKA MoJoCreatior |
| 1 | + | |
| 2 | - | This code is considered free for use both commercial and private and can be redistributed so long as it meats following criteria: |
| 2 | + | |
| 3 | - | 1: 0_Mr_Redstone_0 and MoJoCreatior are credited as the original authors |
| 3 | + | |
| 4 | - | 2: You do not try to take full ownership of the code/written program |
| 4 | + | |
| 5 | - | 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]] |
| 5 | + | mon = "monitor_2" |
| 6 | term.setTextColour(colors.red) | |
| 7 | - | --Power Monitoring Program |
| 7 | + | |
| 8 | - | --Version 2 |
| 8 | + | cube = "RFStorageBattery_1" |
| 9 | term.setTextColour(colors.red) | |
| 10 | - | --Setup |
| 10 | + | |
| 11 | title = "Energy Vortex" | |
| 12 | - | print("Power Monitor Setup")
|
| 12 | + | |
| 13 | term.setTextColour(colors.blue) | |
| 14 | - | print("Launching Configuration...")
|
| 14 | + | |
| 15 | ||
| 16 | - | print("What is the name of your Monitor?")
|
| 16 | + | |
| 17 | function centerText(text,yVal) | |
| 18 | - | mon = io.read() |
| 18 | + | |
| 19 | minus = math.floor(54-length) | |
| 20 | - | print("What is the name of your Energy Storage Device?")
|
| 20 | + | |
| 21 | mon.setCursorPos(x+1,yVal) | |
| 22 | - | cube = io.read() |
| 22 | + | |
| 23 | end | |
| 24 | - | print("What is the Power Monitor going to be Titled? 36 Characters Max!")
|
| 24 | + | |
| 25 | --Wraps the Peripherals | |
| 26 | - | title = io.read() |
| 26 | + | |
| 27 | mon = peripheral.wrap(mon) | |
| 28 | - | print("Confirm Settings")
|
| 28 | + | |
| 29 | --Sets the BackGround to White (Messy! I know!) | |
| 30 | - | print("Monitor: "..mon)
|
| 30 | + | |
| 31 | - | print("Battery: "..cube)
|
| 31 | + | |
| 32 | - | print("Title: "..title)
|
| 32 | + | |
| 33 | mon.setCursorPos(1,1) | |
| 34 | - | print("Hold CTRL+R to redo settings.")
|
| 34 | + | mon.write(string.rep(" ",54))
|
| 35 | - | sleep(2) |
| 35 | + | |
| 36 | - | print("Settings Saved!")
|
| 36 | + | mon.write(string.rep(" ",54))
|
| 37 | mon.setCursorPos(1,3) | |
| 38 | mon.write(string.rep(" ",54))
| |
| 39 | mon.setCursorPos(1,4) | |
| 40 | mon.write(string.rep(" ",54))
| |
| 41 | - | minus = math.floor(36-length) |
| 41 | + | |
| 42 | mon.write(string.rep(" ",54))
| |
| 43 | mon.setCursorPos(1,6) | |
| 44 | mon.write(string.rep(" ",54))
| |
| 45 | mon.setCursorPos(1,7) | |
| 46 | mon.write(string.rep(" ",54))
| |
| 47 | mon.setCursorPos(1,8) | |
| 48 | mon.write(string.rep(" ",54))
| |
| 49 | mon.setCursorPos(1,9) | |
| 50 | mon.write(string.rep(" ",54))
| |
| 51 | mon.setCursorPos(1,10) | |
| 52 | mon.write(string.rep(" ",54))
| |
| 53 | end | |
| 54 | ||
| 55 | clearScreen() | |
| 56 | - | mon.write(string.rep(" ",36))
|
| 56 | + | |
| 57 | mon.setBackgroundColour(colors.lightGray) | |
| 58 | - | mon.write(string.rep(" ",36))
|
| 58 | + | |
| 59 | mon.setTextScale(0.85) | |
| 60 | - | mon.write(string.rep(" ",36))
|
| 60 | + | |
| 61 | centerText(string.rep(" ",string.len(title)+2),1)
| |
| 62 | - | mon.write(string.rep(" ",36))
|
| 62 | + | |
| 63 | ||
| 64 | - | mon.write(string.rep(" ",36))
|
| 64 | + | |
| 65 | --Variables for Calculations | |
| 66 | - | mon.write(string.rep(" ",36))
|
| 66 | + | maxE = 1200000000000 |
| 67 | curE = cube.getEnergyStored("top")
| |
| 68 | - | mon.write(string.rep(" ",36))
|
| 68 | + | |
| 69 | rawPer = rawPer/1000000 | |
| 70 | - | mon.write(string.rep(" ",36))
|
| 70 | + | |
| 71 | bar = math.floor((rawPer*52)+0.5) | |
| 72 | - | mon.write(string.rep(" ",36))
|
| 72 | + | |
| 73 | mon.setBackgroundColour(colors.white) | |
| 74 | - | mon.write(string.rep(" ",36))
|
| 74 | + | |
| 75 | centerText("Current Energy: "..curE.." MrR",3)
| |
| 76 | mon.setTextColour(colors.green) | |
| 77 | centerText(percent.."% Full",6) | |
| 78 | ||
| 79 | --Loading Bar Code Re-Written Much MUCH simpler than before | |
| 80 | mon.setCursorPos(2,8) | |
| 81 | - | mon.setTextScale(0.5) |
| 81 | + | |
| 82 | mon.write(string.rep(" ",52))
| |
| 83 | mon.setCursorPos(2,8) | |
| 84 | mon.setBackgroundColour(colors.lime) | |
| 85 | mon.write(string.rep(" ",bar))
| |
| 86 | ||
| 87 | mon.setCursorPos(2,9) | |
| 88 | - | maxE = cube.getMaxEnergyStored("top")
|
| 88 | + | |
| 89 | mon.write(string.rep(" ",52))
| |
| 90 | mon.setCursorPos(2,9) | |
| 91 | mon.setBackgroundColour(colors.lime) | |
| 92 | - | bar = math.floor((rawPer*34)+0.5) |
| 92 | + | |
| 93 | end |