Advertisement
GNOOR1S

CC: Tweaked - Turtle Platformer

Nov 24th, 2022 (edited)
726
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | Gaming | 0 0
  1. -- this program goes from right to left
  2.  
  3. -- usage "filler [width](right to left) [height](forward direction)
  4.  
  5. local tArgs = {...}
  6. local width = tArgs[1]
  7. local height = tArgs[2]
  8.  
  9. function fuel()
  10.     if turtle.getFuelLevel() < 10 then
  11.         local slot = turtle.getSelectedSlot()
  12.         turtle.select(16)
  13.         turtle.refuel(1)
  14.         turtle.select(slot)
  15.     end
  16.    
  17.     if turtle.getFuelLevel() < 9 then
  18.         print("Please insert fuel into turtle, bottom rt")
  19.         repeat
  20.             sleep(.5)
  21.         until turtle.getItemCount(16) > 0
  22.        
  23.     end
  24. end
  25.  
  26. function check()
  27.     local slot = turtle.getSelectedSlot()
  28.     if slot == 15 then
  29.         -- wait for materials function
  30.         repeat
  31.             sleep(.5)
  32.         until turtle.getItemCount(1) > 1
  33.         turtle.select(1)
  34.     end
  35.    
  36.     if turtle.getItemCount(slot) < 1 then
  37.         turtle.select(slot + 1)
  38.     end
  39.    
  40. end
  41.  
  42.  
  43. function run()
  44.     for x = 1, width do
  45.         for y = 1, height do
  46.             fuel()
  47.             check()
  48.             turtle.placeDown()
  49.             while not turtle.forward() do turtle.dig() end
  50.        end
  51.        
  52.        if x % 2 > 0 then
  53.            check()
  54.            turtle.placeDown()
  55.            turtle.turnLeft()
  56.            turtle.forward()
  57.            turtle.turnLeft()
  58.        else
  59.            check()
  60.            turtle.placeDown()
  61.            turtle.turnRight()
  62.            turtle.forward()
  63.            turtle.turnRight()
  64.        end
  65.        
  66.     end
  67. end
  68.  
  69.  
  70. run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement