Stolar228

lamp robot

Sep 14th, 2024 (edited)
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1.  
  2. local selectedSlot = 1
  3. local maxCountSlots = 16
  4. local checkIterations = 0
  5. local exitFlag = false
  6.  
  7. -- main cicle
  8. while (true) do
  9.     -- check blocks in inventory
  10.     checkIterations = 0
  11.     while (true) do
  12.         checkIterations = checkIterations + 1
  13.         if (turtle.getItemDetail(selectedSlot) ~= nil) then
  14.             break
  15.         end
  16.        
  17.         selectedSlot = selectedSlot + 1
  18.         if (selectedSlot >= maxCountSlots) then
  19.             selectedSlot = 1
  20.         end
  21.        
  22.         if (checkIterations >= maxCountSlots) then
  23.             exitFlag = true
  24.         end
  25.     end
  26.    
  27.     if (exitFlag) then
  28.         print("NO BLOCKS :(")
  29.         break
  30.     end
  31.    
  32.     -- place block
  33.     turtle.select(selectedSlot)
  34.     turtle.placeUp()
  35.    
  36.     -- move
  37.     for i = 1, 4 do
  38.         if (not turtle.forward()) then
  39.             print("NO FUEL OR WALL")
  40.             break
  41.         end
  42.     end
  43.    
  44. end
Advertisement
Add Comment
Please, Sign In to add comment