Advertisement
Guest User

fuelReport.lua

a guest
May 23rd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1. local args = {...}
  2. local door = args[1]
  3. local fuel = args[2]
  4. local maxFuel = 20000
  5. local trips = math.floor(fuel / 8)
  6. local fuelPerc = fuel / maxFuel
  7.  
  8. local f = fs.open("settings.txt", "r")
  9. f.readLine()
  10. f.readLine()
  11. f.readLine()
  12. local side = f.readLine()
  13. f.close()
  14.  
  15. local mon = peripheral.wrap(side)
  16. local w,h = mon.getSize()
  17. local edge = 1
  18. local barWidth = w - 2*edge
  19.  
  20. mon.setBackgroundColor(colors.black)
  21. mon.clear()
  22. mon.setCursorPos(1,1)
  23. mon.write("Silo Door is ".. door)
  24.  
  25. mon.setCursorPos(1,3)
  26. mon.write("Turtle Fuel: ".. trips .." trips")
  27.  
  28. mon.setCursorPos(edge+1, 5)
  29. if mon.isColor() then
  30.     mon.setBackgroundColor(colors.red)
  31. else
  32.     mon.setBackgroundColor(colors.gray)
  33. end
  34. mon.write((" "):rep(barWidth))
  35. mon.setCursorPos(edge+1, 5)
  36. if mon.isColor() then
  37.     mon.setBackgroundColor(colors.blue)
  38. else
  39.     mon.setBackgroundColor(colors.white)
  40. end
  41. mon.write((" "):rep(math.floor(fuelPerc * barWidth)))
  42.  
  43. if trips < 10 then
  44.     mon.setBackgroundColor(colors.white)
  45.     if mon.isColor() then
  46.         mon.setTextColor(colors.red)
  47.     else
  48.         mon.setTextColor(colors.black)
  49.     end
  50.     mon.setCursorPos(1, 7)
  51.     mon.write((" "):rep(w))
  52.     mon.setCursorPos(1, 7)
  53.     mon.write("Warning: Refuel Immediately")
  54.     mon.setTextColor(colors.white)
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement