Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function find_peripheral(t, e)
- e = e or nil
- sides = {[1] = "front", [2] = "back", [3] = "left", [4] = "right", [5] = "top", [6] = "bottom"}
- peripheral_found = false
- for num=1, 6 do
- type = peripheral.getType(sides[num])
- if type == t then
- if e == "wireless" then
- if peripheral.call(sides[num], "isWireless") then
- return sides[num]
- end
- elseif e == "remote" then
- if not peripheral.call(sides[num], "isWireless") then
- return sides[num]
- end
- elseif e == nil then
- return sides[num]
- end
- end
- end
- print("No " .. t .. " attached to the computer")
- end
- function change_colors(command, color_1, color_2)
- command.setTextColor(color_1 or colors.white)
- command.setBackgroundColor(color_2 or colors.black)
- end
- function writes(text1, command, xpos, ypos, color1, color2)
- command.setCursorPos(xpos, ypos)
- change_colors(command, color1, color2)
- command.write(text1:upper())
- change_colors(command)
- end
- me = peripheral.wrap(find_peripheral("me_drive"))
- while true do
- term.clear()
- bytes_used = me.getTotalBytes() - me.getFreeBytes()
- byte_perc = math.floor(bytes_used / me.getTotalBytes())
- types_used = me.getTotalItemTypes() - me.getRemainingItemTypes()
- type_perc = math.floor(types_used / me.getTotalItemTypes())
- text = "bytes: " .. bytes_used .. "/" .. me.getTotalBytes() .. " - " .. byte_perc .. "%"
- writes(text, term, 2, 2, colors.black, colors.white)
- text = "types: " .. types_used .. "/" .. me.getTotalItemTypes() .. " - " .. type_perc .. "%"
- writes(text, term, 2, 4, colors.black, colors.white)
- if byte_perc > 90 or type_perc > 90 then
- text = "status = need more storage"
- else
- text = "status = stable"
- end
- writes(text, term, 2, 6, colors.black, colors.white)
- os.startTimer(20)
- os.pullEvent("timer")
- end
Advertisement
Add Comment
Please, Sign In to add comment