Advertisement
CelticCoder

GetTurtleFuel

Sep 24th, 2023 (edited)
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.54 KB | None | 0 0
  1. -- Display Turtle Fuel Level and Percentage
  2.  
  3. -- Function to get and display the Turtle's fuel information
  4. function displayFuelInfo()
  5.   local fuelLevel = turtle.getFuelLevel()
  6.   local maxFuelLevel = turtle.getFuelLimit()
  7.  
  8.   if fuelLevel == "unlimited" then
  9.     print("Fuel level: Unlimited")
  10.   else
  11.     local fuelPercentage = (fuelLevel / maxFuelLevel) * 100
  12.     print("Fuel level: " .. fuelLevel)
  13.     print("Max fuel level: " .. maxFuelLevel)
  14.     print("Fuel percentage: " .. string.format("%.2f", fuelPercentage) .. "%")
  15.   end
  16. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement