Advertisement
brensen11

plant

Aug 30th, 2022 (edited)
775
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.89 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 Plant()
  13.     turtle.digDown()
  14.     if m.SelectItem("minecraft:wheat_seeds") then
  15.         turtle.placeDown()
  16.         return true
  17.     end
  18. end
  19.  
  20. function Start()
  21.  
  22.     for x = 1, Width do                         -- starting length cuts one turn off, but not one column off. see below
  23.  
  24.         for y = 1, Length - 1 do                -- width cuts one length down off the next
  25.  
  26.             -- check for fuel
  27.             if(not m.CheckFuel(10)) then
  28.                 return Shutdown("Out of Fuel!")
  29.             end
  30.  
  31.             if not isWaterBlock() then
  32.                 Plant()
  33.             end
  34.             m.MapForward()
  35.         end
  36.         Plant() -- Plant on turns
  37.  
  38.         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
  39.             if(lastTurn == "Right") then -- if we're on an even column, turn left
  40.                 m.MapTurnLeft()
  41.                 m.MapForward()
  42.                 m.MapTurnLeft()
  43.                 lastTurn = "Left"
  44.             else -- odd columns (start is 1 btw) turn right!
  45.                 m.MapTurnRight()
  46.                 m.MapForward()
  47.                 m.MapTurnRight()
  48.                 lastTurn = "Right"
  49.             end
  50.         end
  51.  
  52.     end
  53.  
  54.    
  55. end
  56.  
  57. function Main()
  58.     local response
  59.     print("Welcome to the Minecraft hoe plot planter!")
  60.     print("please enter how many plots wide you want to build!")
  61.     local plotsWide = read()
  62.     Width = 9 * plotsWide
  63.     print("please enter how many plots long you want to build!")
  64.     local plotsLong = read()
  65.     Length = 9 * plotsLong
  66.  
  67.     Start()
  68.  
  69.     print("Finished!")
  70. end
  71. Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement