Stennish

Replant.lua

Aug 11th, 2021 (edited)
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- WIP Functions are commented out!
  2.  
  3. -- You can find the up to date (sometimes broken) code on my github page
  4. -- including my other little projects at github.com/Stennish/ComputerCraft-Scripts/
  5.  
  6. -- I'm telling you this now, because every time I add something, something's broken, and I finally fix it -
  7. -- -I'll update this pastebin with the new code, including the broken code so I can load it ingame.-
  8. -- -So if it's broken, just wait a little while I test it ingame and decide if I should keep going or go back to working code.
  9.  
  10. -- Code status: Working [Backup]
  11. -- note to self: figure out arguments and picking how many plots to fill [you can find the plots template here: imgur.com/ctxxMas.png]
  12.  
  13. function NextPlot() -- Move onto the Next Plot
  14.     turtle.turnLeft()
  15.     turtle.forward()
  16.     turtle.forward()
  17.     turtle.turnRight()
  18. end
  19.  
  20. function NextLeft() -- Go to next row on the left
  21.     turtle.turnLeft()
  22.     turtle.forward()
  23.     turtle.turnLeft()
  24. end
  25.  
  26. function NextRight() -- Go to next row on the right
  27.     turtle.turnRight()
  28.     turtle.forward()
  29.     turtle.turnRight()
  30. end
  31.  
  32. function PlaceSeed() -- Place seeds and go forward.
  33.     for i=1,16 do
  34.         turtle.placeDown()
  35.         turtle.forward()
  36.         turtle.placeDown()
  37.     end
  38. end
  39.  
  40. function Return() -- Go back to starting position.
  41.     turtle.turnRight()
  42.     for i=1,18 do
  43.         turtle.forward()
  44.     end
  45.     turtle.turnLeft()
  46.     turtle.back()
  47.     turtle.down()
  48. end
  49.  
  50. function init() -- Prepare for Replanting.
  51.     print("Initializing...")
  52.     os.sleep(0.5)
  53.     print("Getting in position...")
  54.     os.sleep(0.5)
  55.     turtle.up()
  56.     os.sleep(1)
  57.     turtle.forward()
  58.     os.sleep(1.5)
  59.     print("In position.")
  60.     os.sleep(1)
  61.     print("Preparing Inventory...")
  62.     Refill()
  63. end
  64.  
  65. function Refill() -- Go through all slots, refilling Slot 1.
  66.     turtle.select(16)
  67.     turtle.transferTo(1)
  68.     turtle.select(15)
  69.     turtle.transferTo(1)
  70.     turtle.select(14)
  71.     turtle.transferTo(1)
  72.     turtle.select(13)
  73.     turtle.transferTo(1)
  74.     turtle.select(12)
  75.     turtle.transferTo(1)
  76.     turtle.select(11)
  77.     turtle.transferTo(1)
  78.     turtle.select(10)
  79.     turtle.transferTo(1)
  80.     turtle.select(9)
  81.     turtle.transferTo(1)
  82.     turtle.select(8)
  83.     turtle.transferTo(1)
  84.     turtle.select(7)
  85.     turtle.transferTo(1)
  86.     turtle.select(6)
  87.     turtle.transferTo(1)
  88.     turtle.select(5)
  89.     turtle.transferTo(1)
  90.     turtle.select(4)
  91.     turtle.transferTo(1)
  92.     turtle.select(3)
  93.     turtle.transferTo(1)
  94.     turtle.select(2)
  95.     turtle.transferTo(1)
  96.     turtle.select(1)
  97. end
  98. -- main code
  99. init()
  100. print("Started!")
  101. for i=1,4 do -- Fill first plot
  102.     PlaceSeed()
  103.     NextLeft()
  104.     PlaceSeed()
  105.     NextRight()
  106.     print("Refilling Slot 1...")
  107.     Refill()
  108.     print("Continuing...")
  109. end
  110. print("First plot done, moving on to next...")
  111. NextPlot()
  112. for i=1,4 do -- Fill second plot
  113.     PlaceSeed()
  114.     NextLeft()
  115.     PlaceSeed()
  116.     NextRight()
  117.     print("Refilling Slot 1...")
  118.     Refill()
  119.     print("Continuing...")
  120. end
  121. print("Finished, returning to start point.")
  122. Return()
  123. print("Done!")
RAW Paste Data Copied