SirSheepe

Untitled

Feb 23rd, 2018
101
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --p3t5FJAq
  2. local turtleStats = {
  3. fuel = 0,
  4. maxFuel = 100,
  5. status = 0,
  6. issue = " ",
  7. donePercent = 0,
  8. }
  9.  
  10. local status = {
  11. [0] = "Not running",
  12. [1] = "Running",
  13. [2] = "Done",
  14. [3] = "Issue",
  15. [4] = "Refueling",
  16. [5] = "Moving"
  17. }
  18.  
  19. function showPercentageBar(percent)
  20. local screen = peripheral.wrap("left")
  21. percent = math.min(math.floor(percent*10), 10)
  22. screen.blit("■■■■■■■■■■", (percent ~= 0 and string.rep("5", percent) or "")..(percent ~= 10 and string.rep("7", 10-percent) or ""), "ffffffffff")
  23. end
  24.  
  25. function update()
  26. local screen = peripheral.wrap("left")
  27. screen.clear()
  28. screen.setCursorPos(1, 1)
  29.  
  30. local fuelLevel = math.floor((turtleStats.fuel / turtleStats.maxFuel) * 100)
  31.  
  32. screen.write(string.format("Turtle Fuel: %d", fuelLevel).."%"..(fuelLevel > 100 and " (Overfilled)" or ""))
  33. screen.setCursorPos(1, 2)
  34. showPercentageBar(turtleStats.fuel / turtleStats.maxFuel)
  35.  
  36. screen.setCursorPos(1, 4)
  37. screen.write(string.format("Progress: %d", math.floor(turtleStats.donePercent*100)).."%")
  38. screen.setCursorPos(1, 5)
  39. showPercentageBar(turtleStats.donePercent)
  40.  
  41. screen.setCursorPos(1, 7)
  42. screen.write(string.format("Status: %s", status[turtleStats.status]))
  43.  
  44. screen.setCursorPos(1, 9)
  45. screen.write("Current Issue:")
  46.  
  47. screen.setCursorPos(1, 10)
  48. screen.write(#(turtleStats.issue:gsub("%s", "")) == 0 and "None" or turtleStats.issue)
  49. end
  50.  
  51. local modem = peripheral.wrap("top")
  52. modem.closeAll()
  53. modem.open(3)
  54.  
  55. while true do
  56. update()
  57.  
  58. local message = select(5, os.pullEvent("modem_message"))
  59.  
  60. print(message)
  61.  
  62. local data = {}
  63.  
  64. for x in message:gmatch("[^;]+") do
  65. data[#data+1] = x
  66. end
  67.  
  68. turtleStats.fuel = tonumber(data[1])
  69. --turtleStats.maxFuel = tostring(data[2])
  70. turtleStats.status = tonumber(data[3])
  71. turtleStats.donePercent = tonumber(data[5])
  72. turtleStats.issue = data[4] or ""
  73.  
  74.  
  75.  
  76. end
RAW Paste Data