UNOBTANIUM

uwc0.9.0

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