Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --===== Blood Magic Altar Display =====--
- --===== von Thor_s_Crafter =====--
- local mon
- local monX, monY, monX2
- local a
- local ai
- local col
- os.loadAPI("input")
- local blood = 0
- local maxBlood = 0
- local bloodPer = 0
- function getPeripherals()
- mon = peripheral.find("monitor")
- monX,monY = mon.getSize()
- monX2 = math.floor(monX/2)
- a = peripheral.find("tealtar")
- end
- function getBlood()
- ai = a.getTankInfo()[1]
- if ai.contents == nil then
- blood = 0
- else
- blood = ai.contents.amount
- end
- maxBlood = ai.capacity
- bloodPer = math.floor(blood/maxBlood*100)
- end
- function display()
- term.setCursorPos(1,1)
- print("Zeit : "..getTime().."h ")
- print("Life Essence: "..(input.formatNumber(blood)).." ")
- print("Max. Life Essence: "..input.formatNumber(maxBlood).." ")
- print("in Prozent: "..bloodPer.."% ")
- mon.setCursorPos(1,1)
- mon.setTextColor(colors.white)
- mon.write("Life Essence ")
- local timeLength = string.len(getTime())
- mon.setCursorPos(monX-timeLength-1,1)
- mon.write(" "..getTime().."h")
- mon.setCursorPos(1,2)
- for i=1, monX do mon.write("=") end
- mon.setCursorPos(1,4)
- mon.write("Aktuell: "..(input.formatNumber(blood)).." ")
- mon.setCursorPos(1,5)
- mon.write("Maximal: "..(input.formatNumber(maxBlood)).." ")
- mon.setCursorPos(monX2-10,7)
- mon.write("|--------------------|")
- mon.setCursorPos(monX2-9,7)
- selectCol()
- mon.setTextColor(col)
- local part1 = bloodPer/5
- for i=1,part1 do mon.write("=") end
- mon.setCursorPos(monX2-2,8)
- mon.write(bloodPer.."% ")
- end
- function selectCol()
- if bloodPer >= 50 then col = 8192
- elseif bloodPer < 50 and bloodPer >= 20 then col = 2
- elseif bloodPer < 20 then col = 16384
- end
- end
- function getTime()
- local time = os.time()
- local fTime = textutils.formatTime(time,true)
- return tostring(fTime)
- end
- getPeripherals()
- term.setBackgroundColor(colors.gray)
- term.clear()
- mon.setBackgroundColor(colors.gray)
- mon.clear()
- while true do
- getBlood()
- display()
- sleep(0.2)
- end
Advertisement
Add Comment
Please, Sign In to add comment