UNOBTANIUM

uwc1.0.0

Apr 11th, 2013
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 45.68 KB | None | 0 0
  1. --MENU
  2. --VARIABLES
  3.  
  4. local version = "ULTIMATE WOOD CHOPPER BETA 0.9.0"
  5. local w,h = term.getSize()
  6. local select, distance, turtleslot = 1, 7, 1
  7. local running, chopping, usebonemeal = true, true, true
  8. local a, b, c, d, e, f, z = 6,7,8,9,10,11,h-2
  9. turtle.select(turtleslot)
  10.  
  11. --VARIABLES
  12. cancelTimer = 2
  13. bonemealTimer = 120
  14. bonemealFirstDelay = 0
  15. amountMaxWoodSlotBonemeal = 14
  16. amountMaxWoodSlotNoBonemeal = 7
  17. amountMinBonemeal = 8
  18. amountMinSaplings = 17
  19. amountMinFuelLevel = 1200
  20. amountFurnaceWoodBonemeal = 16
  21. amountFurnaceWoodNoBonemeal = 8
  22. debugMaxHeight = 55
  23.  
  24.  
  25. function loadVariables()
  26.  local file = fs.open("uwcvariables","r")
  27.  cancelTimer = file.readLine()
  28.  bonemealTimer = file.readLine()
  29.  bonemealFirstDelay = file.readLine()
  30.  amountMaxWoodSlotBonemeal = file.readLine()
  31.  amountMaxWoodSlotNoBonemeal = file.readLine()
  32.  amountMinBonemeal = file.readLine()
  33.  amountMinSaplings = file.readLine()
  34.  amountMinFuelLevel = file.readLine()
  35.  amountFurnaceWoodBonemeal = file.readLine()
  36.  amountFurnaceWoodNoBonemeal = file.readLine()
  37.  debugMaxHeight = file.readLine()
  38.  file.close()
  39. end
  40.  
  41. function saveVariables()
  42.  if fs.exists("uwcvariables") then
  43.   fs.delete("uwcvariables")
  44.  end
  45.  sleep(0.5)
  46.  local file = fs.open("uwcvariables","w")
  47.  file.writeLine(cancelTimer)
  48.  file.writeLine(bonemealTimer)
  49.  file.writeLine(bonemealFirstDelay)
  50.  file.writeLine(amountMaxWoodSlotBonemeal)
  51.  file.writeLine(amountMaxWoodSlotNoBonemeal)
  52.  file.writeLine(amountMinBonemeal)
  53.  file.writeLine(amountMinSaplings)
  54.  file.writeLine(amountMinFuelLevel)
  55.  file.writeLine(amountFurnaceWoodBonemeal)
  56.  file.writeLine(amountFurnaceWoodNoBonemeal)
  57.  file.writeLine(debugMaxHeight)
  58.  file.close()
  59. end
  60.  
  61. if fs.exists("uwcvariables") then
  62.  loadVariables()
  63. else
  64.  saveVariables()
  65. end
  66.  
  67.  
  68. --PRINT
  69.  
  70. local function printCentered(str, ypos)
  71.  term.setCursorPos(w/2 - #str/2, ypos)
  72.  term.write(str)
  73. end
  74.  
  75. local function printRight(str, ypos)
  76.  term.setCursorPos(w-#str, ypos)
  77.  term.write(str)
  78. end
  79.  
  80. function clearScreen()
  81.  term.clear()
  82.  term.setCursorPos(1,1)
  83.  term.clear()
  84. end
  85.  
  86. function drawHeader(title, line)
  87.  printCentered(title, line)
  88.  printCentered(string.rep("-", w), line+1)
  89. end
  90.  
  91. function drawCopyright()
  92.  printRight("by UNOBTANIUM", h)
  93. end
  94.  
  95. --MENUS
  96.  
  97. function drawMenuMain()
  98.  drawCopyright()
  99.  drawHeader(version, 1)
  100.  if select == 1 then
  101.   printCentered(">> Chop <<", a)
  102.  else
  103.   printCentered("Chop", a)
  104.  end
  105.  if select == 2 then
  106.   printCentered(">> Turtle Interactions <<", b)
  107.  else
  108.   printCentered("Turtle Interactions", b)
  109.  end
  110.  if select == 3 then
  111.   printCentered(">> Build and Expand <<", c)
  112.  else
  113.   printCentered("Build and Expand", c)
  114.  end
  115.  if select == 4 then
  116.   printCentered(">> Help <<", d)
  117.  else
  118.   printCentered("Help", d)
  119.  end
  120.  if select == 5 then
  121.   printCentered("> Credits <", e)
  122.  else
  123.   printCentered("Credits", e)
  124.  end
  125.  if select == 6 then
  126.   printCentered("> Quit <", 11)
  127.  else
  128.   printCentered("Quit", 11)
  129.  end
  130. end
  131.  
  132. function drawMenuFarm()
  133.  drawHeader(version, 1)
  134.  
  135.  if select == 1 then
  136.   printCentered(">> Farm <<", a)
  137.  else
  138.   printCentered("Farm", a)
  139.  end
  140.  if select == 2 then
  141.   printCentered(">> Single Tree <<", b)
  142.  else
  143.   printCentered("Single Tree",b)
  144.  end
  145.  if select == 3 then
  146.   printCentered("> Back <", z)
  147.  else
  148.   printCentered("Back", z)
  149.  end
  150. end
  151.  
  152. function drawMenuChop()
  153.  drawHeader(version, 1)
  154.  drawHeader("FARM", 3)
  155.  
  156.  if select == 1 then
  157.   printCentered("> Standard Farm <", a)
  158.  else
  159.   printCentered("Standard Farm", a)
  160.  end
  161.  if select == 2 then
  162.   printCentered("> Expanded Farm <", b)
  163.  else
  164.   printCentered("Expanded Farm", b)
  165.  end
  166.  if select == 3 then
  167.   printCentered("> Standard Farm without bonemeal <", c)
  168.  else
  169.   printCentered("Standard Farm without bonemeal", c)
  170.  end
  171.  if select == 4 then
  172.   printCentered("> Expanded Farm without bonemeal <", d)
  173.  else
  174.   printCentered("Expanded Farm without bonemeal", d)
  175.  end
  176.  if select == 5 then
  177.   printCentered("> Variables <", e)
  178.  else
  179.   printCentered("Variables", e)
  180.  end
  181.  
  182.  if select == 6 then
  183.   printCentered("> Back <", z)
  184.  else
  185.   printCentered("Back", z)
  186.  end
  187. end
  188.  
  189. function drawMenuBuild()
  190.  drawHeader(version, 1)
  191.  drawHeader("BUILD AND EXPAND", 3)
  192.  printCentered("Does the Turtle has all materials?",10)
  193.  
  194.  if select == 1 then
  195.   printCentered("> Set up a farm <", a)
  196.  else
  197.   printCentered("Set up a farm", a)
  198.  end
  199.  if select == 2 then
  200.   printCentered("> Expand the farm <", b)
  201.  else
  202.   printCentered("Expand the farm", b)
  203.  end
  204.  if select == 3 then
  205.   printCentered("> Add more chests <", c)
  206.  else
  207.   printCentered("Add more chests", c)
  208.  end
  209.  if select == 4 then
  210.   printCentered("> Back <", 12)
  211.  else
  212.   printCentered("Back", 12)
  213.  end
  214. end
  215.  
  216. function drawMenuHelpDebug()
  217.  drawHeader(version, 1)
  218.  drawHeader("DEBUG", 3)
  219.  
  220.  if select == 1 then
  221.   printCentered("> Standard Farm <", a)
  222.  else
  223.   printCentered("Standard Farm", a)
  224.  end
  225.  if select == 2 then
  226.   printCentered("> Expanded Farm <", b)
  227.  else
  228.   printCentered("Expanded Farm", b)
  229.  end
  230.  if select == 3 then
  231.   printCentered("> Back <", z)
  232.  else
  233.   printCentered("Back", z)
  234.  end
  235. end
  236.  
  237. function drawMenuHelpPrograms()
  238.  drawHeader(version, 1)
  239.  drawHeader("HELP PROGRAMS", 3)
  240.  
  241.  
  242.  if select == 1 then
  243.   printCentered("> Position <", a)
  244.  else
  245.   printCentered("Position", a)
  246.  end
  247.  if select == 2 then
  248.   printCentered("> Dig needed space <", b)
  249.  else
  250.   printCentered("Dig needed space", b)
  251.  end
  252.  if select == 3 then
  253.   printCentered(">> Debug <<", c)
  254.  else
  255.   printCentered("Debug", c)
  256.  end
  257.  if select == 4 then
  258.   printCentered("> Move Down <", d)
  259.  else
  260.   printCentered("Move Down", d)
  261.  end
  262.  
  263.  if select == 5 then
  264.   printCentered("> Back <", z)
  265.  else
  266.   printCentered("Back", z)
  267.  end
  268. end
  269.  
  270. function drawMenuHelp()
  271.  drawHeader(version, 1)
  272.  drawHeader("HELP", 3)
  273.  
  274.  if select == 1 then
  275.   printCentered(">> Help Programs <<", a)
  276.  else
  277.   printCentered("Help Programs", a)
  278.  end
  279.  if select == 2 then
  280.   printCentered(">> Help Interface <<", b)
  281.  else
  282.   printCentered("Help Interface", b)
  283.  end
  284.  if select == 3 then
  285.   printCentered("> Back <", z)
  286.  else
  287.   printCentered("Back", z)
  288.  end
  289. end
  290.  
  291. function drawMenuSingleTreeChop()
  292.  drawHeader(version, 1)
  293.  drawHeader("SINGLE TREE CHOP", 3)
  294.  
  295.  if select == 1 then
  296.   printCentered("> General 1x1 Tree <", a)
  297.  else
  298.   printCentered("General 1x1 Tree", a)
  299.  end
  300.  if select == 2 then
  301.   printCentered("> General 2x2 Tree <", b)
  302.  else
  303.   printCentered("General 2x2 Tree", b)
  304.  end
  305.  if select == 3 then
  306.   printCentered("> Back <", z)
  307.  else
  308.   printCentered("Back", z)
  309.  end
  310. end
  311.  
  312. function drawMenuTurtleInteractions()
  313.  drawHeader(version, 1)
  314.  drawHeader("TURTLE INTERACTIONS", 3)
  315.  
  316.  if select == 1 then
  317.   printCentered(">> Movement <<", a)
  318.  else
  319.   printCentered("Movement", a)
  320.  end
  321.  if select == 2 then
  322.   printCentered(">> Actions <<", b)
  323.  else
  324.   printCentered("Actions", b)
  325.  end
  326.  if select == 3 then
  327.   printCentered("> Back <", z)
  328.  else
  329.   printCentered("Back", z)
  330.  end
  331. end
  332.  
  333. function drawMenuTurtleMovement()
  334.  drawHeader(version, 1)
  335.  drawHeader("TURTLE MOVEMENT", 3)
  336.  
  337.  if select == 1 then
  338.   printCentered("> Forward <", a)
  339.  else
  340.   printCentered("Forward", a)
  341.  end
  342.  if select == 2 then
  343.   printCentered("> Back <", b)
  344.  else
  345.   printCentered("Back", b)
  346.  end
  347.  if select == 3 then
  348.   printCentered("> Up <", c)
  349.  else
  350.   printCentered("Up", c)
  351.  end
  352.  if select == 4 then
  353.   printCentered("> Down <", d)
  354.  else
  355.   printCentered("Down", d)
  356.  end
  357.  if select == 5 then
  358.   printCentered("> Turn Left <", e)
  359.  else
  360.   printCentered("Turn Left", e)
  361.  end
  362.  if select == 6 then
  363.   printCentered("> Turn Right <", f)
  364.  else
  365.   printCentered("Turn Right", f)
  366.  end
  367.  if select == 7 then
  368.   printCentered("> Back <", 12)
  369.  else
  370.   printCentered("Back", 12)
  371.  end
  372. end
  373.  
  374. function drawMenuTurtleActions()
  375.  drawHeader(version, 1)
  376.  drawHeader("TURTLE ACTIONS", 3)
  377.  
  378.  if select == 1 then
  379.   printCentered("> Refuel <", a)
  380.  else
  381.   printCentered("Refuel", a)
  382.  end
  383.  if select == 2 then
  384.   printCentered(">> Dig <<", b)
  385.  else
  386.   printCentered("Dig", b)
  387.  end
  388.  if select == 3 then
  389.   printCentered("> Select <", c)
  390.  else
  391.   printCentered("Select", c)
  392.  end
  393.  if select == 4 then
  394.   printCentered("> Back <", z)
  395.  else
  396.   printCentered("Back", z)
  397.  end
  398. end
  399.  
  400. function drawMenuTurtleDig()
  401.  drawHeader(version, 1)
  402.  drawHeader("TURTLE DIG", 3)
  403.  
  404.  if select == 1 then
  405.   printCentered("> Up <", a)
  406.  else
  407.   printCentered("Up", a)
  408.  end
  409.  if select == 2 then
  410.   printCentered("> Front <", b)
  411.  else
  412.   printCentered("Front", b)
  413.  end
  414.  if select == 3 then
  415.   printCentered("> Down <", c)
  416.  else
  417.   printCentered("Down", c)
  418.  end
  419.  if select == 4 then
  420.   printCentered("> Back <", z)
  421.  else
  422.   printCentered("Back", z)
  423.  end
  424. end
  425.  
  426. function drawMenuCredits()
  427.  drawHeader(version,1)
  428.  printCentered("all nicknames from the CC forums!!",3)
  429.  printCentered("- IDEA, CODEING & PUBLISHER -",5)
  430.  printCentered("unobtanium",6)
  431.  printCentered("- HELPING WITH CODING -",8)
  432.  printCentered("theoriginalbit, Mtdj2, NitrogenFingers", 9)
  433.  printCentered("- SPECIAL THANKS GOES TO -",11)
  434.  printCentered("Hoppingmad9, xInDiGo, Seleck",12)
  435.  printCentered("Permutation, PhilHibbs, DavEdward ",13)
  436.  read()
  437.  clearScreen()
  438.  drawHeader(version,1)
  439.  printCentered("- MENTIONABLES -",3)
  440.  printCentered("HotGirlEAN, snoxx, steel_toed_boot,",4)
  441.  printCentered("Zagi, Kylun, Kravyn, PhaxeNor, ughzug",5)
  442.  printCentered("sjkeegs, atlas, Minithra, TheFan",6)
  443.  printCentered("grumpysmurf, Quickslash78, lewanator1",7)
  444.  printCentered("behedwin, TESTimonSHOOTER",8)
  445.  printCentered("Kevironi, Fuzzlewhumper, Bigdavie",9)
  446.  printCentered("Viproz, Bigjimmy12, bomanski, punchin",10)
  447.  printCentered("oxgon, ahwtx, zilvar2k11",11)
  448.  printCentered("The_Ianator, Coolkrieger3", 12)
  449.  read()
  450.  clearScreen()
  451.  drawHeader(version,1)
  452.  printCentered(version,1)
  453.  printCentered("And last but not least",6)
  454.  printCentered("You, the users and players :D",7)
  455.  printCentered("Thank you everybody!!!", 10)
  456.  read()
  457. end
  458.  
  459. --MENUSTATE
  460.  
  461. local menustate = "main"
  462.  
  463. local mopt = {
  464.  ["main"] = {
  465.   options = {"mainchopprograms", "turtleinteractions" ,"buildprograms", "help", "credits","quit"},
  466.   draw = drawMenuMain
  467.  },
  468.  
  469.  ["mainchopprograms"] = {
  470.   options = {"farmprograms", "singletreechopprograms", "main"},
  471.   draw = drawMenuFarm
  472.  },
  473.  ["farmprograms"] = {
  474.   options = {"standard", "expanded", "standardnobonemeal", "expandednobonemeal", "variables", "mainchopprograms"},
  475.   draw = drawMenuChop
  476.  },
  477.  ["buildprograms"] = {
  478.   options = {"build","expand", "expandchests", "main"},
  479.   draw = drawMenuBuild
  480.  },
  481.  ["singletreechopprograms"] = {
  482.   options = {"onebyone", "twobytwo", "mainchopprograms"},
  483.   draw = drawMenuSingleTreeChop
  484.  },
  485.  ["help"] = {
  486.   options = {"helpprograms", "helpinterface", "main"},
  487.   draw = drawMenuHelp
  488.  },
  489.  ["helpprograms"] = {
  490.   options = {"position", "digSpace", "helpdebugprograms", "godown", "help"},
  491.   draw = drawMenuHelpPrograms
  492.  },
  493.  ["helpdebugprograms"] = {
  494.   options = {"debugstandard", "debugexpanded","helpprograms"},
  495.   draw = drawMenuHelpDebug
  496.  },
  497.  
  498.  ["turtleinteractions"] = {
  499.   options = {"turtlemovement", "turtleactions", "main"},
  500.   draw = drawMenuTurtleInteractions
  501.  },
  502.  ["turtlemovement"] = {
  503.   options = {"forward", "back", "up", "down", "left", "right" , "turtleinteractions"},
  504.   draw = drawMenuTurtleMovement
  505.  },
  506.  ["turtleactions"] = {
  507.   options = {"refuel", "turtledig", "select", "turtleinteractions"},
  508.   draw = drawMenuTurtleActions
  509.  },
  510.  ["turtledig"] = {
  511.   options = {"digup", "digfront", "digdown", "turtleactions"},
  512.   draw = drawMenuTurtleDig
  513.  }
  514. }
  515.  
  516.  
  517. --RUN MENU
  518.  
  519. function runMenu()
  520.  while true do
  521.   clearScreen()
  522.   mopt[menustate].draw()
  523.  
  524.   local id, key = os.pullEvent("key")
  525.   if key == 200  or key == 17 then
  526.    select = select-1
  527.   end
  528.   if key == 208 or key == 31 then
  529.    select = select+1
  530.   end
  531.   if select == 0 then
  532.    select = #mopt[menustate].options
  533.   end
  534.   if select > #mopt[menustate].options then
  535.    select = 1
  536.   end
  537.   if key == 65 or key == 30 then
  538.    if not menustate == "quit" then
  539.     select = #mopt[menustate].options
  540.     menustate = mopt[menustate].options[select]
  541.     select = 1
  542.    else
  543.     clearScreen()
  544.     running = false
  545.     break
  546.    end
  547.   end
  548.   clearScreen()
  549.   if key == 28 or key == 32 then
  550.    if mopt[menustate].options[select] == "quit" then
  551.     running = false
  552.     break
  553.    elseif mopt[menustate].options[select] == "credits" then
  554.     UWCeasyfarm()
  555.     --drawMenuCredits()
  556.    elseif mopt[menustate].options[select] == "standard" then
  557.     usebonemeal = true
  558.     FWCchop()
  559.    elseif mopt[menustate].options[select] == "expanded" then
  560.     FWCchop2()
  561.     usebonemeal = true
  562.    elseif mopt[menustate].options[select] == "debugstandard" then
  563.     FWCdebugstandard()
  564.    elseif mopt[menustate].options[select] == "debugexpanded" then
  565.     FWCdebugexpanded()
  566.    elseif mopt[menustate].options[select] == "build" then
  567.     FWCbuild()
  568.    elseif mopt[menustate].options[select] == "expand" then
  569.     FWCexpand()
  570.    elseif mopt[menustate].options[select] == "helpinterface" then
  571.     FWChelp()
  572.    elseif mopt[menustate].options[select] == "position" then
  573.     FWCposition()
  574.    elseif mopt[menustate].options[select] == "expandchests" then
  575.     FWCexpandchests()
  576.    elseif mopt[menustate].options[select] == "onebyone" then
  577.     FWConebyone()
  578.    elseif mopt[menustate].options[select] == "twobytwo" then
  579.     FWCtwobytwo()
  580.    elseif mopt[menustate].options[select] == "standardnobonemeal" then
  581.     FWCchop()
  582.     usebonemeal = false
  583.    elseif mopt[menustate].options[select] == "expandednobonemeal" then
  584.     FWCchop2()
  585.     usebonemeal = false
  586.    elseif mopt[menustate].options[select] == "digSpace" then
  587.     FWCdigSpace()
  588.    elseif mopt[menustate].options[select] == "forward" then
  589.     turtle.forward()
  590.    elseif mopt[menustate].options[select] == "back" then
  591.     turtle.back()
  592.    elseif mopt[menustate].options[select] == "up" then
  593.     turtle.up()
  594.    elseif mopt[menustate].options[select] == "down" then
  595.     turtle.down()
  596.    elseif mopt[menustate].options[select] == "left" then
  597.     turtle.turnLeft()
  598.    elseif mopt[menustate].options[select] == "right" then
  599.     turtle.turnRight()
  600.    elseif mopt[menustate].options[select] == "refuel" then
  601.     turtle.refuel(1)
  602.    elseif mopt[menustate].options[select] == "select" then
  603.     turtleslot = turtleslot + 1
  604.     if turtleslot > 16 then turtleslot = 1 end
  605.     turtle.select(turtleslot)
  606.    elseif mopt[menustate].options[select] == "digup" then
  607.     turtle.digUp()
  608.    elseif mopt[menustate].options[select] == "digfront" then
  609.     turtle.dig()
  610.    elseif mopt[menustate].options[select] == "digdown" then
  611.     turtle.digDown()
  612.    elseif mopt[menustate].options[select] == "godown" then
  613.     UWCgodown()
  614.    elseif mopt[menustate].options[select] == "variables" then
  615.     UWCvariables()
  616.    elseif true then
  617.     menustate = mopt[menustate].options[select]
  618.     select = 1
  619.    end
  620.   end
  621.  end
  622. end
  623.  
  624.  
  625.  
  626.  
  627.  
  628. --ULTIMATE WOOD CHOPPER PROGRAMS
  629. --VARIABLES
  630. local dirtexpand, pipeexpand, obsidianpipeexpand, blockslot, coal, chest, furnace, dirt, pipe, ironpipe, goldpipe, obsidianpipe, woodenpipe, engine, lever, bonemeal, stone1, stone2, stone3, sapling, fuel = 2,3,4,5,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,3
  631.  
  632. --MOVE FUNCTIONS
  633.  
  634. function forward()
  635.  while not turtle.forward() do end
  636. end
  637.  
  638. function back()
  639.  while not turtle.back() do end
  640. end
  641.  
  642. function up()
  643.  while not turtle.up() do end
  644. end
  645.  
  646. function down()
  647.  while not turtle.down() do end
  648. end
  649.  
  650. --MAIN CHOP PROGRAM FUNCTIONS
  651.  
  652. local function refreshItemStack(i)
  653.  turtle.select(3)
  654.  turtle.suck()
  655.  turtle.select(i)
  656.  turtle.drop()
  657.  turtle.select(3)
  658.  turtle.drop()
  659.  turtle.select(i)
  660.  turtle.suck()
  661.  if turtle.getItemCount(3) > 0 then
  662.   print("!!!!!!!!!")
  663.   print("The coal or sapling chest is full! Please take out some stacks, otherwise you lose items! The turtle will drop them!")
  664.   print("!!!!!!!!!")
  665.   turtle.select(3)
  666.   turtle.dropDown()
  667.  end
  668. end
  669.  
  670. local function moveForward(j)
  671.  for i = 1,j do
  672.   forward()
  673.  end
  674. end
  675.  
  676. local function getCoal()
  677.  local delay = os.startTimer(cancelTimer)
  678.  print("Taking coal out of the chest!")
  679.  print("If nothing happens the chest has too less materials!")
  680.  print("Press Enter to terminate process!")
  681.  
  682.  while turtle.getFuelLevel() < amountMinFuelLevel do
  683.   event = { os.pullEvent() }
  684.   if event[1] == "timer" and event[2] == delay then
  685.    turtle.select(16)
  686.    turtle.suck()
  687.    if turtle.getItemCount(16) > 0 then  
  688.     turtle.refuel(math.ceil((amountMinFuelLevel - turtle.getFuelLevel())/80))
  689.     turtle.drop()
  690.     if turtle.getFuelLevel() < amountMinFuelLevel then
  691.      delay = os.startTimer(2)
  692.     end
  693.    else
  694.     delay = os.startTimer(cancelTimer)
  695.    end
  696.   elseif event[1] == "key" and event[2] == 28 then
  697.    print("Terminated by User!")
  698.    clearScreen()
  699.    os.shutdown()
  700.   end
  701.  end
  702.  print("Succesful!")
  703. end
  704.  
  705. local function getSaplings()
  706.  local taking = true
  707.  local delay = os.startTimer(cancelTimer)
  708.  print("Taking saplings out of the chest!")
  709.  print("If nothing happens the chest has too less materials!")
  710.  print("Press Enter to terminate process!")
  711.  
  712.  while taking == true do
  713.   event = { os.pullEvent() }
  714.   if event[1] == "timer" and event[2] == delay then
  715.    refreshItemStack(1)
  716.    if turtle.getItemCount(1) < amountMinSaplings then
  717.     delay = os.startTimer(cancelTimer)
  718.    else
  719.     taking = false
  720.    end
  721.   elseif event[1] == "key" and event[2] == 28 then
  722.    print("Terminated by User!")
  723.    turtle.turnRight()
  724.    forward()
  725.    turtle.turnRight()
  726.    clearScreen()
  727.    os.shutdown()
  728.   end
  729.  end
  730.  print("Succesful!")
  731. end
  732.  
  733. local function getBonemeal()
  734.  local taking = true
  735.  local delay = os.startTimer(cancelTimer)
  736.  print("Taking bonemeal out of the chest!")
  737.  print("If nothing happens the chest has too less materials!")
  738.  print("Press Enter to terminate process!")
  739.  
  740.  while taking == true do
  741.   event = { os.pullEvent() }
  742.   if usebonemeal == true then
  743.    if event[1] == "timer" and event[2] == delay then
  744.     turtle.select(3)
  745.     turtle.suckUp()
  746.     turtle.select(2)
  747.     turtle.dropUp()
  748.     turtle.select(3)
  749.     turtle.dropUp()
  750.     turtle.select(2)
  751.     turtle.suckUp()
  752.     if turtle.getItemCount(3) > 0 then
  753.      print("!!!!!!!!!")
  754.      print("The bonemeal chest is full! Please take out some stacks, otherwise you lose items! The turtle will drop them!")
  755.      print("!!!!!!!!!")
  756.      turtle.select(3)
  757.      turtle.dropDown()
  758.     end
  759.     if turtle.getItemCount(2) < amountMinBonemeal then
  760.      delay = os.startTimer(cancelTimer)
  761.     else
  762.      taking = false
  763.     end
  764.    elseif event[1] == "key" and event[2] == 28 then
  765.     print("Terminated by User!")
  766.     turtle.turnRight()
  767.     forward()
  768.     turtle.turnRight()
  769.     clearScreen()
  770.     os.shutdown()
  771.    end
  772.   else
  773.    turtle.select(2)
  774.    turtle.dropUp()
  775.    taking = false
  776.   end
  777.  end
  778.  print("Successful!")
  779. end
  780.  
  781. local function storeWood()
  782.  print("Storing wood in the chests!")
  783.  chestfull = true
  784.  while chestfull == true do
  785.   if usebonemeal == true then
  786.    for i=3,16 do
  787.     if turtle.getItemCount(i) > 0 then
  788.      turtle.select(i)
  789.      chestfull = turtle.drop()
  790.     end
  791.    end
  792.   else
  793.    for i=2,16 do
  794.     if turtle.getItemCount(i) > 0 then
  795.      turtle.select(i)
  796.      chestfull = turtle.drop()
  797.     end
  798.    end
  799.   end
  800.  
  801.   chestfull = not chestfull
  802.    
  803.   if chestfull == true and turtle.detectUp() == true then
  804.    print("Wood! Wood everywhere!!!")
  805.    print("Your wood chests are full!")
  806.    print("Try to add more vertical chests or take wood out of them.")
  807.    print("")
  808.    chopping = false
  809.    while turtle.detectDown() == false do
  810.     down()
  811.    end
  812.    turtle.turnRight()
  813.      
  814.   end
  815.  
  816.   if chestfull == true and turtle.detectUp() == false then
  817.    up()
  818.    print("This Chest is full!")
  819.   end
  820.  
  821.  end
  822.  
  823.  while turtle.detectDown() == false do
  824.  down()
  825.  end
  826.  
  827.  print("Successful stored the wood!")
  828.  print("")
  829. end
  830.  
  831. local function plantTree()
  832.  print("Planting saplings!")
  833.  moveForward(2)
  834.  turtle.turnRight()
  835.  turtle.select(1)
  836.  turtle.place()
  837.  turtle.turnLeft()
  838.  back()
  839.  turtle.place()
  840.  turtle.turnRight()
  841.  turtle.place()
  842.  turtle.turnLeft()
  843.  back()
  844.  turtle.place()
  845.  if usebonemeal == true then
  846.   while turtle.compare() == true and turtle.getItemCount(2) > 2 do
  847.    print("Fertilizing the tree with bonemeal!")
  848.    turtle.select(2)
  849.    turtle.place()
  850.    turtle.select(1)
  851.    sleep(bonemealFirstDelay)
  852.    if turtle.compare() == true then
  853.     print("Tree didnt grown with bonemeal!")
  854.     print("Will try again in two minutes...")
  855.     sleep(bonemealTimer)
  856.    end
  857.   end
  858.  else
  859.   print("Waiting for the tree to grow!")
  860.   print("Get some coffee this may take a while ;D")
  861.   while turtle.compare() == true do
  862.    os.sleep(5)
  863.   end
  864.  end
  865.  print("Successful planted new tree!")
  866.  print("")
  867. end
  868.  
  869. local function getMaterials()
  870.  turtle.turnRight()
  871.  turtle.turnRight()
  872.  moveForward(distance)
  873.  
  874.  turtle.select(3)
  875.  if usebonemeal then
  876.   turtle.dropDown(amountFurnaceWoodBonemeal)
  877.  else
  878.   turtle.dropDown(amountFurnaceWoodNoBonemeal)
  879.  end
  880.  storeWood()
  881.  
  882.  turtle.turnRight()
  883.    
  884.  if redstone.getInput("back") == false then
  885.   print("Shutdown by redstone signal!")
  886.   chopping = false
  887.  else
  888.   getCoal()
  889.   turtle.turnRight()
  890.   turtle.forward()
  891.   turtle.turnRight()  
  892.   getSaplings()
  893.   getBonemeal()
  894.   turtle.turnLeft()
  895.   moveForward(distance-1)
  896.  end
  897. end
  898.  
  899. local function cutWood()
  900.  print("Chopping down the tree!")
  901.  local height = 0
  902.  turtle.select(1)
  903.  turtle.dig()
  904.  forward()
  905.  turtle.dig()
  906.  while turtle.detectUp() do
  907.   turtle.digUp()
  908.   up()
  909.   turtle.dig()
  910.   height = height + 1
  911.  end
  912.  print("Reached the top of the tree!")
  913.  turtle.turnRight()
  914.  turtle.dig()
  915.  forward()
  916.  turtle.turnLeft()
  917.  turtle.dig()
  918.  while height > 0 do
  919.   turtle.digDown()
  920.   down()
  921.   turtle.dig()
  922.   height = height - 1
  923.  end
  924.  print("Successful chopped the tree!")
  925.  print("")
  926.  back()
  927.  turtle.turnLeft()
  928.  forward()
  929.  turtle.turnRight()
  930. end
  931.  
  932. function chop()
  933.  if redstone.getInput("back") == true then
  934.   print("Starting the Fir Wood Chooper program!")
  935.   getCoal()
  936.   if turtle.getItemCount(3) > 0 or turtle.getItemCount(16) > 0 then
  937.    turtle.turnLeft()
  938.    storeWood()
  939.    turtle.turnRight()
  940.   end
  941.   turtle.turnRight()
  942.   forward()
  943.   turtle.turnRight()
  944.   if turtle.getItemCount(1) < amountMinSaplings then
  945.    getSaplings()
  946.   end
  947.   if turtle.getItemCount(2) < amountMinBonemeal and usebonemeal == true then
  948.    getBonemeal()
  949.   end
  950.   if turtle.getItemCount(2) > 0 and usebonemeal == false then
  951.    turtle.select(2)
  952.    turtle.dropUp()
  953.   end
  954.   turtle.turnRight()
  955.   forward()
  956.   turtle.turnRight()
  957.   turtle.turnRight()
  958.   moveForward(distance)
  959.  
  960.   while chopping == true do
  961.    local needMaterials = false
  962.    if turtle.getFuelLevel() < 200 then
  963.     needMaterials = true
  964.     print("Have to refuel!")
  965.    end
  966.    if turtle.getItemCount(1) < amountMinSaplings then
  967.     needMaterials = true
  968.     print("Need more Saplings!")
  969.    end
  970.    if turtle.getItemCount(2) < amountMinBonemeal and usebonemeal then
  971.     needMaterials = true
  972.     print("Need more bonemeal!")
  973.    end
  974.    if usebonemeal and turtle.getItemCount(amountMaxWoodSlotBonemeal) > 0 then
  975.     needMaterials = true
  976.     print("Inventory almost full with wood!")
  977.    end
  978.    if usebonemeal == false and turtle.getItemCount(amountMaxWoodSlotNoBonemeal) > 0 then
  979.     needMaterials = true
  980.     print("Enough wood harvested!")
  981.    end
  982.    if needMaterials == true then
  983.     getMaterials()
  984.    end
  985.    if chopping == true then
  986.     plantTree()
  987.     cutWood()
  988.    end
  989.   end
  990.  else
  991.   print("No redstone signal, no wood!")
  992.   print("Be sure the Turtle is facing the coal chest and stays above the furnace!")
  993.   print("The redstone signal has to be in the back of the Turtle!")
  994.  end
  995.  print("Press Enter to get back into the menu!")
  996.  read()
  997.  chopping = true
  998. end
  999.  
  1000. --FWCchop 11111111111111111111111
  1001.  
  1002. function FWCchop()
  1003.  distance = 7
  1004.  chop()
  1005. end
  1006.  
  1007.  
  1008. --FWCchop2 2222222222222222222222
  1009.  
  1010. function FWCchop2()
  1011.  distance = 9
  1012.  chop()
  1013. end
  1014.  
  1015. --MAIN DEBUG FUNCTIONS
  1016.  
  1017. local function debugTree()
  1018.  local height = 0
  1019.  turtle.select(1)
  1020.  turtle.dig()
  1021.  forward()
  1022.  turtle.dig()
  1023.  while not turtle.detectUp() and height < debugMaxHeight do
  1024.   turtle.up()
  1025.   height = height + 1
  1026.  end
  1027.  turtle.dig()
  1028.  while turtle.detectUp() do
  1029.   turtle.digUp()
  1030.   turtle.up()
  1031.   turtle.dig()
  1032.   height = height + 1
  1033.  end
  1034.  turtle.turnRight()
  1035.  turtle.dig()
  1036.  forward()
  1037.  turtle.turnLeft()
  1038.  turtle.dig()
  1039.  while height > 0 do
  1040.   turtle.digDown()
  1041.   down()
  1042.   turtle.dig()
  1043.   height = height - 1
  1044.  end
  1045.  back()
  1046.  turtle.turnLeft()
  1047.  forward()
  1048.  turtle.turnLeft()
  1049. end
  1050.  
  1051. --FWCdebugstandard 33333333333333333333333333
  1052.  
  1053. function FWCdebugstandard()
  1054.  turtle.turnRight()
  1055.  moveForward(7)
  1056.  debugTree()
  1057.  moveForward(7)
  1058.  turtle.turnRight()
  1059.  print("Debug for standard farm finished!")
  1060.  print("Press Enter to get back into the menu!")
  1061.  read()
  1062. end
  1063.  
  1064. --FWCdebugexpand 44444444444444444444444444444
  1065.  
  1066. function FWCdebugexpanded()
  1067.  turtle.turnRight()
  1068.  moveForward(9)
  1069.  debugTree()
  1070.  moveForward(9)
  1071.  turtle.turnRight()
  1072.  print("Debug for expanded farm finished!")
  1073.  print("Press Enter to get back into the menu!")
  1074.  read()
  1075. end
  1076.  
  1077. --MAIN BUILD FUNCTIONS
  1078.  
  1079. local function dbp(j)
  1080.  for i=1,j do
  1081.   turtle.placeDown()
  1082.   turtle.back()
  1083.   turtle.place()
  1084.  end
  1085. end
  1086.  
  1087. local function fd(j)
  1088.  for i=1,j do
  1089.   turtle.forward()
  1090.   turtle.placeDown()
  1091.  end
  1092. end
  1093.  
  1094. local function bp(j)
  1095.  for i=1,j do
  1096.   turtle.back()
  1097.   turtle.place()
  1098.  end
  1099. end
  1100.  
  1101. local function lb()
  1102.  turtle.turnLeft()
  1103.  turtle.back()
  1104. end
  1105.  
  1106. --FWCbuild 55555555555555555555555555555555555
  1107.  
  1108. function FWCbuild()
  1109.  if turtle.detectDown() then
  1110.   print("There is a block underneath the turtle.")
  1111.   print("Be sure you have free space under the turtle.")
  1112.   print("Press Enter to get back to the menu.")
  1113.   read()
  1114.   return false
  1115.  end
  1116.  turtle.select(coal)
  1117.  turtle.refuel(fuel)
  1118.  turtle.select(stone1)
  1119.  moveForward(2)
  1120.  turtle.turnRight()
  1121.  forward()
  1122.  turtle.placeUp()
  1123.  dbp(1)
  1124.  turtle.placeUp()
  1125.  turtle.placeDown()
  1126.  back()
  1127.  turtle.placeUp()
  1128.  dbp(1)
  1129.  down()
  1130.  down()
  1131.  turtle.turnLeft()
  1132.  turtle.turnLeft()
  1133.  forward()
  1134.  
  1135.  dbp(4)
  1136.  turtle.select(stone1)
  1137.  bp(1)
  1138.  
  1139.  dbp(3)
  1140.  
  1141.  lb()
  1142.  dbp(2)
  1143.  bp(8)
  1144.  
  1145.  lb()
  1146.  bp(8)
  1147.  
  1148.  lb()
  1149.  bp(8)
  1150.  dbp(1)
  1151.  turtle.placeDown()
  1152.  turtle.turnLeft()
  1153.  bp(1)
  1154.  
  1155.  turtle.turnRight()
  1156.  turtle.turnRight()
  1157.  down()
  1158.  turtle.placeDown()
  1159.  fd(7)
  1160.  turtle.turnLeft()
  1161.  fd(1)
  1162.  turtle.turnLeft()
  1163.  turtle.select(stone3)
  1164.  fd(7)
  1165.  
  1166.  turtle.select(stone2)
  1167.  turtle.turnRight()
  1168.  up()
  1169.  for i = 1,4 do
  1170.   fd(8)
  1171.   turtle.turnRight()
  1172.   fd(1)
  1173.   turtle.turnRight()
  1174.   fd(7)
  1175.   if i < 4 then
  1176.    turtle.turnLeft()
  1177.    fd(1)
  1178.    turtle.turnLeft()
  1179.   end
  1180.  end
  1181.  
  1182.  turtle.select(stone3)
  1183.  up()
  1184.  up()
  1185.  turtle.turnRight()
  1186.  moveForward(3)
  1187.  turtle.turnRight()
  1188.  moveForward(2)
  1189.  turtle.select(dirt)
  1190.  fd(2)
  1191.  turtle.turnLeft()
  1192.  fd(1)
  1193.  turtle.turnLeft()
  1194.  fd(1)
  1195.  moveForward(7)
  1196.  
  1197.  turtle.select(stone1)
  1198.  turtle.placeDown()
  1199.  turtle.turnLeft()
  1200.  turtle.select(chest)
  1201.  turtle.place()
  1202.  turtle.select(sapling)
  1203.  turtle.drop()
  1204.  turtle.turnRight()
  1205.  turtle.select(chest)
  1206.  turtle.placeUp()
  1207.  turtle.select(bonemeal)
  1208.  turtle.dropUp()
  1209.  forward()
  1210.  turtle.select(chest)
  1211.  turtle.place()
  1212.  up()
  1213.  turtle.place()
  1214.  up()
  1215.  turtle.place()
  1216.  turtle.select(stone3)
  1217.  turtle.placeUp()
  1218.  
  1219.  down()
  1220.  down()
  1221.  down()
  1222.  turtle.turnRight()
  1223.  turtle.select(woodenpipe)
  1224.  turtle.place()
  1225.  turtle.turnLeft()
  1226.  down()
  1227.  turtle.select(furnace)
  1228.  turtle.placeUp()
  1229.  turtle.select(coal)
  1230.  turtle.dropUp(1)
  1231.  turtle.select(ironpipe)
  1232.  turtle.place()
  1233.  lb()
  1234.  turtle.select(pipe)
  1235.  turtle.place()
  1236.  turtle.turnLeft()
  1237.  back()
  1238.  turtle.select(goldpipe)
  1239.  turtle.place()
  1240.  up()
  1241.  up()
  1242.  turtle.select(chest)
  1243.  turtle.place()
  1244.  turtle.select(coal)
  1245.  turtle.drop(1)
  1246.  turtle.select(engine)
  1247.  turtle.placeDown()
  1248.  back()
  1249.  turtle.select(stone3)
  1250.  turtle.placeDown()
  1251.  lb()
  1252.  turtle.select(lever)
  1253.  turtle.place()
  1254.  back()
  1255.  turtle.turnRight()
  1256.  moveForward(2)
  1257.  down()
  1258.  turtle.select(pipe)
  1259.  turtle.place()
  1260.  down()
  1261.  turtle.place()
  1262.  down()
  1263.  moveForward(2)
  1264.  turtle.select(obsidianpipe)
  1265.  turtle.place()
  1266.  back()
  1267.  turtle.select(pipe)
  1268.  turtle.place()
  1269.  back()
  1270.  turtle.place()
  1271.  
  1272.  turtle.turnLeft()
  1273.  up()
  1274.  up()
  1275.  up()
  1276.  turtle.select(stone3)
  1277.  turtle.placeDown()
  1278.  forward()
  1279.  turtle.turnRight()
  1280.  turtle.turnRight()
  1281.  turtle.select(lever)
  1282.  turtle.place()
  1283.  turtle.turnRight()
  1284.  turtle.turnRight()
  1285.  
  1286.  print("Finally set up farm! Enjoy!")
  1287.  print("Flip the lever for the redstone engine.")
  1288.  print("")
  1289.  print("Press Enter to get back into the menu!")
  1290.  read()
  1291. end
  1292.  
  1293. --MAIN EXPAND FUNCTIONS
  1294.  
  1295. local function checkBlocks()
  1296.  if turtle.getItemCount(blockslot) == 0 and blockslot < 10 then
  1297.   blockslot = blockslot + 1
  1298.   turtle.select(blockslot)
  1299.  end
  1300. end
  1301.  
  1302. local function checkFuelexpand()
  1303.  print("The refueling needs around 8 coal!")
  1304.  while turtle.getFuelLevel() < 600 do
  1305.   print("Refueling!")
  1306.   turtle.select(coal)
  1307.   turtle.refuel(1)
  1308.  end
  1309. end
  1310.  
  1311.  
  1312. local function fde(j)
  1313.  for i=1,j do
  1314.   checkBlocks()
  1315.   forward()
  1316.   turtle.placeDown()
  1317.   checkBlocks()
  1318.  end
  1319. end
  1320.  
  1321. local function df(j)
  1322.  for i=1,j do
  1323.   turtle.dig()
  1324.   forward()
  1325.  end
  1326. end
  1327.  
  1328. local function dfd(j)
  1329.  for i=1,j do
  1330.   turtle.dig()
  1331.   forward()
  1332.   turtle.digDown()
  1333.  end
  1334. end
  1335.  
  1336. local function destroy()
  1337.  turtle.turnRight()
  1338.  moveForward(3)
  1339.  down()
  1340.  down()
  1341.  down()
  1342.  turtle.turnRight()
  1343.  turtle.select(obsidianpipeexpand)
  1344.  turtle.dig()
  1345.  forward()
  1346.  turtle.turnRight()
  1347.  turtle.select(pipeexpand)
  1348.  turtle.dig()
  1349.  turtle.select(blockslot)
  1350.  forward()
  1351.  turtle.turnLeft()
  1352.  df(4)
  1353.  turtle.turnLeft()
  1354.  up()
  1355.  dfd(2)
  1356.  df(9)
  1357.  turtle.turnLeft()
  1358.  df(9)
  1359.  turtle.turnLeft()
  1360.  df(8)
  1361.  dfd(2)
  1362.  down()
  1363.  down()
  1364.  turtle.turnLeft()
  1365.  df(8)
  1366.  turtle.turnLeft()
  1367.  df(1)
  1368.  turtle.turnLeft()
  1369.  df(7)
  1370.  turtle.turnRight()
  1371.  turtle.up()
  1372.  for i=1,4 do
  1373.   df(8)
  1374.   turtle.turnRight()
  1375.   df(1)
  1376.   turtle.turnRight()
  1377.   df(8)
  1378.   if i < 4 then
  1379.    turtle.turnLeft()
  1380.    forward()
  1381.    turtle.turnLeft()
  1382.   end
  1383.  end
  1384. end
  1385.  
  1386. local function layout()
  1387.  turtle.select(blockslot)
  1388.  forward()
  1389.  up()
  1390.  up()
  1391.  up()
  1392.  forward()
  1393.  turtle.turnLeft()
  1394.  back()
  1395.  back()
  1396.  turtle.placeDown()
  1397.  fde(7)
  1398.  for i=1,3 do
  1399.   turtle.turnLeft()
  1400.   fde(7)
  1401.   forward()
  1402.   down()
  1403.   turtle.placeDown()
  1404.   fde(1)
  1405.   up()
  1406.   back()
  1407.   turtle.placeDown()
  1408.   fde(9)
  1409.  end
  1410.  turtle.turnLeft()
  1411.  fde(6)
  1412.  turtle.turnLeft()
  1413.  forward()
  1414.  turtle.turnRight()
  1415.  moveForward(10)
  1416.  turtle.turnLeft()
  1417.  moveForward(8)
  1418. end
  1419.  
  1420. local function corners()
  1421.  turtle.down()
  1422.  for i=1,4 do
  1423.   fde(7)
  1424.   turtle.turnLeft()
  1425.   fde(6)
  1426.   turtle.turnLeft()
  1427.   forward()
  1428.   turtle.turnLeft()
  1429.   fde(5)
  1430.   turtle.turnRight()
  1431.   fde(4)
  1432.   turtle.turnRight()
  1433.   forward()
  1434.   turtle.turnRight()
  1435.   fde(3)
  1436.   turtle.turnLeft()
  1437.   fde(2)
  1438.   turtle.back()
  1439.   turtle.turnLeft()
  1440.   fde(1)
  1441.   turtle.turnRight()
  1442.   turtle.turnRight()
  1443.   moveForward(3)
  1444.   turtle.turnLeft()
  1445.   moveForward(5)
  1446.  end
  1447. end
  1448.  
  1449. local function lines(j)
  1450.  fde(j)
  1451.  back()
  1452.  turtle.turnLeft()
  1453.  fde(1)
  1454.  turtle.turnLeft()
  1455.  fde(j-2)
  1456.  if j > 4 then
  1457.   back()
  1458.   turtle.turnRight()
  1459.   fde(1)
  1460.   turtle.turnRight()
  1461.   lines(j-4)
  1462.  end
  1463. end
  1464.  
  1465. local function plateau()
  1466.  down()
  1467.  back()
  1468.  turtle.placeDown()
  1469.  turtle.turnLeft()
  1470.  lines(15)
  1471.  turtle.turnLeft()
  1472.  moveForward(8)
  1473.  turtle.turnLeft()
  1474.  moveForward(8)
  1475.  turtle.turnRight()
  1476.  turtle.turnRight()
  1477.  turtle.placeDown()
  1478.  lines(15)
  1479. end
  1480.  
  1481. local function pipeAndDirt()
  1482.  back()
  1483.  turtle.turnLeft()
  1484.  moveForward(9)
  1485.  turtle.select(dirtexpand)
  1486.  turtle.digUp()
  1487.  forward()
  1488.  turtle.digUp()
  1489.  turtle.turnRight()
  1490.  forward()
  1491.  turtle.digUp()
  1492.  turtle.turnRight()
  1493.  forward()
  1494.  turtle.digUp()
  1495.  forward()
  1496.  turtle.placeUp()
  1497.  forward()
  1498.  turtle.placeUp()
  1499.  turtle.turnRight()
  1500.  forward()
  1501.  turtle.placeUp()
  1502.  turtle.turnRight()
  1503.  forward()
  1504.  turtle.placeUp()
  1505.  turtle.digDown()
  1506.  down()
  1507.  turtle.digDown()
  1508.  down()
  1509.  df(9)
  1510.  turtle.select(pipeexpand)
  1511.  for i=1,9 do
  1512.   back()
  1513.   turtle.place()
  1514.  end
  1515.  up()
  1516.  turtle.placeDown()
  1517.  up()
  1518.  turtle.placeDown()
  1519.  back()
  1520.  turtle.select(obsidianpipeexpand)
  1521.  turtle.place()
  1522.  turtle.turnRight()
  1523.  forward()
  1524.  turtle.turnLeft()
  1525.  moveForward(8)
  1526.  up()
  1527.  up()
  1528.  moveForward(3)
  1529.  turtle.turnRight()
  1530. end
  1531.  
  1532. --FWCexpand 66666666666666666666666666
  1533. function FWCexpand()
  1534.  print("Expanding farm!")
  1535.  checkFuelexpand()
  1536.  blockslot = 5
  1537.  destroy()
  1538.  layout()
  1539.  corners()
  1540.  plateau()
  1541.  pipeAndDirt()
  1542.  print("Finished!")
  1543.  print("Press Enter to get back into the menu!")
  1544.  read()
  1545. end
  1546.  
  1547. --FWChelp 77777777777777777777777777777777777777777
  1548.  
  1549. function FWChelp()
  1550.  print("Welcome to the UWC Help Interface!")
  1551.  print("If you have any question, suggestions, bugs or feedback, let me know: Type")
  1552.  print("computercraft forum ultimate wood chopper")
  1553.  print("in Google and write a post or PM at me ;D")
  1554.  read()
  1555. end
  1556.  
  1557. --FWCposition 999999999999999999999999999999999999
  1558.  
  1559. function FWCposition()
  1560.  turtle.select(coal)
  1561.  turtle.refuel(1)
  1562.  up()
  1563.  up()
  1564.  up()
  1565.  up()
  1566.  turtle.turnRight()
  1567.  forward()
  1568.  forward()
  1569.  forward()
  1570.  forward()
  1571.  turtle.turnLeft()
  1572.  forward()
  1573.  forward()
  1574.  print(" ")
  1575.  print("Turtle in Base. Ready to set up farm.")
  1576.  print("Be sure the turtle has all the materials it needs.")
  1577.  print("Press Enter to get back into the menu.")
  1578.  read()
  1579. end
  1580.  
  1581. --FWCexpandchests
  1582.  
  1583. function FWCexpandchests()
  1584.  print("Adding more chests!")
  1585.  local amount = turtle.getItemCount(2)
  1586.  turtle.turnLeft()
  1587.  while not turtle.detectUp() do
  1588.   turtle.up()
  1589.  end
  1590.  turtle.select(3)
  1591.  turtle.digUp()
  1592.  turtle.select(2)
  1593.  while amount > 0 do
  1594.   up()
  1595.   turtle.place()
  1596.   amount = amount-1
  1597.  end
  1598.  turtle.select(3)
  1599.  turtle.placeUp()
  1600.  while turtle.down() do end
  1601.  turtle.turnRight()
  1602.  print("Finsihed!")
  1603.  print("Press Enter to get back into the menu.")
  1604.  read()
  1605. end
  1606.  
  1607. --FWCtwobytwo
  1608.  
  1609. function FWCtwobytwo()
  1610.  print("Chopping down 2x2 tree.")
  1611.  while turtle.getFuelLevel() < 200 do
  1612.   sleep(2)
  1613.   turtle.select(1)
  1614.   turtle.refuel(1)
  1615.   print("Refueled!")
  1616.  end
  1617.  cutWood()
  1618.  print("Press Enter to get back into the menu.")
  1619.  read()
  1620. end
  1621.  
  1622. --FWConebyone
  1623.  
  1624. function FWConebyone()
  1625.  print("Chopping down 1x1 tree.")
  1626.  while turtle.getFuelLevel() < 200 do
  1627.   sleep(2)
  1628.   turtle.select(1)
  1629.   turtle.refuel(1)
  1630.   print("Refueled!")
  1631.  end
  1632.  turtle.select(2)
  1633.  turtle.dig()
  1634.  forward()
  1635.  while turtle.compareUp() do
  1636.   turtle.digUp()
  1637.   up()
  1638.  end
  1639.  while not turtle.detectDown() do
  1640.   turtle.down()
  1641.  end
  1642.  print("Finsihed!")
  1643.  print("Press Enter to get back into the menu.")
  1644.  read()
  1645. end
  1646.  
  1647. --FWCdigSpace
  1648.  
  1649. function FWCdigSpace()
  1650.  os.sleep(2)
  1651.  turtle.select(1)
  1652.  turtle.refuel(5)
  1653.  back()
  1654.  back()
  1655.  turtle.turnLeft()
  1656.  forward()
  1657.  turtle.turnRight()
  1658.  turtle.digDown()
  1659.  turtle.down()
  1660.  turtle.digDown()
  1661.  turtle.down()
  1662.  for i=1,3 do
  1663.   for j=1,4 do
  1664.    turtle.forward()
  1665.    turtle.digUp()
  1666.    turtle.dig()
  1667.   end
  1668.   if i<3 then
  1669.    for j=1,4 do
  1670.     turtle.back()
  1671.    end
  1672.    turtle.turnRight()
  1673.    turtle.dig()
  1674.    turtle.forward()
  1675.    turtle.turnLeft()
  1676.   end
  1677.  end
  1678.  turtle.digDown()
  1679.  turtle.back()
  1680.  turtle.digDown()
  1681.  turtle.forward()
  1682.  turtle.up()
  1683.  turtle.up()
  1684.  turtle.turnLeft()
  1685.  moveForward(5)
  1686.  turtle.turnRight()
  1687.  turtle.forward()
  1688.  turtle.digDown()
  1689.  turtle.down()
  1690.  turtle.digDown()
  1691.  turtle.down()
  1692.  turtle.digDown()
  1693.  for i=1,5 do
  1694.   for j=1,11 do
  1695.    turtle.dig()
  1696.    turtle.forward()
  1697.    turtle.digUp()
  1698.    turtle.digDown()
  1699.   end
  1700.   turtle.turnRight()
  1701.   turtle.dig()
  1702.   turtle.forward()
  1703.   turtle.turnRight()
  1704.   turtle.digUp()
  1705.   turtle.digDown()
  1706.   for j=1,11 do
  1707.    turtle.dig()
  1708.    turtle.forward()
  1709.    turtle.digUp()
  1710.    turtle.digDown()  
  1711.   end
  1712.   if i < 5 then
  1713.    turtle.turnLeft()
  1714.    turtle.dig()
  1715.    turtle.forward()
  1716.    turtle.turnLeft()
  1717.    turtle.digDown()
  1718.    turtle.digUp()
  1719.   end
  1720.  end
  1721.  turtle.back()
  1722.  turtle.turnRight()
  1723.  turtle.forward()
  1724.  turtle.down()
  1725.  turtle.digDown()
  1726.  turtle.down()
  1727.  for i=1,8 do
  1728.   turtle.turnRight()
  1729.   turtle.dig()
  1730.   turtle.turnLeft()
  1731.   turtle.dig()
  1732.   turtle.forward()
  1733.  end
  1734.  turtle.turnLeft()
  1735.  turtle.up()
  1736.  turtle.up()
  1737.  turtle.up()
  1738.  turtle.up()
  1739.  turtle.turnLeft()
  1740.  moveForward(4)
  1741.  turtle.turnRight()
  1742.  moveForward(3)
  1743.  turtle.turnLeft()
  1744.  turtle.turnLeft()
  1745.  print("Finished!")
  1746.  print("Press Enter to get back into the menu!")
  1747.  read()
  1748. end
  1749.  
  1750. -- EASY FARM
  1751.  
  1752. gapBase = 3
  1753. gapTree = 1
  1754. row = 3
  1755. cell = 2
  1756. size = 1
  1757. currentTreeX = 0
  1758. currentTreeY = 0
  1759. usebonemealEasyFarm = true
  1760.  
  1761. function chopDownTree()
  1762.  turtle.down()
  1763.  if size == 2 then
  1764.   local height = 1
  1765.   turtle.select(1)
  1766.   turtle.dig()
  1767.   forward()
  1768.   turtle.dig()
  1769.   turtle.digUp()
  1770.   up()
  1771.   turtle.dig()
  1772.   while turtle.detectUp() do
  1773.    turtle.digUp()
  1774.    up()
  1775.    turtle.dig()
  1776.    height = height + 1
  1777.   end
  1778.   turtle.turnRight()
  1779.   turtle.dig()
  1780.   forward()
  1781.   turtle.turnLeft()
  1782.   turtle.dig()
  1783.   while height > 0 do
  1784.    turtle.digDown()
  1785.    down()
  1786.    turtle.dig()
  1787.    height = height - 1
  1788.   end
  1789.   back()
  1790.   turtle.turnLeft()
  1791.   forward()
  1792.   turtle.turnRight()
  1793.   turtle.up()
  1794.   turtle.forward()
  1795.   replantTree()
  1796.  else
  1797.   turtle.select(1)
  1798.   turtle.dig()
  1799.   forward()
  1800.   for i=1,2 do
  1801.    turtle.digUp()
  1802.    turtle.up()
  1803.   end
  1804.   while turtle.compareUp() do
  1805.    turtle.digUp()
  1806.    turtle.up()
  1807.   end
  1808.   while not turtle.detectDown() do
  1809.    turtle.down()
  1810.   end
  1811.   turtle.up()
  1812.   replantTree()
  1813.  end
  1814. end
  1815.  
  1816. function xcoord()
  1817.  return gapTree*currentTreeX + currentTreeX*size
  1818. end
  1819.  
  1820. function ycoord()
  1821.  return gapTree*currentTreeY + currentTreeY*size + 1
  1822. end
  1823.  
  1824. function move(x,y)
  1825.  if y < 0 then
  1826.   turtle.turnLeft()
  1827.   turtle.turnLeft()
  1828.   forwardsuck(-y)
  1829.   turtle.turnLeft()
  1830.   turtle.turnLeft()
  1831.  elseif y > 0 then
  1832.   forwardsuck(y)
  1833.  end
  1834.  
  1835.  if x < 0 then
  1836.   turtle.turnLeft()
  1837.   forwardsuck(-x)
  1838.   turtle.turnRight()
  1839.  elseif x > 0 then
  1840.   turtle.turnRight()
  1841.   forwardsuck(x)
  1842.   turtle.turnLeft()
  1843.  end
  1844. end
  1845.  
  1846. function placeSapling()
  1847.  if not turtle.detectDown() then
  1848.   turtle.select(1)
  1849.   turtle.placeDown()
  1850.  end
  1851. end
  1852.  
  1853. function resupply()
  1854.  if turtle.getItemCount(1) < size*size*2 or turtle.getItemCount(14) > 0 or turtle.getItemCount(2) <= 1 then
  1855.   move(- xcoord(),- ycoord())
  1856.   move(0,-(gapBase+2))
  1857.   getSupplies()
  1858.   move(0,gapBase+2)
  1859.   move(xcoord(),ycoord())
  1860.  end
  1861. end
  1862.  
  1863. function replantTree()
  1864.  placeSapling()
  1865.  if size == 2 then
  1866.   for i=1,4 do
  1867.    turtle.forward()
  1868.    placeSapling()
  1869.    turtle.turnRight()
  1870.   end
  1871.  end
  1872. end
  1873.  
  1874. function forwardsuck(j)
  1875.  for i=1,j do
  1876.   turtle.select(1)
  1877.   turtle.dig()
  1878.   turtle.forward()
  1879.   if turtle.getItemCount(1) < 60 then
  1880.    for i=1,2 do
  1881.     turtle.suckDown()
  1882.    end
  1883.   end
  1884.  end
  1885. end
  1886.  
  1887. function getSupplies()
  1888.  turtle.select(3)
  1889.  turtle.dropDown(16)
  1890.  usebonemeal = true
  1891.  storeWood()
  1892.  turtle.turnRight()
  1893.  if redstone.getInput("back") == false then
  1894.   print("Shutdown by redstone signal!")
  1895.   chopping = false
  1896.  else
  1897.   getCoal()
  1898.   turtle.turnRight()
  1899.   turtle.forward()
  1900.   turtle.turnRight()  
  1901.   getSaplings()
  1902.   getBonemeal()
  1903.   turtle.turnLeft()
  1904.   move(0,1+gapBase)
  1905.  end
  1906. end
  1907.  
  1908. function checkTree()
  1909.  resupply()
  1910.  turtle.select(1)
  1911.  if not turtle.detect() then
  1912.   turtle.forward()
  1913.   if not turtle.detect() then
  1914.    replantTree()
  1915.   elseif not turtle.compareDown() then
  1916.    turtle.back()
  1917.    chopDownTree()
  1918.   elseif turtle.compareDown() and usebonemealEasyFarm then
  1919.    turtle.back()
  1920.    turtle.down()
  1921.    turtle.select(1)
  1922.    while turtle.compare() and turtle.getItemCount(2) > 1 do
  1923.     turtle.select(2)
  1924.     turtle.place()
  1925.     turtle.select(1)
  1926.     sleep(1)
  1927.    end
  1928.    turtle.digUp()
  1929.    turtle.up()
  1930.    chopDownTree()
  1931.   end
  1932.  else
  1933.   chopDownTree()
  1934.  end
  1935. end
  1936.  
  1937. function UWCeasyfarm()
  1938.  running = true
  1939.  while running do
  1940.   resupply()
  1941.   forwardsuck(gapBase)
  1942.   currentTreeX, currentTreeY = 0,0
  1943.   for i=1,row do
  1944.    for j=1,cell do
  1945.     checkTree()
  1946.     if i%2 == 1 then
  1947.      if j < cell then
  1948.       forwardsuck(gapTree+size-1)
  1949.       currentTreeY = currentTreeY + 1
  1950.      end
  1951.     else
  1952.      if j < cell then
  1953.       turtle.turnLeft()
  1954.       turtle.turnLeft()
  1955.       forwardsuck(gapTree+size+1)
  1956.       turtle.turnLeft()
  1957.       turtle.turnLeft()
  1958.       currentTreeY = currentTreeY - 1
  1959.      end
  1960.     end
  1961.    end
  1962.    if i < row then
  1963.     turtle.back()
  1964.     turtle.turnRight()
  1965.     forwardsuck(gapTree+size)
  1966.     turtle.turnLeft()
  1967.     currentTreeX = currentTreeX + 1
  1968.    end
  1969.   end
  1970.   move(- xcoord(), - ycoord())
  1971.   move(0, - gapBase)
  1972.   sleep(10)
  1973.  end
  1974. end
  1975.  
  1976.  
  1977.  
  1978. --VARIABLES
  1979.  
  1980. function UWCvariables()
  1981.  print("Welcome in the variable change menu.")
  1982.  print("You have the choice to individualise your farming turtle.")
  1983.  print("These variables are just used for the farm and get saved.")
  1984.  print("If you want to skip a variable and leave it where it is, you just have to press Enter.")
  1985.  print("Press Enter to continue...")
  1986.  read()
  1987.  clearScreen()
  1988.  print("There are different values:")
  1989.  print("Timer - The amount of seconds until something happens.")
  1990.  print("Amount - The amount of items.")
  1991.  print("Slot - A slot in the turtles inventory")
  1992.  print("Level - The Fuel Level")
  1993.  print("Height - The amount of blocks.")
  1994.  print("")
  1995.  print("Press Enter to continue...")
  1996.  read()
  1997.  clearScreen()
  1998.  local input = 0
  1999.  
  2000.  
  2001.  
  2002.  print("Timer")
  2003.  print("Turtle fails to take enough materials out of a chest.")
  2004.  print("How long does he waits until it tries again?")
  2005.  print("In this time the turtle can be terminated by the user.")
  2006.  print("Standard: 2")
  2007.  print("Minimum: 1")
  2008.  print("Current: " .. cancelTimer)
  2009.  input = tonumber(read())
  2010.  if input then
  2011.   input = math.floor(input)
  2012.   if input >= 1 then cancelTimer = input end
  2013.  end
  2014.  clearScreen()
  2015.  
  2016.  print("Set to: " .. cancelTimer)
  2017.  print("")
  2018.  print("Timer")
  2019.  print("Turtle fails to fertilize the tree with bonemeal.")
  2020.  print("How long should it wait until it tries again?")
  2021.  print("Standard: 120")
  2022.  print("Current: " .. bonemealTimer)
  2023.  input = tonumber(read())
  2024.  if input then
  2025.   input = math.floor(input)
  2026.   if input >= 0 then bonemealTimer = input end
  2027.  end
  2028.  clearScreen()
  2029.  
  2030.  print("Set to: " .. bonemealTimer)
  2031.  print("")
  2032.  print("Timer")
  2033.  print("Turtle planted the saplings.")
  2034.  print("How long should the turtle wait before fertilizing the first time?")
  2035.  print("Standard: 0")
  2036.  print("Current: " .. bonemealFirstDelay)
  2037.  input = tonumber(read())
  2038.  if input then
  2039.   input = math.floor(input)
  2040.   if input >= 0 then bonemealFirstDelay = input end
  2041.  end
  2042.  clearScreen()
  2043.  
  2044.  print("Set to: " .. bonemealFirstDelay)
  2045.  print("")
  2046.  print("Slot")
  2047.  print("Turtle goes back to base if the inventory slot has items in it.")
  2048.  print("Which slot should it be if the turtle uses bonemeal?")
  2049.  print("Standard: 14")
  2050.  print("Minimum: 3  Maximum: 16")
  2051.  print("Current: " .. amountMaxWoodSlotBonemeal)
  2052.  turtle.select(tonumber(amountMaxWoodSlotBonemeal))
  2053.  input = tonumber(read())
  2054.  if input then
  2055.   input = math.floor(input)
  2056.   if input >= 3 and input <= 16 then amountMaxWoodSlotBonemeal = input end
  2057.  end
  2058.  clearScreen()
  2059.  
  2060.  print("Set to: " .. amountMaxWoodSlotBonemeal)
  2061.  print("")
  2062.  print("Slot")
  2063.  print("Turtle goes back to base if inventory slot has items in it.")
  2064.  print("Which slot should it be if the turtle doesnt use bonemeal?")
  2065.  print("Standard: 7")
  2066.  print("Minimum: 2  Maximum: 16")
  2067.  print("Current: " .. amountMaxWoodSlotNoBonemeal)
  2068.  turtle.select(tonumber(amountMaxWoodSlotNoBonemeal))
  2069.  input = tonumber(read())
  2070.  if input then
  2071.   input = math.floor(input)
  2072.   if input >= 2 and input <= 16 then amountMaxWoodSlotNoBonemeal = input end
  2073.  end
  2074.  clearScreen()
  2075.  
  2076.  print("Set to: " .. amountMaxWoodSlotNoBonemeal)
  2077.  print("")
  2078.  print("Amount")
  2079.  print("Turtle needs this amount or more bonemeal in slot 2 before keep going.")
  2080.  print("Standard: 8")
  2081.  print("Minimum: 3 Maximum: 64")
  2082.  print("Current: " .. amountMinBonemeal)
  2083.  input = tonumber(read())
  2084.  if input then
  2085.   input = math.floor(input)
  2086.   if input > 2 and input < 65 then amountMinBonemeal = input end
  2087.  end
  2088.  clearScreen()
  2089.  
  2090.  print("Set to: " .. amountMinBonemeal)
  2091.  print("")
  2092.  print("Amount")
  2093.  print("Turtle needs this amount or more saplings in slot 1 before keep going.")
  2094.  print("Standard: 17")
  2095.  print("Minimum: 4 Maximum: 64")
  2096.  print("Current: " .. amountMinSaplings)
  2097.  input = tonumber(read())
  2098.  if input then
  2099.   input = math.floor(input)
  2100.   if input > 3 and input < 65 then amountMinSaplings = input end
  2101.  end
  2102.  clearScreen()
  2103.  
  2104.  print("Set to: " .. amountMinSaplings)
  2105.  print("")
  2106.  print("Level")
  2107.  print("Turtle checks if it needs more fuel before planting and chopping down the next tree.")
  2108.  print("Standard: 200")
  2109.  print("Minimum: 150 Maximum: 1000")
  2110.  print("Current: " .. amountMinFuelLevel)
  2111.  input = tonumber(read())
  2112.  if input then
  2113.   input = math.floor(input)
  2114.   if input > 149 and input < 1001 then amountMinFuelLevel = input end
  2115.  end
  2116.  clearScreen()
  2117.  
  2118.  print("Set to: " .. amountMinFuelLevel)
  2119.  print("")
  2120.  print("Amount")
  2121.  print("After chopping down trees, the turtle places some wood into the furnace.")
  2122.  print("How many wood should be put into the furnace if bonemeal is used?")
  2123.  print("Standard: 16")
  2124.  print("Minimum: 0  Maximum: 64")
  2125.  print("Current: " .. amountFurnaceWoodBonemeal)
  2126.  input = tonumber(read())
  2127.  if input then
  2128.   input = math.floor(input)
  2129.   if input >= 0 and input < 65 then amountFurnaceWoodBonemeal = input end
  2130.  end
  2131.  clearScreen()
  2132.  
  2133.  print("Set to: " .. amountFurnaceWoodBonemeal)
  2134.  print("")
  2135.  print("Amount")
  2136.  print("After chopping down trees, the turtle places some wood into the furnace.")
  2137.  print("How many wood should be put into the furnace if no bonemeal is used?")
  2138.  print("Standard: 8")
  2139.  print("Minimum: 0  Maximum: 64")
  2140.  print("Current: " .. amountFurnaceWoodNoBonemeal)
  2141.  input = tonumber(read())
  2142.  if input then
  2143.   input = math.floor(input)
  2144.   if input >= 0 and input < 65 then amountFurnaceWoodNoBonemeal = input end
  2145.  end
  2146.  clearScreen()
  2147.  
  2148.  print("Set to: " .. amountFurnaceWoodNoBonemeal)
  2149.  print("")
  2150.  print("Height")
  2151.  print("If the turtle debugs the farm, it checks how height it is.")
  2152.  print("It turns back down if it didnt it anything.")
  2153.  print("At which height should it turn back down.")
  2154.  print("Standard: 55")
  2155.  print("Minimum: 1  Maximum: 200")
  2156.  print("Current: " .. debugMaxHeight)
  2157.  input = tonumber(read())
  2158.  if input then
  2159.   input = math.floor(input)
  2160.   if input > 0 and input < 201 then debugMaxHeight = input end
  2161.  end
  2162.  clearScreen()
  2163.  
  2164.  print("Set to: " ..debugMaxHeight)
  2165.  print("")
  2166.  print("Saving variables...")
  2167.  saveVariables()
  2168.  print("Saved variables!")
  2169.  sleep(0.5)
  2170. end
  2171.  
  2172. function UWCgodown()
  2173.  while not turtle.detectDown() do
  2174.   turtle.down()
  2175.  end
  2176. end
  2177. --MAIN PROGRAM
  2178.  
  2179. while running == true do
  2180.  runMenu()
  2181. end
Advertisement
Add Comment
Please, Sign In to add comment