Advertisement
musictroopa

platform.lua

Oct 3rd, 2022 (edited)
1,877
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.44 KB | Gaming | 0 0
  1. local tArgs = {...}
  2. local length = tonumber(tArgs[1])
  3. local width = tonumber(tArgs[2])
  4. local turnRight = true
  5. local slot = 1
  6.  
  7.  
  8.  
  9. --Helper Functions
  10. function nextSlot()
  11.     if slot < 16 then
  12.         slot = slot + 1
  13.     else
  14.         slot = 1
  15.     end
  16.       turtle.select(slot)
  17. end
  18.  
  19. function place()
  20.     block = turtle.inspectDown()
  21.     if block then
  22.         if not turtle.compareDown() then
  23.             turtle.digDown()
  24.             turtle.placeDown()
  25.         end
  26.     end
  27. end
  28.  
  29. if width == nil then
  30.     print("1. Place turtle facing direction of said platform on left side.")
  31.     print("2. Load turtle with materials for the platform.")
  32.     print("3. Type 'platform <length> <width>'")
  33.     return 0
  34. end
  35.  
  36. -- Main Function --
  37. function main()
  38.        
  39. end
  40.  
  41.  
  42. turtle.select(slot)
  43.  
  44. turtle.dig()
  45. turtle.forward()
  46.  
  47. for j = 1, width, 1 do
  48.  
  49.   for i = 1, length, 1 do
  50.     if turtle.getItemCount(slot) == 0 then
  51.       nextSlot()
  52.       turtle.digDown()
  53.       turtle.placeDown()
  54.     else
  55.         if not turtle.refuel() then
  56.             turtle.digDown()
  57.             turtle.placeDown()
  58.         end
  59.     end
  60.    
  61.     if i < length then
  62.         turtle.dig()
  63.       turtle.forward()
  64.     end
  65.  
  66.   end
  67.  
  68.   if j < width then
  69.  
  70.     if turnRight == true then
  71.       turtle.turnRight()
  72.       turtle.dig()
  73.       turtle.forward()
  74.       turtle.turnRight()
  75.       turnRight = false
  76.     else
  77.       turtle.turnLeft()
  78.       turtle.dig()
  79.       turtle.forward()
  80.       turtle.turnLeft()
  81.       turnRight = true
  82.     end
  83.   end
  84. end
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement