UNOBTANIUM

uwc0.9.5 prerelease B

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