Advertisement
dadragon84

Building 1

Feb 6th, 2015
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.28 KB | None | 0 0
  1.  
  2. function r()
  3.   checkMat()
  4.   end
  5.  
  6.  
  7.  
  8. function matsList()
  9.  
  10.   print("Please make sure you have the following:")
  11.   print("Use solid blocks as building material")
  12.   print("64 of a building material in slot 1")
  13.   print("45 of a building material in slot 2")
  14.   print("1 furnace in slot 3")
  15.   print("6 chests in slot 4")
  16.   print("1 hopper in slot 5")
  17.   print("1 dirt in slot 6")
  18.   print("1 sapling in slot 7")
  19.   print("one charcoal or coal in slot 8")
  20.  
  21.  
  22.   print("Press any key when you have supplied the materials")
  23.  
  24.   local event, key = os.pullEvent("key")
  25.   if key then
  26.   print("Checking materials..")
  27.   sleep(1)
  28.   r()
  29.   end
  30.   end
  31.  
  32.  
  33. function checkMat()
  34.   turtle.getItemCount(1)
  35.   turtle.getItemCount(2)
  36.   turtle.getItemCount(3)
  37.   turtle.getItemCount(4)
  38.   turtle.getItemCount(5)
  39.   turtle.getItemCount(6)
  40.   turtle.getItemCount(7)
  41.   turtle.getItemCount(8)
  42.  
  43.   if turtle.getItemCount(1) == 64 and
  44.   turtle.getItemCount(2) == 45 and
  45.   turtle.getItemCount(3) == 1 and
  46.   turtle.getItemCount(4) == 6 and
  47.   turtle.getItemCount(5) == 1 and
  48.   turtle.getItemCount(6) == 1 and
  49.   turtle.getItemCount(7) == 1 and
  50.   turtle.getItemCount(8) == 1 then
  51.     print("Sufficient matierals!")
  52.     sleep(1)
  53.     print("Beginning to build farm...")
  54.     buildFarm()
  55.     else
  56.     print("Insufficent materials!")
  57.     sleep(1)
  58.     matsList()
  59.    end
  60.    end
  61.  
  62.  
  63.    --farm building
  64.    
  65.    function f()
  66.    turtle.forward()
  67.    end
  68.    
  69.    
  70.    
  71.    function buildFarm()
  72.  
  73.  
  74. --farm building
  75. --square wall
  76.   turtle.up()
  77.   turtle.up()
  78.   f()
  79.   turtle.select(1)
  80.   turtle.placeDown()
  81.   turtle.turnRight()
  82.   f()
  83.   turtle.placeDown()
  84.   f()
  85.   turtle.placeDown()
  86.   f()
  87.   turtle.placeDown()
  88.   f()
  89.   turtle.placeDown()
  90.   turtle.turnLeft()
  91.   f()
  92.   turtle.placeDown()
  93.   f()
  94.   turtle.placeDown()
  95.   f()
  96.   turtle.placeDown()
  97.   f()
  98.   turtle.placeDown()
  99.   f()
  100.   turtle.placeDown()
  101.   f()
  102.   turtle.placeDown()
  103.   f()
  104.   turtle.placeDown()
  105.   f()
  106.   turtle.placeDown()
  107.   f()
  108.   turtle.placeDown()
  109.   f()
  110.   turtle.placeDown()
  111.   turtle.turnLeft()
  112.   f()
  113.   turtle.placeDown()
  114.   f()
  115.   turtle.placeDown()
  116.   f()
  117.   turtle.placeDown()
  118.   f()
  119.   turtle.placeDown()
  120.   f()
  121.   turtle.placeDown()
  122.   f()
  123.   turtle.placeDown()
  124.   f()
  125.   turtle.placeDown()
  126.   f()
  127.   turtle.placeDown()
  128.   turtle.turnLeft()
  129.   f()
  130.   turtle.placeDown()
  131.   f()
  132.   turtle.placeDown()
  133.   f()
  134.   turtle.placeDown()
  135.   f()
  136.   turtle.placeDown()
  137.   f()
  138.   turtle.placeDown()
  139.   f()
  140.   turtle.placeDown()
  141.   f()
  142.   turtle.placeDown()
  143.   f()
  144.   turtle.placeDown()
  145.   f()
  146.   turtle.placeDown()
  147.   f()
  148.   turtle.placeDown()
  149.   turtle.turnLeft()
  150.   f()
  151.   turtle.placeDown()
  152.   f()
  153.   turtle.placeDown()
  154.   f()
  155.   turtle.placeDown()
  156.   f()
  157.   --lower platform
  158.   turtle.turnLeft()
  159.   f()
  160.   turtle.down()
  161.   turtle.placeDown()
  162.   turtle.turnRight()
  163.   f()
  164.   turtle.placeDown()
  165.   f()
  166.   turtle.placeDown()
  167.   f()
  168.   turtle.placeDown()
  169.   turtle.turnLeft()
  170.   f()
  171.   turtle.placeDown()
  172.   f()
  173.   turtle.placeDown()
  174.   f()
  175.   turtle.placeDown()
  176.   f()
  177.   turtle.placeDown()
  178.   f()
  179.   turtle.placeDown()
  180.   f()
  181.   turtle.placeDown()
  182.   f()
  183.   turtle.placeDown()
  184.   turtle.turnLeft()
  185.   f()
  186.   turtle.turnLeft()
  187.   turtle.placeDown()
  188.   f()
  189.   turtle.placeDown()
  190.   f()
  191.   turtle.placeDown()
  192.   f()
  193.   turtle.placeDown()
  194.   f()
  195.   turtle.placeDown()
  196.   f()
  197.   turtle.placeDown()
  198.   f()
  199.   turtle.placeDown()
  200.   turtle.turnRight()
  201.   f()
  202.   turtle.placeDown()
  203.   turtle.turnRight()
  204.   f()
  205.   turtle.placeDown()
  206.   f()
  207.   turtle.placeDown()
  208.   f()
  209.   turtle.placeDown()
  210.   f()
  211.   turtle.placeDown()
  212.   f()
  213.   turtle.placeDown()
  214.   f()
  215.   turtle.placeDown()
  216.   turtle.turnLeft()
  217.   f()
  218.   turtle.turnLeft()
  219.   turtle.placeDown()
  220.   f()
  221.   turtle.placeDown()
  222.   f()
  223.   turtle.placeDown()
  224.   turtle.select(2)
  225.   f()
  226.   turtle.placeDown()
  227.   f()
  228.   turtle.placeDown()
  229.   f()
  230.   turtle.placeDown()
  231.   f()
  232.   turtle.placeDown()
  233.   f()
  234.   turtle.turnRight()
  235.   f()
  236.   turtle.placeDown()
  237.   turtle.turnRight()
  238.   f()
  239.   turtle.placeDown()
  240.   f()
  241.   turtle.placeDown()
  242.   f()
  243.   turtle.placeDown()
  244.   f()
  245.   turtle.placeDown()
  246.   f()
  247.   turtle.placeDown()
  248.   f()
  249.   turtle.placeDown()
  250.   f()
  251.   turtle.placeDown()
  252.   turtle.turnLeft()
  253.   f()
  254.   turtle.turnLeft()
  255.   turtle.placeDown()
  256.   f()
  257.   turtle.placeDown()
  258.   f()
  259.   turtle.placeDown()
  260.   f()
  261.   turtle.placeDown()
  262.   f()
  263.   turtle.placeDown()
  264.   f()
  265.   turtle.placeDown()
  266.   f()
  267.   turtle.placeDown()
  268.   f()
  269.   turtle.placeDown()
  270.   turtle.turnRight()
  271.   f()
  272.   turtle.placeDown()
  273.   turtle.turnRight()
  274.   f()
  275.   turtle.placeDown()
  276.   f()
  277.   turtle.placeDown()
  278.   f()
  279.   turtle.placeDown()
  280.   f()
  281.   turtle.placeDown()
  282.   f()
  283.   turtle.placeDown()
  284.   f()
  285.   turtle.placeDown()
  286.   f()
  287.   turtle.placeDown()
  288.   --ditch thingy
  289.   f()
  290.   turtle.down()
  291.   turtle.turnLeft()
  292.   f()
  293.   turtle.turnLeft()
  294.   turtle.back()
  295.   turtle.place()
  296.   turtle.turnRight()
  297.   turtle.back()
  298.   turtle.place()
  299.   turtle.back()
  300.   turtle.place()
  301.   turtle.back()
  302.   turtle.place()
  303.   turtle.back()
  304.   turtle.place()
  305.   turtle.back()
  306.   turtle.place()
  307.   turtle.back()
  308.   turtle.place()
  309.   turtle.back()
  310.   turtle.place()
  311.   turtle.back()
  312.   turtle.place()
  313.   turtle.turnRight()
  314.   turtle.back()
  315.   turtle.place()
  316.   turtle.turnRight()
  317.   turtle.back()
  318.   turtle.place()
  319.   turtle.digDown()
  320.   turtle.placeDown()
  321.   turtle.back()
  322.   turtle.digDown()
  323.   turtle.placeDown()
  324.   turtle.back()
  325.   turtle.digDown()
  326.   turtle.placeDown()
  327.   turtle.back()
  328.   turtle.digDown()
  329.   turtle.back()
  330.   turtle.digDown()
  331.   turtle.placeDown()
  332.   turtle.back()
  333.   turtle.digDown()
  334.   turtle.placeDown()
  335.   turtle.back()
  336.   turtle.digDown()
  337.   turtle.placeDown()
  338.   --storage 'n' stuff
  339.   f()
  340.   turtle.up()
  341.   turtle.up()
  342.   turtle.turnLeft()
  343.   f()
  344.   turtle.turnLeft()
  345.   turtle.back()
  346.   turtle.select(4)
  347.   turtle.place()
  348.   turtle.back()
  349.   turtle.place()
  350.   turtle.back()
  351.   turtle.back()
  352.   turtle.place()
  353.   turtle.back()
  354.   turtle.place()
  355.   turtle.turnRight()
  356.   f()
  357.   turtle.turnLeft()
  358.   f()
  359.   f()
  360.   f()
  361.   turtle.down()
  362.   --furnace
  363.   turtle.select(3)
  364.   turtle.place()
  365.   turtle.select(8)
  366.   turtle.drop()
  367.   --chests and hopper
  368.   turtle.down()
  369.   turtle.digDown()
  370.   turtle.down()
  371.   turtle.turnLeft()
  372.   turtle.dig()
  373.   turtle.digDown()
  374.   turtle.down()
  375.   turtle.dig()
  376.   f()
  377.   turtle.dig()
  378.   f()
  379.   turtle.select(4)
  380.   turtle.turnRight()
  381.   turtle.turnRight()
  382.   turtle.place()
  383.   turtle.up()
  384.   turtle.placeDown()
  385.   turtle.up()
  386.   turtle.select(5)
  387.   turtle.placeDown()
  388.  
  389.  
  390.  
  391.  
  392.  --dirt and sapling
  393.   turtle.up()
  394.   turtle.turnLeft()
  395.   turtle.turnLeft()
  396.   f()
  397.   f()
  398.   f()
  399.   turtle.select(6)
  400.   turtle.up()
  401.   turtle.place()
  402.   turtle.select(7)
  403.   turtle.up()
  404.   turtle.place()
  405.  
  406.   end
  407.  
  408.   function chopTree()
  409.   turtle.select(2)
  410.   turtle.dig()
  411.   f()
  412.   turtle.select(1)
  413.   turtle.compareUp()
  414.   while turtle.compareUp() == true do
  415.   turtle.select(2)
  416.   turtle.digUp()
  417.   turtle.up()
  418.   end
  419.   print("Turtle finished chopping, returning...")
  420.   goDown()
  421.   end
  422.  
  423.  function goDown()
  424.   turtle.detectDown()
  425.   while turtle.detectDown() == false do
  426.   turtle.down()
  427.   end
  428.   turtle.back()
  429.   turtle.select(3)
  430.   turtle.place()
  431.   end
  432.  
  433.   function status()
  434.   turtle.getFuelLevel()
  435.   turtle.getItemCount(2)
  436.   turtle.getItemCount(3)
  437.   if turtle.getFuelLevel() < 100 or turtle.getItemCount(2) > 40 or turtle.getItemCount(3) < 10 then
  438.    toHub()
  439.    end
  440.    end
  441.    
  442.    
  443.   function logStat()
  444.   if turtle.getItemCount(2) > 40 then
  445.   turtle.turnLeft()
  446.   turtle.select(2)
  447.   turtle.drop(64)
  448.   turtle.turnRight()
  449.   end
  450.   end
  451.  
  452.   function saplingStat()
  453.   if turtle.getItemCount(3) < 5 then
  454.   turtle.back()
  455.   turtle.down()
  456.   turtle.down()
  457.   turtle.down()
  458.   turtle.down()
  459.   turtle.select(3)
  460.   turtle.suck(32)
  461.   turtle.up()
  462.   turtle.up()
  463.   turtle.up()
  464.   turtle.up()
  465.   f()
  466.   end
  467.   end
  468.  
  469.   function fuelStat()
  470.   if turtle.getFuelLevel() < 100 then
  471.   turtle.select(4)
  472.   turtle.turnLeft()
  473.   turtle.suck(8)
  474.   turtle.turnRight()
  475.   turtle.back()
  476.   turtle.turnRight()
  477.   f()
  478.   turtle.dropDown()
  479.   turtle.back()
  480.   turtle.down()
  481.   turtle.down()
  482.   f()
  483.   sleep(80)
  484.   turtle.select(5)
  485.   turtle.suckUp(7)
  486.   turtle.refuel()
  487.   turtle.suckUp()
  488.   turtle.back()
  489.   turtle.up()
  490.   turtle.drop()
  491.   turtle.up()
  492.   turtle.turnLeft()
  493.   f()
  494.   end
  495.   end
  496.  
  497.      
  498.   function toHub()
  499.   turtle.down()
  500.   turtle.down()
  501.   turtle.back()
  502.   turtle.back()
  503.   turtle.up()
  504.   turtle.back()
  505.   turtle.back()
  506.   turtle.back()
  507.   logStat()
  508.   saplingStat()
  509.   fuelStat()
  510.   f()
  511.   f()
  512.   f()
  513.   turtle.down()
  514.   f()
  515.   f()
  516.   turtle.up()
  517.   turtle.up()
  518.   end
  519.  
  520.    
  521.      
  522.   function menu()
  523.  
  524.   term.setCursorPos(1,1)
  525.   print("Welcome to SimpleWoodChop by yk88 and DemonBabby")
  526.   print("Type 'build' to begin building the farm")
  527.   print("Type 'chop' to begin the independent chopping program")
  528.   print("Type 'left' or 'right' to make sure the turtle is facing")
  529.   print("away from the chests and furnaces.")
  530.    
  531.  
  532.   userInput = io.read()
  533.   if string.lower(userInput) == "build" then
  534.   matsList()
  535.   print("Please put water along the top row in front of the turtle, and in the two bottom corners behind the turtle.")
  536.   print("Press any key to start the chopping program")
  537.   local key = os.pullEvent("key")
  538.   if key then
  539.   print("Starting chopping program")
  540.   checkGrowth()
  541.   end
  542.   elseif string.lower(userInput) == "chop" then
  543.   term.clear()
  544.   term.setCursorPos(1,1)
  545.   print("Please make sure the turtle is placed in front of the tree")
  546.   checkGrowth()
  547.   elseif string.lower(userInput) == "left" then
  548.   turtle.turnLeft()
  549.   print("Turning left one time..")
  550.   sleep(1.5)
  551.   rMenu()
  552.   elseif string.lower(userInput) == "right" then
  553.   turtle.turnRight()
  554.   print("Turning right one time..")
  555.   sleep(1.5)
  556.   rMenu()
  557.   else
  558.   print("Unkown command")
  559.   sleep(1)
  560.   rMenu()
  561.    end
  562. end
  563.  
  564.   function rMenu()
  565.     term.clear()
  566.     menu()
  567.     end
  568.  
  569.  
  570.   function turnCheck()
  571.      turtle.select(1)
  572.          turtle.compare(1)
  573.          if turtle.compare(1) == true then
  574.          print("Tree growth detected!")
  575.          chopTree()
  576.          end
  577.          sleep(8)
  578.          turtle.turnRight()
  579.          turtle.select(1)
  580.          turtle.compare(1)
  581.          if turtle.compare(1) == true then
  582.          print("Tree growth detected!")
  583.          chopTree()
  584.          end
  585.          sleep(8)
  586.          turtle.turnRight()
  587.          turtle.select(1)
  588.          turtle.compare(1)
  589.          if turtle.compare(1) == true then
  590.          print("Tree growth detected!")
  591.          chopTree()
  592.          end
  593.      sleep(8)    
  594.          turtle.turnRight()
  595.          turtle.select(1)
  596.          turtle.compare(1)
  597.          if turtle.compare(1) == true then
  598.          print("Tree growth detected!")
  599.          chopTree()
  600.          end
  601.          sleep(8)
  602.          turtle.turnRight()
  603.          status()
  604.    end  
  605.          
  606.          
  607.  
  608.   function checkGrowth()
  609.   print("Make sure there is one log of the  in the first slot, and at least 2 saplings in the third slot.")
  610.   print("Press any key to continue...")
  611.   local key = os.pullEvent("key")
  612.   if key then
  613.   turtle.getItemCount(1)
  614.   turtle.getItemCount(3)
  615.   if turtle.getItemCount(1) == 1 and turtle.getItemCount(3) > 1 then
  616.   print("Initiating chopping program..")
  617.  
  618.  while true do
  619.    turnCheck()
  620.   end
  621.   else
  622.   print("Not enough/too many resources")
  623.   sleep(2)
  624.   rCheckGrowth()
  625.   end
  626.   end
  627.  end
  628.  
  629.   function rCheckGrowth()
  630.   term.clear()
  631.   term.setCursorPos(1,1)
  632.   checkGrowth()
  633.   end
  634.  
  635.   menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement