SHOW:
|
|
- or go back to the newest paste.
| 1 | -- Made by Rnen10 | |
| 2 | -- If problems/questions feel free to contact me | |
| 3 | -- https://twitter.com/Rnen10 | |
| 4 | -- rnen. (Evan#7181) on discord | |
| 5 | ||
| 6 | - | --Here is a detailed view |
| 6 | + | -- Program for displaying DraconicEvolution powercore as a percentage on a monitor. |
| 7 | - | --https://imgur.com/a/FMfTi |
| 7 | + | |
| 8 | -- =============VARIABLES=================== | |
| 9 | - | --Here's a flowchart showing how it works |
| 9 | + | |
| 10 | - | --https://sketchboard.me/NAZDv63LNgBd#/ |
| 10 | + | |
| 11 | local done = false | |
| 12 | ||
| 13 | - | --Use this for automatic updates-> pastebin get fehTMGPp startup |
| 13 | + | print("Displaying power levels on screen")
|
| 14 | ||
| 15 | local power = peripheral.wrap("left")
| |
| 16 | - | analyzer = peripheral.wrap("bottom")
|
| 16 | + | local mon = peripheral.wrap("monitor_1")
|
| 17 | ||
| 18 | - | --Plant 1 & 2 |
| 18 | + | local monw, monh = mon.getSize() |
| 19 | - | local p1 = nil |
| 19 | + | monw = monw + 1 |
| 20 | - | local p2 = nil |
| 20 | + | |
| 21 | - | --Seeds in analyzer |
| 21 | + | |
| 22 | - | local p3 = nil |
| 22 | + | |
| 23 | -- ============FUNCTIONS==================== | |
| 24 | local function CalcScreenTextPos(Str) | |
| 25 | local length = (math.ceil(monw / 2) - (math.floor(string.len(Str) / 2))) | |
| 26 | - | local plantName = nil |
| 26 | + | if (length < 1) or (length >= (monw - 1)) then |
| 27 | return 1 | |
| 28 | - | function DEBUG() |
| 28 | + | |
| 29 | - | return fs.exists("seeddebug")
|
| 29 | + | return length |
| 30 | end | |
| 31 | end | |
| 32 | - | local posData = { ["x"] = 0, ["y"] = 0, ["rot"] = 1 }
|
| 32 | + | |
| 33 | local function NewLine(Str) | |
| 34 | power = peripheral.wrap("left")
| |
| 35 | mon = peripheral.wrap("monitor_1")
| |
| 36 | - | function NewLine(Str) |
| 36 | + | |
| 37 | - | local barLength = 40 |
| 37 | + | mon.clear() |
| 38 | ||
| 39 | - | term.clear() |
| 39 | + | local barLength = monw |
| 40 | - | term.setCursorPos(1,2) |
| 40 | + | |
| 41 | - | print("-------------[SeedBot v3.8]------------")
|
| 41 | + | |
| 42 | - | term.setCursorPos(11,5) |
| 42 | + | local str1 = "Energy Core" |
| 43 | - | write("v {Current action} v")
|
| 43 | + | mon.setCursorPos(CalcScreenTextPos(str1),1) |
| 44 | - | term.setCursorPos(21 - (math.floor(string.len(Str) / 2)),8) |
| 44 | + | mon.write(str1) |
| 45 | - | print(Str) |
| 45 | + | |
| 46 | - | if not plantName == nil then |
| 46 | + | --local fuelStr = "[Current Fuel %"..(math.floor()).."]" |
| 47 | - | plantString = "Current Type: "..plantName |
| 47 | + | --mon.setCursorPos(CalcScreenTextPos(fuelStr),5) |
| 48 | - | term.setCursorPos(20 - (math.floor(string.len(plantString) / 2)),9) |
| 48 | + | --mon.write(fuelStr) |
| 49 | - | print(plantString) |
| 49 | + | mon.setCursorPos(1,3) |
| 50 | barLength = power.getEnergyStored() / power.getMaxEnergyStored() * monw | |
| 51 | - | if DEBUG() then |
| 51 | + | if barLength > monw then barLength = monw end |
| 52 | - | term.setCursorPos(1,11) |
| 52 | + | if mon.isColor() then |
| 53 | - | print("X: "..posData["x"].." Y: "..posData["y"].." Rot: "..posData["rot"])
|
| 53 | + | mon.setBackgroundColor(colors.green) |
| 54 | else | |
| 55 | - | term.setCursorPos(12,12) |
| 55 | + | mon.setBackgroundColor(colors.white) |
| 56 | - | write("[Current Fuel %"..(math.floor(turtle.getFuelLevel())))
|
| 56 | + | |
| 57 | - | write("]")
|
| 57 | + | |
| 58 | - | term.setCursorPos(1,13) |
| 58 | + | mon.write(" ")
|
| 59 | - | barLength = turtle.getFuelLevel() / 100 * 40 |
| 59 | + | |
| 60 | - | if barLength > 40 then barLength = 40 end |
| 60 | + | if barLength < (monw + 1) then |
| 61 | - | if term.isColor() then |
| 61 | + | if mon.isColor() then mon.setBackgroundColor(colors.red) else mon.setBackgroundColor(colors.gray) end |
| 62 | - | term.setBackgroundColor(colors.green) |
| 62 | + | local remainingBarLength = (monw - barLength) |
| 63 | for i =1,(remainingBarLength) do | |
| 64 | - | term.setBackgroundColor(colors.white) |
| 64 | + | mon.write(" ")
|
| 65 | end | |
| 66 | end | |
| 67 | - | write(" ")
|
| 67 | + | mon.setBackgroundColor(colors.black) |
| 68 | ||
| 69 | - | if barLength < 40 then |
| 69 | + | local str2 = "% "..tostring(math.floor((power.getEnergyStored() / power.getMaxEnergyStored()) * 10000) / 100) |
| 70 | - | if term.isColor() then term.setBackgroundColor(colors.red) else term.setBackgroundColor(colors.gray) end |
| 70 | + | mon.setCursorPos(CalcScreenTextPos(str2),5) |
| 71 | - | local remainingBarLength = (40 - barLength) |
| 71 | + | mon.write(str2) |
| 72 | end | |
| 73 | - | write(" ")
|
| 73 | + | |
| 74 | ||
| 75 | -- ===========STARTUP SEQUENCE========== | |
| 76 | - | term.setBackgroundColor(colors.black) |
| 76 | + | |
| 77 | -- ===========STARTUP SEQUENCE END====== | |
| 78 | ||
| 79 | - | function ClearSeeds() |
| 79 | + | |
| 80 | - | analyzer = peripheral.wrap("bottom")
|
| 80 | + | |
| 81 | - | if analyzer.hasPlant("NORTH") then
|
| 81 | + | NewLine("t")
|
| 82 | - | Left() |
| 82 | + | sleep(1) |
| 83 | - | Forward() |
| 83 | + | while not rs.getInput("back") do
|
| 84 | - | turtle.select(1) |
| 84 | + | sleep(8) |
| 85 | - | turtle.digDown() |
| 85 | + | end |
| 86 | - | turtle.suckDown() |
| 86 | + | |
| 87 | - | turtle.select(1) |
| 87 | + | -- ================Main Loop End========================= |
| 88 | - | turtle.placeDown() |
| 88 | + |