Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Made by Rnen10
- -- If problems/questions feel free to contact me
- -- https://twitter.com/Rnen10
- -- rnen. (Evan#7181) on discord
- -- Program for displaying DraconicEvolution powercore as a percentage on a monitor.
- -- =============VARIABLES===================
- --Variable for when job is done
- local done = false
- print("Displaying power levels on screen")
- local power = peripheral.wrap("left")
- local mon = peripheral.wrap("monitor_1")
- local monw, monh = mon.getSize()
- monw = monw + 1
- -- ============VARIABLES END================
- -- ============FUNCTIONS====================
- local function CalcScreenTextPos(Str)
- local length = (math.ceil(monw / 2) - (math.floor(string.len(Str) / 2)))
- if (length < 1) or (length >= (monw - 1)) then
- return 1
- else
- return length
- end
- end
- local function NewLine(Str)
- power = peripheral.wrap("left")
- mon = peripheral.wrap("monitor_1")
- mon.clear()
- local barLength = monw
- local tempPercentage = 0
- local str1 = "Energy Core"
- mon.setCursorPos(CalcScreenTextPos(str1),1)
- mon.write(str1)
- --local fuelStr = "[Current Fuel %"..(math.floor()).."]"
- --mon.setCursorPos(CalcScreenTextPos(fuelStr),5)
- --mon.write(fuelStr)
- mon.setCursorPos(1,3)
- barLength = power.getEnergyStored() / power.getMaxEnergyStored() * monw
- if barLength > monw then barLength = monw end
- if mon.isColor() then
- mon.setBackgroundColor(colors.green)
- else
- mon.setBackgroundColor(colors.white)
- end
- for i =1,(barLength) do
- mon.write(" ")
- end
- if barLength < (monw + 1) then
- if mon.isColor() then mon.setBackgroundColor(colors.red) else mon.setBackgroundColor(colors.gray) end
- local remainingBarLength = (monw - barLength)
- for i =1,(remainingBarLength) do
- mon.write(" ")
- end
- end
- mon.setBackgroundColor(colors.black)
- local str2 = "% "..tostring(math.floor((power.getEnergyStored() / power.getMaxEnergyStored()) * 10000) / 100)
- mon.setCursorPos(CalcScreenTextPos(str2),5)
- mon.write(str2)
- end
- -- ===========STARTUP SEQUENCE==========
- -- ===========STARTUP SEQUENCE END======
- -- ===========MAIN LOOP=================
- while not done do
- NewLine("t")
- sleep(1)
- while not rs.getInput("back") do
- sleep(8)
- end
- end
- -- ================Main Loop End=========================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement