sorry for the bad example,
but it`s the same with this: less small than the other
monitor = peripheral.wrap("top") --this prog requires a monitor min. size of 3x3
monitor.setTextScale(0.5)
term.redirect(monitor)
os.loadAPI("ocs/apis/sensor") --be sure to place your computer and sensors in a range of max. 7 blocks to the back-block of the reactor-core, due to the sensor range
local inventory = sensor.wrap("left") --put the inventory sensor card to a sensor at the left side
local ic2 = sensor.wrap("right")
term.clear()
local counter = 0
local menergy = {}
TextColor = 1
menergy = {valuenew = 0,
valueinc = 0 }
function drawbar (PosCol, PosRow, BarWidth, BarCol, BarValue)
local digit = {}
for x = PosCol, PosCol + (BarWidth) do
term.setCursorPos (PosCol + x , PosRow) print (" ")
end
term.setCursorPos ( PosCol, PosRow ) term.setTextColor (colors.white) print (">")
term.setCursorPos ( PosCol + (BarWidth+2) , PosRow ) term.setTextColor (colors.white) print ("<")
TextPos= math.ceil(BarWidth /2) - 2
if BarValue >= 101 then BarValue = 100 end
if BarValue ~= 0 then
BarPos = ((BarWidth / 100) * BarValue )
term.setCursorPos ( (PosCol+1) + BarPos, PosRow ) term.setBackgroundColor (BarCol) print (" ") term.setBackgroundColor(32768)
for freespace = PosCol + 1 , BarPos + 2 do
term.setBackgroundColor(BarCol)
term.setTextColor(TextColor)
term.setCursorPos (freespace, PosRow) print (" ")
term.setBackgroundColor(32768)
end
else
term.setBackgroundColor(colors.black)
term.setCursorPos(PosCol + 1, PosRow) print (" ")
BarPos = 0
end
for z = 0 , 3 do
if BarPos >= TextPos + z then digit[z] = { digit = string.sub(BarValue, z+1, z+1), TextColor = 32768, BColor = BarCol }
else digit[z] = { digit = string.sub(BarValue, z+1, z+1), TextColor = 1, BColor = 32768 } end
if BarPos >= TextPos + 3 then digit[3] = { digit = "%", TextColor = 32768, BColor = BarCol}
else digit[3] = { digit = "%", TextColor = 1, BColor = 32768 } end
term.setCursorPos((TextPos+PosCol+(z+1)), PosRow)
term.setBackgroundColor(digit[z].BColor)
term.setTextColor(digit[z].TextColor) print(digit[z].digit)
term.setBackgroundColor (32768)
end
end
while true do
-- draw loadingdevice
chargingdeviceinventory = inventory.getTargetDetails('-3,0,0')
chargingdevicedetails = ic2.getTargetDetails ('-5,0,0')
menergy = { valuenew = chargingdevicedetails.Stored,
valueinc = (chargingdevicedetails.Stored - (tonumber(menergy.valuenew))) }
term.setTextColor (colors.orange)
term.setCursorPos (2,2) print ("Charging Device = ")
term.setCursorPos (2,3) print ("Energy Stored = ")
term.setCursorPos (29,3) print ("=")
term.setCursorPos (35,3) print ("%")
term.setCursorPos (2,4) print ("Charging Rate = ")
term.setTextColor(colors.lightBlue)
term.setCursorPos (20,2) print (" ")
term.setCursorPos (20,2) print (chargingdevicedetails.Name)
term.setCursorPos (20,3) print (" ")
term.setCursorPos (20,3) print (chargingdevicedetails.Stored)
term.setCursorPos (30,3) print (" ")
term.setCursorPos (31,3) print (chargingdevicedetails.StoredPercentage)
term.setCursorPos (20,4) print (" ")
term.setCursorPos (20,4) print (menergy.valueinc)
term.setTextColor(colors.white)
drawbar ( 2, 6, 31, 32, chargingdevicedetails.StoredPercentage )
-- draw upper slot
term.setTextColor(colors.white)
term.setCursorPos (2,9) print ("Charging-Slot:")
term.setCursorPos (2,10) print ("----------------------------------")
term.setTextColor(colors.lightGray)
term.setCursorPos (2,11) print ("Input = ")
term.setCursorPos (2,12) print ("Loading Value = ")
term.setCursorPos (2,13) print ("Load.Percentage =")
if chargingdeviceinventory.Slots[1].Name ~= "empty" then
term.setTextColor(colors.lightBlue)
term.setCursorPos (19, 11) print (" ") term.setCursorPos (20,11) print (chargingdeviceinventory.Slots[1].Name)
term.setCursorPos (19, 12) print (" ") term.setCursorPos (20,12) print (chargingdeviceinventory.Slots[1].DamageValue)
loadingpercentage = math.abs(((100/25)* (chargingdeviceinventory.Slots[1].DamageValue - 1 )*-1)+100 )
term.setCursorPos (19, 13) print (" ") term.setCursorPos (20,13) print (loadingpercentage)
drawbar (2, 15, 31, 32, loadingpercentage )
else
term.setTextColor(colors.lightBlue)
term.setCursorPos (20,11) print ("EMPTY ")
term.setCursorPos (20,12) print ("----- ")
term.setCursorPos (20,13) print ("----- ")
term.setCursorPos (2 , 15) term.clearLine()
end
-- draw lower slot
term.setTextColor(colors.white)
term.setCursorPos (2,17) print ("Decharging-Slot:")
term.setCursorPos (2,18) print ("----------------------------------")
term.setTextColor(colors.lightGray)
term.setCursorPos (2,19) print ("Input = ")
term.setCursorPos (2,20) print ("Loading Value = ")
term.setCursorPos (2,21) print ("Load.Percentage = ")
if chargingdeviceinventory.Slots[2].Name ~= "empty" then
term.setTextColor(colors.lightBlue)
term.setCursorPos (19, 19) print (" ") term.setCursorPos (20,19) print (chargingdeviceinventory.Slots[2].Name)
term.setCursorPos (19, 20) print (" ") term.setCursorPos (20,20) print (chargingdeviceinventory.Slots[2].DamageValue)
loadingpercentage = math.abs(((100/25)* (chargingdeviceinventory.Slots[2].DamageValue - 1 )*-1)+100 )
term.setCursorPos (19, 21) print (" ") term.setCursorPos (20,21) print (loadingpercentage)
if loadingpercentage == 104 then loadingpercentage = 0 end
drawbar (2, 23, 31, 32, loadingpercentage )
else
term.setTextColor(colors.lightBlue)
term.setCursorPos (20,19) print ("EMPTY ")
term.setCursorPos (20,20) print ("----- ")
term.setCursorPos (20,21) print ("----- ")
term.setCursorPos (2, 23) term.clearLine()
end
end
term.restore()