Kenanja

hitCrank

Mar 29th, 2024 (edited)
909
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.80 KB | None | 0 0
  1. -- Function to check and refuel if necessary
  2. local function checkFuel()
  3.     if turtle.getFuelLevel() < 10 then
  4.         print("Refueling...")
  5.         turtle.select(1) -- Assuming fuel is in slot 1
  6.         turtle.refuel(1)
  7.     end
  8. end
  9.  
  10. local p = peripheral.wrap("left")
  11.  
  12. while true do
  13.     -- Check if there's a block in front of the turtle (the crank)
  14.     if turtle.detect() then
  15.         print("Crank detected. Attempting to hit...")
  16.         turtle.select(16)
  17.         p.useOnBlock()
  18.         print("Hit the crank.")
  19.     else
  20.         print("Crank not detected. Please check the turtle's orientation.")
  21.         break
  22.     end
  23.  
  24.     -- Introduce a delay between hits to simulate a more realistic interaction with the crank
  25.     os.sleep(0.5)
  26.  
  27.     -- Check and refuel if necessary
  28.     checkFuel()
  29. end
  30.  
Advertisement
Add Comment
Please, Sign In to add comment