Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- -- Wrap the sensor
- for a,b in pairs(rs.getSides()) do
- if peripheral.getType(b) == 'sensor' then
- prox = sensor.wrap(b)
- break
- end
- end
- -- Wrap the monitor
- for a,b in pairs(rs.getSides()) do
- if peripheral.getType(b) == 'monitor' then
- mon = peripheral.wrap(b)
- break
- end
- end
- term.redirect(mon)
- -- Battery graphic
- function low(l,b)
- term.setCursorPos(l,b)
- term.setTextColor(colors.red)
- print("||")
- term.setTextColor(colors.white)
- end
- function medium(l, b)
- b = b - 1
- term.setCursorPos(l, b)
- term.setTextColor(colors.yellow)
- print("||")
- term.setTextColor(colors.white)
- end
- function clM(l, b)
- b = b - 1
- term.setCursorPos(l, b)
- term.setTextColor(colors.black)
- print("||")
- term.setTextColor(colors.white)
- end
- function high(l, b)
- b = b - 2
- term.setCursorPos(l,b)
- term.setTextColor(colors.lime)
- print("||")
- term.setTextColor(colors.white)
- end
- function clH(l, b)
- b = b - 2
- term.setCursorPos(l,b)
- term.setTextColor(colors.black)
- print("||")
- term.setTextColor(colors.white)
- end
- -- Battery Function
- function battery(l,b)
- if percent < 33 then
- low(l,b)
- clM(l,b)
- clH(l,b)
- elseif percent >= 33 and percent <= 66 then
- low(l,b)
- medium(l,b)
- clH(l,b)
- elseif percent >= 66 then
- low(l,b)
- medium(l,b)
- high(l,b)
- end
- end
- while true do
- shell.run("ui")
- -- Create table with coordinates
- t = {}
- tar = prox.getTargets()
- i = 1
- count = 0
- for name, basicDetails in pairs(tar) do
- local moreDetails = prox.getTargetDetails(name)
- local checkName = moreDetails.Name
- if checkName == "MFSU" then
- t[i] = name
- i = i+1
- count = count + 1
- end
- end
- -- MFSU 1
- if count > 0 then
- details = prox.getTargetDetails(t[1])
- term.setCursorPos(3,3)
- print("MFSU - 1")
- term.setCursorPos(4,4)
- term.setTextColor(colors.black)
- print("--------")
- term.setCursorPos(4,4)
- term.setTextColor(colors.white)
- print(math.floor(details.Stored))
- term.setCursorPos(5,5)
- term.setTextColor(colors.black)
- print("-------")
- term.setCursorPos(5,5)
- term.setTextColor(colors.white)
- percent = math.floor(details.StoredPercentage)
- print(percent, "%")
- battery(12,5)
- else
- term.setCursorPos(4,4)
- print("No Input")
- end
- -- MFSU 2
- if count > 1 then
- details = prox.getTargetDetails(t[2])
- term.setCursorPos(20,3)
- print("MFSU - 2")
- term.setCursorPos(21,4)
- term.setTextColor(colors.black)
- print("--------")
- term.setCursorPos(21,4)
- term.setTextColor(colors.white)
- print(math.floor(details.Stored))
- term.setCursorPos(22,5)
- term.setTextColor(colors.black)
- print("-------")
- term.setCursorPos(22,5)
- term.setTextColor(colors.white)
- percent = math.floor(details.StoredPercentage)
- print(percent, "%")
- battery(29,5)
- else
- term.setCursorPos(21,4)
- print("No Input")
- end
- -- MFSU 3
- if count > 2 then
- details = prox.getTargetDetails(t[3])
- term.setCursorPos(36,3)
- print("MFSU - 3")
- term.setCursorPos(37,4)
- term.setTextColor(colors.black)
- print("--------")
- term.setCursorPos(37,4)
- term.setTextColor(colors.white)
- print(math.floor(details.Stored))
- term.setCursorPos(38,5)
- term.setTextColor(colors.black)
- print("-------")
- term.setCursorPos(38,5)
- term.setTextColor(colors.white)
- percent = math.floor(details.StoredPercentage)
- print(percent, "%")
- battery(45,5)
- else
- term.setCursorPos(37,4)
- print("No Input")
- end
- -- MFSU 4
- if count > 3 then
- details = prox.getTargetDetails(t[4])
- term.setCursorPos(3,9)
- print("MFSU - 4")
- term.setCursorPos(4,10)
- term.setTextColor(colors.black)
- print("--------")
- term.setCursorPos(4,10)
- term.setTextColor(colors.white)
- print(math.floor(details.Stored))
- term.setCursorPos(5,11)
- term.setTextColor(colors.black)
- print("-------")
- term.setCursorPos(5,11)
- term.setTextColor(colors.white)
- percent = math.floor(details.StoredPercentage)
- print(percent, "%")
- battery(12,11)
- else
- term.setCursorPos(4,10)
- print("No Input")
- end
- -- MFSU 5
- if count > 4 then
- details = prox.getTargetDetails(t[5])
- term.setCursorPos(20,9)
- print("MFSU - 5")
- term.setCursorPos(21,10)
- term.setTextColor(colors.black)
- print("--------")
- term.setCursorPos(21,10)
- term.setTextColor(colors.white)
- print(math.floor(details.Stored))
- term.setCursorPos(22,11)
- term.setTextColor(colors.black)
- print("-------")
- term.setCursorPos(22,11)
- term.setTextColor(colors.white)
- percent = math.floor(details.StoredPercentage)
- print(percent, "%")
- battery(29,11)
- else
- term.setCursorPos(21,10)
- print("No Input")
- end
- -- MFSU 6
- if count > 5 then
- details = prox.getTargetDetails(t[6])
- term.setCursorPos(36,9)
- print("MFSU - 6")
- term.setCursorPos(37,10)
- term.setTextColor(colors.black)
- print("--------")
- term.setCursorPos(37,10)
- term.setTextColor(colors.white)
- print(math.floor(details.Stored))
- term.setCursorPos(38,11)
- term.setTextColor(colors.black)
- print("-------")
- term.setCursorPos(38,11)
- term.setTextColor(colors.white)
- percent = math.floor(details.StoredPercentage)
- print(percent, "%")
- battery(45,11)
- else
- term.setCursorPos(37,10)
- print("No Input")
- end
- -- MFSU 7
- if count > 6 then
- details = prox.getTargetDetails(t[7])
- term.setCursorPos(3,15)
- print("MFSU - 7")
- term.setCursorPos(4,16)
- term.setTextColor(colors.black)
- print("--------")
- term.setCursorPos(4,16)
- term.setTextColor(colors.white)
- print(math.floor(details.Stored))
- term.setCursorPos(5,17)
- term.setTextColor(colors.black)
- print("-------")
- term.setCursorPos(5,17)
- term.setTextColor(colors.white)
- percent = math.floor(details.StoredPercentage)
- print(percent, "%")
- battery(12,17)
- else
- term.setCursorPos(4,16)
- print("No Input")
- end
- -- MFSU 8
- if count > 7 then
- details = prox.getTargetDetails(t[8])
- term.setCursorPos(20,15)
- print("MFSU - 8")
- term.setCursorPos(21,16)
- term.setTextColor(colors.black)
- print("--------")
- term.setCursorPos(21,16)
- term.setTextColor(colors.white)
- print(math.floor(details.Stored))
- term.setCursorPos(22,17)
- term.setTextColor(colors.black)
- print("-------")
- term.setCursorPos(22,17)
- term.setTextColor(colors.white)
- percent = math.floor(details.StoredPercentage)
- print(percent, "%")
- battery(29,17)
- else
- term.setCursorPos(21,16)
- print("No Input")
- end
- -- MFSU 9
- if count > 8 then
- details = prox.getTargetDetails(t[9])
- term.setCursorPos(36,15)
- print("MFSU - 9")
- term.setCursorPos(37,16)
- term.setTextColor(colors.black)
- print("--------")
- term.setCursorPos(37,16)
- term.setTextColor(colors.white)
- print(math.floor(details.Stored))
- term.setCursorPos(38,17)
- term.setTextColor(colors.black)
- print("-------")
- term.setCursorPos(38,17)
- term.setTextColor(colors.white)
- percent = math.floor(details.StoredPercentage)
- print(percent, "%")
- battery(45,17)
- else
- term.setCursorPos(37,16)
- print("No Input")
- end
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement