Advertisement
brensen11

farm

Aug 28th, 2022 (edited)
1,172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.00 KB | None | 0 0
  1. local m = require("blib")
  2. m.map = {x = 1, y = 1, z = 1, xf = 0, yf = 1}
  3. local Length
  4. local Width
  5.  
  6. function isWaterBlock()
  7.     if m.map.x % 9 == 5  and m.map.y % 9 == 5 then
  8.         return true
  9.     end
  10. end
  11.  
  12. function PlaceDirtBlock()
  13.     if m.SelectItem("minecraft:dirt") then
  14.         turtle.digDown()
  15.         turtle.placeDown()
  16.         return true
  17.     end
  18.     return false
  19.    
  20. end
  21.  
  22. function Start()
  23.  
  24.     for x = 1, Width do                         -- starting length cuts one turn off, but not one column off. see below
  25.  
  26.         for y = 1, Length - 1 do                -- width cuts one length down off the next
  27.  
  28.             -- check for fuel
  29.             if(not m.CheckFuel(10)) then
  30.                 return Shutdown("Out of Fuel!")
  31.             end
  32.  
  33.             if not isWaterBlock() then
  34.                 PlaceDirtBlock()
  35.             else
  36.                 turtle.digDown()
  37.             end
  38.             m.MapForward()
  39.         end
  40.  
  41.         PlaceDirtBlock() -- Place block on turns
  42.  
  43.         if( Width - x ~= 0) then -- Technically on the last column, we want to continue forward so we can't do 'Width - 1', but don't turn into the next column
  44.             if(lastTurn == "Right") then -- if we're on an even column, turn left
  45.                 m.MapTurnLeft()
  46.                 m.MapForward()
  47.                 m.MapTurnLeft()
  48.                 lastTurn = "Left"
  49.             else -- odd columns (start is 1 btw) turn right!
  50.                 m.MapTurnRight()
  51.                 m.MapForward()
  52.                 m.MapTurnRight()
  53.                 lastTurn = "Right"
  54.             end
  55.         end
  56.  
  57.     end
  58.  
  59.    
  60. end
  61.  
  62. function Main()
  63.     local response
  64.     print("Welcome to the Minecraft farm plot builder!")
  65.     print("please enter how many plots LONG you want to build!")
  66.     local plotsLong = read()
  67.     Length = 9 * plotsLong
  68.     print("please enter how many plots WIDE you want to build!")
  69.     local plotsWide = read()
  70.     Width = 9 * plotsWide
  71.  
  72.     Start()
  73.  
  74.     print("Finished!")
  75. end
  76. Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement