Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --p3t5FJAq
- local turtleStats = {
- fuel = 0,
- maxFuel = 100,
- status = 0,
- issue = " ",
- donePercent = 0,
- }
- local status = {
- [0] = "Not running",
- [1] = "Running",
- [2] = "Done",
- [3] = "Issue",
- [4] = "Refueling",
- [5] = "Moving"
- }
- function showPercentageBar(percent)
- local screen = peripheral.wrap("left")
- percent = math.min(math.floor(percent*10), 10)
- screen.blit("■■■■■■■■■■", (percent ~= 0 and string.rep("5", percent) or "")..(percent ~= 10 and string.rep("7", 10-percent) or ""), "ffffffffff")
- end
- function update()
- local screen = peripheral.wrap("left")
- screen.clear()
- screen.setCursorPos(1, 1)
- local fuelLevel = math.floor((turtleStats.fuel / turtleStats.maxFuel) * 100)
- screen.write(string.format("Turtle Fuel: %d", fuelLevel).."%"..(fuelLevel > 100 and " (Overfilled)" or ""))
- screen.setCursorPos(1, 2)
- showPercentageBar(turtleStats.fuel / turtleStats.maxFuel)
- screen.setCursorPos(1, 4)
- screen.write(string.format("Progress: %d", math.floor(turtleStats.donePercent*100)).."%")
- screen.setCursorPos(1, 5)
- showPercentageBar(turtleStats.donePercent)
- screen.setCursorPos(1, 7)
- screen.write(string.format("Status: %s", status[turtleStats.status]))
- screen.setCursorPos(1, 9)
- screen.write("Current Issue:")
- screen.setCursorPos(1, 10)
- screen.write(#(turtleStats.issue:gsub("%s", "")) == 0 and "None" or turtleStats.issue)
- end
- local modem = peripheral.wrap("top")
- modem.closeAll()
- modem.open(3)
- while true do
- update()
- local message = select(5, os.pullEvent("modem_message"))
- print(message)
- local data = {}
- for x in message:gmatch("[^;]+") do
- data[#data+1] = x
- end
- turtleStats.fuel = tonumber(data[1])
- --turtleStats.maxFuel = tostring(data[2])
- turtleStats.status = tonumber(data[3])
- turtleStats.donePercent = tonumber(data[5])
- turtleStats.issue = data[4] or ""
- end
RAW Paste Data