Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.   forward()
  699.      -- now should be over water between 1 and 2   assuming grid is  2W3
  700.      --                                                              WWW
  701.      --                                                              1W4
  702.   turtle.dig()
  703.   forward()
  704.   saveSavePoint(6)
  705.   turtle.turnRight()
  706.   forward()
  707.   turtle.dig()  --should have dug 3
  708.  
  709.    turtle.place() -- plant sapling on 3
  710.   jFert()
  711.   back()
  712.   back()
  713.  
  714.  turtle.place() -- plant sapling on 2
  715.   jFert()
  716.   turtle.turnLeft()
  717.   back()
  718.   back()
  719.  
  720.   turtle.turnRight()
  721.   forward()
  722.   forward()
  723.  
  724.  
  725. turtle.place() -- plant sapling on 4
  726.   jFert()
  727.  
  728.    back()
  729.    turtle.turnLeft()
  730.    back()
  731. turtle.place() -- plant sapling on 1
  732.   jFert()
  733.  
  734. end
  735. end
  736.  
  737.  
  738.  
  739.  
  740.  
  741.  
  742. function jFert()
  743.  
  744.   if usebonemeal then
  745.    if turtle.getItemCount(2) <= amountbonemealtimes + 1 then
  746.     print("Ran out of bonemeal!")
  747.     print("")
  748.     return false
  749.    end
  750.    print("Fertilizing the sapling with bonemeal!")
  751.    turtle.select(2)
  752.    local amountPlaced = 0
  753.    for i=1,amountbonemealtimes do
  754.     if turtle.place() then
  755.      amountPlaced = amountPlaced + 1
  756.     end
  757.     sleep(0.6)
  758.    end
  759.    print("Fertilized the sapling ".. amountPlaced .." times!")
  760.   end
  761.   turtle.select(1)
  762. end
  763.  
  764. function getMaterials()
  765.  saveSavePoint(4)
  766.  turtle.turnLeft()
  767.  saveSavePoint(1)
  768.  turtle.turnLeft()
  769.  moveForward(distance)
  770.  
  771.  turtle.select(3)
  772.  if usebonemeal then
  773.   turtle.dropDown(amountFurnaceWoodBonemeal)
  774.  else
  775.   turtle.dropDown(amountFurnaceWoodNoBonemeal)
  776.  end
  777.  saveSavePoint(5)
  778.  storeWood()
  779.  
  780.  saveSavePoint(0)
  781.  turtle.turnRight()
  782.    
  783.  if redstone.getInput("back") == false then
  784.   print("Shutdown by redstone signal!")
  785.   chopping = false
  786.   runningProgram = ""
  787.   saveSavePoint(0)
  788.  else
  789.   getCoal()
  790.   saveSavePoint(2)
  791.   turtle.turnRight()
  792.   turtle.forward()
  793.   saveSavePoint(3)
  794.   turtle.turnRight()  
  795.   getSaplings()
  796.   getBonemeal()
  797.   saveSavePoint(2)
  798.   turtle.turnLeft()
  799.   moveForward(distance-1)
  800.  end
  801. end
  802.  
  803. function chopUp()
  804.  turtle.dig()
  805.  while turtle.detectUp() do
  806.   saveSavePoint(110)
  807.   turtle.digUp()
  808.   saveSavePoint(102)
  809.   up()
  810.   turtle.dig()
  811.  end
  812. end
  813.  
  814. function chopDown()
  815.  turtle.dig()
  816.  while turtle.detectDown() do
  817.   saveSavePoint(111)
  818.   turtle.digDown()
  819.   saveSavePoint(103)
  820.   down()
  821.   turtle.dig()
  822.  end
  823. end
  824.  
  825. function cutWood()
  826.  turtle.select(1)
  827.  
  828.  turtle.dig()
  829.   forward()
  830.  
  831.  
  832.   chopUp()
  833.  
  834.   UWCgodown()
  835.  
  836.   forward()
  837.      -- now should be over water between 1 and 2   assuming grid is  2W3
  838.      --                                                              WWW
  839.      --                                                              1W4
  840.   turtle.dig()
  841.   forward()
  842.   chopUp()
  843.  
  844.   UWCgodown()
  845.  
  846.   saveSavePoint(6)
  847.   turtle.turnRight()
  848.   forward()
  849.   turtle.dig()  --should have dug 3
  850.   forward()
  851.   chopUp()
  852.  
  853.   UWCgodown()
  854.  
  855.   back()
  856.   back()
  857.  
  858.   turtle.turnLeft()
  859.   back()
  860.   back()
  861.  
  862.   turtle.turnRight()
  863.   forward()
  864.   forward()
  865. turtle.dig()  --should have dug 3
  866.   forward()
  867.   chopUp()
  868.  
  869.   UWCgodown()
  870.  
  871.    back()
  872.    back()
  873.    turtle.turnLeft()
  874.    back()
  875.  
  876.  
  877. end
  878.  
  879. function cutWood_old()
  880.  turtle.select(1)
  881.  if savestate == 2 then
  882.   turtle.dig()
  883.   saveSavePoint(100)
  884.   forward()
  885.  end
  886.  if savestate == 100 then
  887.   if turtle.detectUp() then
  888.    print("Chopping down the tree!")
  889.    saveSavePoint(101)
  890.    turtle.turnRight()
  891.   else
  892.    saveSavePoint(2)
  893.    back()
  894.    print("ERROR!!! No tree above!")
  895.    print("Prevented: Digging down to bedrock!")
  896.    return
  897.   end
  898.  end
  899.  if savestate == 101 then
  900.   turtle.dig()
  901.   saveSavePoint(102)
  902.   turtle.turnLeft()
  903.  end
  904.  if savestate == 110 then
  905.   saveSavePoint(102)
  906.   up()
  907.  end
  908.  if savestate == 102 then
  909.   chopUp()
  910.   saveSavePoint(8)
  911.   turtle.turnRight()
  912.  end
  913.  print("Reached the top of the tree!")
  914.  if savestate == 8 then
  915.   turtle.dig()
  916.   saveSavePoint(9)
  917.   forward()
  918.  end
  919.  if savestate == 9 then
  920.   saveSavePoint(103)
  921.   turtle.turnLeft()
  922.  end
  923.  if savestate == 111 then
  924.   saveSavePoint(103)
  925.   down()
  926.  end
  927.  if savestate == 103 then
  928.   chopDown()
  929.   saveSavePoint(104)
  930.   turtle.dig()
  931.  end
  932.  if savestate == 104 then
  933.   saveSavePoint(105)
  934.   down()
  935.  end
  936.  if savestate == 105 then
  937.   saveSavePoint(106)
  938.   turtle.dig()
  939.  end
  940.  if savestate == 106 then
  941.   saveSavePoint(10)
  942.   back()
  943.  end
  944.  print("Successful chopped the tree!")
  945.  print("")
  946.  if savestate == 10 then
  947.   saveSavePoint(11)
  948.   turtle.turnLeft()
  949.  end
  950.  if savestate == 11 then
  951.   saveSavePoint(12)
  952.   forward()
  953.  end
  954.  if savestate == 12 then
  955.   saveSavePoint(2)
  956.   turtle.turnRight()
  957.  end
  958. end
  959.  
  960.  
  961.  
  962.  
  963.  
  964. function chop()
  965.  if redstone.getInput("back") == true then
  966.   saveSavePoint(0)
  967.   print("Starting the Fir Wood Chooper program!")
  968.   getCoal()
  969.   if turtle.getItemCount(3) > 0 or turtle.getItemCount(16) > 0 then
  970.    saveSavePoint(1)
  971.    turtle.turnLeft()
  972.    storeWood()
  973.    saveSavePoint(0)
  974.    turtle.turnRight()
  975.   end
  976.   saveSavePoint(2)
  977.   turtle.turnRight()
  978.   forward()
  979.   saveSavePoint(3)
  980.   turtle.turnRight()
  981.   if turtle.getItemCount(1) < amountMinSaplings then
  982.    getSaplings()
  983.   end
  984.   if turtle.getItemCount(2) < amountMinBonemeal and usebonemeal == true then
  985.    getBonemeal()
  986.   end
  987.   if turtle.getItemCount(2) > 0 and usebonemeal == false then
  988.    turtle.select(2)
  989.    turtle.dropUp()
  990.   end
  991.   saveSavePoint(1)
  992.   turtle.turnRight()
  993.   forward()
  994.   saveSavePoint(0)
  995.   turtle.turnRight()
  996.   saveSavePoint(2)
  997.   turtle.turnRight()
  998.   moveForward(distance)
  999.  
  1000.   while chopping == true do
  1001.    local needMaterials = false
  1002.    if turtle.getFuelLevel() < 200 then
  1003.     needMaterials = true
  1004.     print("Have to refuel!")
  1005.    end
  1006.    if turtle.getItemCount(1) < amountMinSaplings then
  1007.     needMaterials = true
  1008.     print("Need more Saplings!")
  1009.    end
  1010.    if usebonemeal and turtle.getItemCount(2) < amountMinBonemeal then
  1011.     needMaterials = true
  1012.     print("Need more bonemeal!")
  1013.    end
  1014.    if usebonemeal and turtle.getItemCount(amountMaxWoodSlotBonemeal) > 0 then
  1015.     needMaterials = true
  1016.     print("Enough wood harvested!")
  1017.    elseif not usebonemeal and turtle.getItemCount(amountMaxWoodSlotNoBonemeal) > 0 then
  1018.     needMaterials = true
  1019.     print("Enough wood harvested!")
  1020.    end
  1021.    if needMaterials then
  1022.     getMaterials()
  1023.    end
  1024.    if chopping then
  1025.     if plantTree() then
  1026.      cutWood()
  1027.     end
  1028.    end
  1029.    sleep(0)
  1030.   end
  1031.  else
  1032.   runningProgram = ""
  1033.   saveSavePoint(0)
  1034.   print("No redstone signal, no wood!")
  1035.   print("Be sure the Turtle is facing the coal chest and stays above the furnace!")
  1036.   print("The redstone signal has to be in the back of the Turtle!")
  1037.  end
  1038.  print("Press Enter to get back into the menu...")
  1039.  read()
  1040.  chopping = true
  1041. end
  1042.  
  1043. --MAIN DEBUG FUNCTIONS
  1044.  
  1045. function FWCdebug()
  1046.  getCoal()
  1047.  turtle.turnRight()
  1048.  moveForward(distance)
  1049.  local height = 0
  1050.  turtle.select(1)
  1051.  turtle.dig()
  1052.  forward()
  1053.  turtle.dig()
  1054.  while not turtle.detectUp() and height < debugMaxHeight do
  1055.   turtle.up()
  1056.   height = height + 1
  1057.  end
  1058.  turtle.dig()
  1059.  while turtle.detectUp() do
  1060.   turtle.digUp()
  1061.   turtle.up()
  1062.   turtle.dig()
  1063.   height = height + 1
  1064.  end
  1065.  turtle.turnRight()
  1066.  turtle.dig()
  1067.  forward()
  1068.  turtle.turnLeft()
  1069.  turtle.dig()
  1070.  while height > 0 do
  1071.   turtle.digDown()
  1072.   down()
  1073.   turtle.dig()
  1074.   height = height - 1
  1075.  end
  1076.  back()
  1077.  turtle.turnLeft()
  1078.  forward()
  1079.  turtle.turnLeft()
  1080.  moveForward(distance)
  1081.  turtle.turnRight()
  1082.  print("Debug finished! Please take the wood out of the inventory!")
  1083.  print("Press Enter to get back into the menu!")
  1084.  read()
  1085. end
  1086.  
  1087. -- MOVEMENT FUNCTIONS
  1088.  
  1089. function dbp(j) -- dig down, place down, back (dig), place
  1090.  j = j or 1
  1091.  for i=1,j do
  1092.   turtle.digDown()
  1093.   turtle.placeDown()
  1094.   db()
  1095.   turtle.place()
  1096.  end
  1097. end
  1098.  
  1099. function lb() -- left, back (dig)
  1100.  turtle.turnLeft()
  1101.  db()
  1102. end
  1103.  
  1104. function db() -- back (dig)
  1105.  if not turtle.back() then
  1106.   turtle.turnLeft()
  1107.   turtle.turnLeft()
  1108.   turtle.dig()
  1109.   turtle.forward()
  1110.   turtle.turnLeft()
  1111.   turtle.turnLeft()
  1112.  end
  1113. end
  1114.  
  1115. function bp(j) -- back (dig), place
  1116.  j = j or 1
  1117.  for i=1,j do
  1118.   db()
  1119.   turtle.place()
  1120.  end
  1121. end
  1122.  
  1123. function checkBlocks()
  1124.  if turtle.getItemCount(blockslot) == 0 and blockslot < 10 then
  1125.   blockslot = blockslot + 1
  1126.   turtle.select(blockslot)
  1127.  end
  1128. end
  1129.  
  1130. function fd(j) -- forward (dig)
  1131.  j = j or 1
  1132.  for i=1, j do
  1133.   if turtle.detect() then
  1134.    turtle.dig()
  1135.   end
  1136.  turtle.forward()
  1137.  end
  1138. end
  1139.  
  1140. function fdown(j) -- forward, placeDown (digDown)
  1141.  j = j or 1
  1142.  for i=1,j do
  1143.   if not turtle.forward() then
  1144.    turtle.dig()
  1145.    turtle.forward()
  1146.   end
  1147.   if turtle.detectDown() then
  1148.    turtle.digDown()
  1149.   end
  1150.   turtle.placeDown()
  1151.  end
  1152. end
  1153.  
  1154. function fde(j,check) -- forward (dig), digUp, digDown, checkBlocks, placeDown
  1155.  j = j or 1
  1156.  check = check or true
  1157.  for i=1,j do
  1158.   dfd(1)
  1159.   if check then
  1160.    checkBlocks()
  1161.   end
  1162.   turtle.placeDown()
  1163.  end
  1164. end
  1165.  
  1166. function dfd(j) -- forward (dig), digUp, digDown
  1167.  j = j or 1
  1168.  for i=1,j do
  1169.   df(1)
  1170.   turtle.digDown()
  1171.  end
  1172. end
  1173.  
  1174. function df(j) -- forward (dig), digUp
  1175.  j = j or 1
  1176.  for i=1,j do
  1177.   if turtle.detect() then
  1178.    turtle.dig()
  1179.   end
  1180.   forward()
  1181.   turtle.digUp()
  1182.  end
  1183. end
  1184.  
  1185. function dd() -- digDown, down
  1186.  turtle.digDown()
  1187.  turtle.down()
  1188. end
  1189.  
  1190. function du() -- digUp, up
  1191.  turtle.digUp()
  1192.  turtle.up()
  1193. end
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199. -- BUILD FUNCTIONS
  1200.  
  1201. function buildBase(standard)
  1202.  turtle.select(stone3)
  1203.  if not standard then
  1204.   entrance()
  1205.   dd()
  1206.   dd()
  1207.   moveForward(2)
  1208.   turtle.dig()
  1209.   turtle.place()
  1210.   turtle.turnLeft()
  1211.   db()
  1212.   turtle.place()
  1213.   du()
  1214.   du()
  1215.   turtle.turnLeft()
  1216.   turtle.turnLeft()
  1217.  end
  1218.  turtle.placeDown()
  1219.  turtle.turnLeft()
  1220.  turtle.select(chest)
  1221.  turtle.place()
  1222.  turtle.select(sapling)
  1223.  turtle.drop()
  1224.  turtle.turnRight()
  1225.  turtle.select(chest)
  1226.  turtle.placeUp()
  1227.  turtle.select(bonemeal)
  1228.  turtle.dropUp()
  1229.  forward()
  1230.  turtle.select(chest)
  1231.  turtle.place()
  1232.  du()
  1233.  turtle.place()
  1234.  du()
  1235.  turtle.place()
  1236.  turtle.select(stone3)
  1237.  turtle.placeUp()
  1238.  
  1239.  dd()
  1240.  dd()
  1241.  dd()
  1242.  turtle.turnRight()
  1243.  turtle.select(woodenpipe)
  1244.  turtle.place()
  1245.  turtle.turnLeft()
  1246.  dd()
  1247.  turtle.select(furnace)
  1248.  turtle.placeUp()
  1249.  turtle.select(coal)
  1250.  turtle.dropUp(1)
  1251.  turtle.select(ironpipe)
  1252.  turtle.dig()
  1253.  turtle.place()
  1254.  lb()
  1255.  turtle.select(pipe)
  1256.  turtle.place()
  1257.  turtle.turnLeft()
  1258.  db()
  1259.  turtle.select(goldpipe)
  1260.  turtle.place()
  1261.  du()
  1262.  du()
  1263.  turtle.select(chest)
  1264.  turtle.place()
  1265.  turtle.select(coal)
  1266.  turtle.drop(1)
  1267.  turtle.select(engine)
  1268.  turtle.placeDown()
  1269.  db()
  1270.  turtle.select(stone3)
  1271.  turtle.placeDown()
  1272.  lb()
  1273.  turtle.select(lever)
  1274.  turtle.place()
  1275.  db()
  1276.  turtle.turnRight()
  1277.  moveForward(2)
  1278.  dd()
  1279.  turtle.select(pipe)
  1280.  turtle.dig()
  1281.  turtle.place()
  1282.  dd()
  1283.  turtle.dig()
  1284.  turtle.place()
  1285.  dd()
  1286.  if standard then
  1287.   fd(2)
  1288.   turtle.select(obsidianpipe)
  1289.   turtle.place()
  1290.   db()
  1291.   turtle.select(pipe)
  1292.   turtle.place()
  1293.   db()
  1294.  end
  1295.  turtle.place()
  1296.  
  1297.  turtle.turnLeft()
  1298.  du()
  1299.  du()
  1300.  du()
  1301.  turtle.select(stone3)
  1302.  turtle.placeDown()
  1303.  fd()
  1304.  turtle.turnRight()
  1305.  turtle.turnRight()
  1306.  turtle.select(lever)
  1307.  turtle.place()
  1308.  turtle.turnRight()
  1309.  turtle.turnRight()
  1310. end
  1311.  
  1312. function entrance()
  1313.  moveForward(2)
  1314.  turtle.turnRight()
  1315.  fd()
  1316.  turtle.placeUp()
  1317.  dbp(1)
  1318.  turtle.placeUp()
  1319.  turtle.digDown()
  1320.  turtle.placeDown()
  1321.  db()
  1322.  turtle.placeUp()
  1323.  dbp(1)
  1324. end
  1325.  
  1326.  
  1327. function FWCbuild()
  1328.  if turtle.detectDown() then
  1329.   print("There is a block underneath the turtle.")
  1330.   print("Be sure you have free space under the turtle.")
  1331.   print("Press Enter to get back to the menu.")
  1332.   read()
  1333.   return false
  1334.  end
  1335.  turtle.select(coal)
  1336.  for i=1,fuel do
  1337.   while not turtle.refuel(1) do print("Refuel didnt worked.") sleep(1) end
  1338.  end
  1339.  turtle.select(stone1)
  1340.  entrance()
  1341.  dd()
  1342.  dd()
  1343.  turtle.turnLeft()
  1344.  turtle.turnLeft()
  1345.  fd()
  1346.  
  1347.  dbp(4)
  1348.  turtle.select(stone1)
  1349.  bp(1)
  1350.  
  1351.  dbp(3)
  1352.  
  1353.  lb()
  1354.  dbp(2)
  1355.  bp(8)
  1356.  
  1357.  lb()
  1358.  bp(8)
  1359.  
  1360.  lb()
  1361.  bp(8)
  1362.  dbp(1)
  1363.  turtle.digDown()
  1364.  turtle.placeDown()
  1365.  turtle.turnLeft()
  1366.  bp(1)
  1367.  
  1368.  turtle.turnRight()
  1369.  turtle.turnRight()
  1370.  dd()
  1371.  turtle.digDown()
  1372.  turtle.placeDown()
  1373.  fde(7,false)
  1374.  turtle.turnLeft()
  1375.  fde(1,false)
  1376.  turtle.turnLeft()
  1377.  turtle.select(stone1)
  1378.  fde(7,false)
  1379.  
  1380.  turtle.select(stone2)
  1381.  turtle.turnRight()
  1382.  du()
  1383.  fdown(1)
  1384.  for i = 1,4 do
  1385.   fdown(7)
  1386.   turtle.turnRight()
  1387.   fdown(1)
  1388.   turtle.turnRight()
  1389.   fdown(7)
  1390.   if i < 4 then
  1391.    turtle.turnLeft()
  1392.    fdown(1)
  1393.    turtle.turnLeft()
  1394.   end
  1395.  end
  1396.  
  1397.  turtle.select(stone3)
  1398.  du()
  1399.  du()
  1400.  turtle.turnRight()
  1401.  moveForward(3)
  1402.  turtle.turnRight()
  1403.  moveForward(2)
  1404.  turtle.select(dirt)
  1405.  fdown(2)
  1406.  turtle.turnLeft()
  1407.  fdown(1)
  1408.  turtle.turnLeft()
  1409.  fdown(1)
  1410.  moveForward(7)
  1411.  
  1412.  buildBase(true)
  1413.  
  1414.  print("Finally set up the farm! Enjoy!")
  1415.  print("Flip the lever for the redstone engine.")
  1416.  print("")
  1417.  print("Press Enter to get back into the menu!")
  1418.  read()
  1419. end
  1420.  
  1421. -- EXPAND FUNCTIONS
  1422.  
  1423. function destroy()
  1424.  turtle.turnRight()
  1425.  moveForward(3)
  1426.  dd()
  1427.  dd()
  1428.  dd()
  1429.  turtle.turnRight()
  1430.  turtle.select(obsidianpipeexpand)
  1431.  fd()
  1432.  turtle.turnRight()
  1433.  turtle.select(pipeexpand)
  1434.  fd()
  1435.  turtle.select(blockslot)
  1436.  turtle.turnLeft()
  1437.  df(3)
  1438.  turtle.select(16)
  1439.  turtle.dig()
  1440.  turtle.forward()
  1441.  turtle.select(blockslot)
  1442.  turtle.turnLeft()
  1443.  du()
  1444.  dfd(2)
  1445.  df(9)
  1446.  turtle.turnLeft()
  1447.  df(9)
  1448.  turtle.turnLeft()
  1449.  df(8)
  1450.  dfd(2)
  1451.  if turtle.detectDown() then
  1452.   turtle.select(16)
  1453.   turtle.digDown()
  1454.   turtle.select(blockslot)
  1455.  end
  1456.  dd()
  1457.  if turtle.detectDown() then
  1458.   turtle.select(16)
  1459.   turtle.digDown()
  1460.   turtle.select(blockslot)
  1461.  end
  1462.  dd()
  1463.  turtle.turnLeft()
  1464.  df(8)
  1465.  turtle.turnLeft()
  1466.  df(1)
  1467.  turtle.turnLeft()
  1468.  df(7)
  1469.  turtle.turnRight()
  1470.  du()
  1471.  df(1)
  1472.  for i=1,4 do
  1473.   df(7)
  1474.   turtle.turnRight()
  1475.   df(1)
  1476.   turtle.turnRight()
  1477.   df(7)
  1478.   if i < 4 then
  1479.    turtle.turnLeft()
  1480.    fd()
  1481.    turtle.turnLeft()
  1482.   end
  1483.  end
  1484.  forward()
  1485. end
  1486.  
  1487. function layout(expanding)
  1488.  turtle.select(blockslot)
  1489.  if expanding then
  1490.   forward()
  1491.   du()
  1492.   du()
  1493.   du()
  1494.   fd()
  1495.   turtle.turnLeft()
  1496.   db()
  1497.   db()
  1498.  end
  1499.  turtle.digDown()
  1500.  turtle.placeDown()
  1501.  fde(7)
  1502.  for i=1,3 do
  1503.   turtle.turnLeft()
  1504.   fde(7)
  1505.   df()
  1506.   dd()
  1507.   turtle.digDown()
  1508.   turtle.placeDown()
  1509.   fde(1)
  1510.   du()
  1511.   db()
  1512.   turtle.digDown()
  1513.   turtle.placeDown()
  1514.   fde(9)
  1515.  end
  1516.  turtle.turnLeft()
  1517.  fde(6)
  1518.  turtle.turnLeft()
  1519.  df()
  1520.  turtle.turnRight()
  1521.  for i=1,10 do
  1522.   df()
  1523.  end
  1524.  turtle.turnLeft()
  1525.  for i=1,8 do
  1526.   df()
  1527.  end
  1528. end
  1529.  
  1530. function corners()
  1531.  dd()
  1532.  for i=1,4 do
  1533.   fde(7)
  1534.   turtle.turnLeft()
  1535.   fde(6)
  1536.   turtle.turnLeft()
  1537.   df()
  1538.   turtle.turnLeft()
  1539.   fde(5)
  1540.   turtle.turnRight()
  1541.   fde(4)
  1542.   turtle.turnRight()
  1543.   df()
  1544.   turtle.turnRight()
  1545.   fde(3)
  1546.   turtle.turnLeft()
  1547.   fde(2)
  1548.   db()
  1549.   turtle.turnLeft()
  1550.   fde(1)
  1551.   turtle.turnRight()
  1552.   turtle.turnRight()
  1553.   for i=1,3 do
  1554.    df()
  1555.   end
  1556.   turtle.turnLeft()
  1557.   for i=1,5 do
  1558.    df()
  1559.   end
  1560.  end
  1561. end
  1562.  
  1563. function lines(j)
  1564.  fde(j)
  1565.  db()
  1566.  turtle.turnLeft()
  1567.  fde(1)
  1568.  turtle.turnLeft()
  1569.  fde(j-2)
  1570.  if j > 4 then
  1571.   db()
  1572.   turtle.turnRight()
  1573.   fde(1)
  1574.   turtle.turnRight()
  1575.   lines(j-4)
  1576.  end
  1577. end
  1578.  
  1579. function plateau()
  1580.  dd()
  1581.  db()
  1582.  turtle.digDown()
  1583.  turtle.placeDown()
  1584.  turtle.turnLeft()
  1585.  lines(15)
  1586.  turtle.turnLeft()
  1587.   for i=1,8 do
  1588.    df()
  1589.   end
  1590.  turtle.turnLeft()
  1591.   for i=1,8 do
  1592.    df()
  1593.   end
  1594.  turtle.turnRight()
  1595.  turtle.turnRight()
  1596.  turtle.digDown()
  1597.  turtle.placeDown()
  1598.  lines(15)
  1599. end
  1600.  
  1601. function pipeAndDirt()
  1602.  db()
  1603.  turtle.turnLeft()
  1604.  moveForward(9)
  1605.  turtle.select(dirtexpand)
  1606.  turtle.digUp()
  1607.  fd()
  1608.  turtle.digUp()
  1609.  turtle.turnRight()
  1610.  fd()
  1611.  turtle.digUp()
  1612.  turtle.turnRight()
  1613.  fd()
  1614.  turtle.digUp()
  1615.  fd()
  1616.  turtle.placeUp()
  1617.  fd()
  1618.  turtle.placeUp()
  1619.  turtle.turnRight()
  1620.  fd()
  1621.  turtle.placeUp()
  1622.  turtle.turnRight()
  1623.  fd()
  1624.  turtle.placeUp()
  1625.  dd()
  1626.  turtle.select(obsidianpipeexpand)
  1627.  turtle.placeUp()
  1628.  dd()
  1629.  turtle.select(pipeexpand)
  1630.  turtle.placeUp()
  1631.  for i=1,10 do
  1632.   fd()
  1633.   turtle.turnLeft()
  1634.   turtle.turnLeft()
  1635.   turtle.place()
  1636.   turtle.turnLeft()
  1637.   turtle.turnLeft()
  1638.  end
  1639.  fd()
  1640.  for i=1,5 do
  1641.   du()
  1642.  end
  1643.  db()
  1644.  turtle.turnRight()
  1645.  fd()
  1646.  dd()
  1647. end
  1648.  
  1649. -- EXPAND
  1650.  
  1651. function FWCexpand()
  1652.  print("Expanding farm!")
  1653.  print("The refueling needs around 8 coal!")
  1654.  while turtle.getFuelLevel() < 600 do
  1655.   turtle.select(coal)
  1656.   if turtle.refuel(1) then
  1657.    print("Refueling!")
  1658.   else
  1659.    print("Didn't refueled!")
  1660.    sleep(1)
  1661.   end
  1662.  end
  1663.  blockslot = 5
  1664.  destroy()
  1665.  layout(true)
  1666.  corners()
  1667.  plateau()
  1668.  pipeAndDirt()
  1669.  print("Finished!")
  1670.  print("Press Enter to get back into the menu!")
  1671.  read()
  1672. end
  1673.  
  1674. -- UWC BUILD EXPANDED FARM RIGHT AWAY
  1675.  
  1676. function UWCbuildexpanded()
  1677.  local doesItDig = true
  1678.  if turtle.detectDown() then
  1679.   print("There is a block underneath the turtle.")
  1680.  end
  1681.  print("Do you want the turtle to dig the needed space for you?")
  1682.  print("Y/N")
  1683.  local id, key = os.pullEvent("key")
  1684.  if key == 49  then
  1685.   doesItDig = false
  1686.   print("Start building!")
  1687.   turtle.turnLeft()
  1688.   turtle.turnLeft()
  1689.  end
  1690.  if doesItDig then
  1691.   turtle.select(1)
  1692.   print("Place a charcoal in slot 1 (top left, the selected one)")
  1693.   while turtle.getItemCount(1) == 0 do sleep(1) end
  1694.   print("Start building and digging!")
  1695.   turtle.refuel(1)
  1696.   sleep(1)
  1697.   du()
  1698.   db()
  1699.   db()
  1700.   dd()
  1701.   UWCdigBaseSpace()
  1702.   forward()
  1703.   turtle.turnLeft()
  1704.   forward()
  1705.   for i=1,16 do
  1706.    if turtle.getItemCount(i) > 0 then
  1707.     turtle.select(i)
  1708.     turtle.drop()
  1709.    end
  1710.   end
  1711.  end
  1712.  sleep(1)
  1713.  for i=1,16 do
  1714.   turtle.select(i)
  1715.   turtle.suck()
  1716.  end
  1717.  turtle.select(1)
  1718.  turtle.refuel(8)
  1719.  turtle.turnLeft()
  1720.  turtle.turnLeft()
  1721.  buildBase(false)
  1722.  turtle.turnLeft()
  1723.  for i=4,5 do
  1724.   turtle.select(i)
  1725.   turtle.transferTo(i-2)
  1726.  end
  1727.  turtle.select(8)
  1728.  turtle.transferTo(4)
  1729.  for i=13,15 do
  1730.   turtle.select(i)
  1731.   turtle.transferTo(i-8)
  1732.  end
  1733.  turtle.select(5)
  1734.  for i=1,3 do
  1735.   turtle.suck()
  1736.  end
  1737.  turtle.turnLeft()
  1738.  turtle.turnLeft()
  1739.  moveForward(3)
  1740.  turtle.turnRight()
  1741.  moveForward(2)
  1742.  turtle.turnRight()
  1743.  fd()
  1744.  turtle.turnLeft()
  1745.  blockslot = 5
  1746.  layout(false)
  1747.  corners()
  1748.  plateau()
  1749.  pipeAndDirt()
  1750.  print("Finished building the expanded farm!")
  1751.  print("Please take ALL items out of the inventory!")
  1752.  print("Press Enter to get back into the menu!")
  1753.  read()
  1754. end
  1755.  
  1756.  
  1757. --FWChelp 77777777777777777777777777777777777777777
  1758.  
  1759. function FWChelp()
  1760.  print("Welcome to the UWC Help Interface!")
  1761.  print("If you have any question, suggestions, bugs or feedback, let me know: Type")
  1762.  print("computercraft forum ultimate wood chopper")
  1763.  print("in Google and write a post or PM at me ;D")
  1764.  read()
  1765. end
  1766.  
  1767. --FWCposition 999999999999999999999999999999999999
  1768.  
  1769. function FWCposition()
  1770.  turtle.select(coal)
  1771.  turtle.refuel(1)
  1772.  up()
  1773.  up()
  1774.  up()
  1775.  up()
  1776.  turtle.turnRight()
  1777.  forward()
  1778.  forward()
  1779.  forward()
  1780.  forward()
  1781.  turtle.turnLeft()
  1782.  forward()
  1783.  forward()
  1784.  print(" ")
  1785.  print("Turtle in Base. Ready to set up farm.")
  1786.  print("Be sure the turtle has all the materials it needs.")
  1787.  print("Press Enter to get back into the menu.")
  1788.  read()
  1789. end
  1790.  
  1791. --FWCexpandchests
  1792.  
  1793. function FWCexpandchests()
  1794.  print("Adding more chests!")
  1795.  local amount = turtle.getItemCount(2)
  1796.  turtle.turnLeft()
  1797.  while not turtle.detectUp() do
  1798.   turtle.up()
  1799.  end
  1800.  turtle.select(3)
  1801.  turtle.digUp()
  1802.  turtle.select(2)
  1803.  while amount > 0 do
  1804.   up()
  1805.   turtle.place()
  1806.   amount = amount-1
  1807.  end
  1808.  turtle.select(3)
  1809.  turtle.placeUp()
  1810.  while turtle.down() do end
  1811.  turtle.turnRight()
  1812.  print("Finsihed!")
  1813.  print("Press Enter to get back into the menu.")
  1814.  read()
  1815. end
  1816.  
  1817. --FWCtwobytwo
  1818.  
  1819. function FWCtwobytwo()
  1820.  print("Chopping down 2x2 tree.")
  1821.  while turtle.getFuelLevel() < 200 do
  1822.   sleep(2)
  1823.   turtle.select(1)
  1824.   turtle.refuel(1)
  1825.   print("Refueled!")
  1826.  end
  1827.  savestate = 2
  1828.  cutWood()
  1829.  print("Press Enter to get back into the menu.")
  1830.  read()
  1831. end
  1832.  
  1833. --FWConebyone
  1834.  
  1835. function FWConebyone()
  1836.  print("Chopping down 1x1 tree.")
  1837.  while turtle.getFuelLevel() < 200 do
  1838.   sleep(2)
  1839.   turtle.select(1)
  1840.   turtle.refuel(1)
  1841.   print("Refueled!")
  1842.  end
  1843.  turtle.select(2)
  1844.  turtle.dig()
  1845.  forward()
  1846.  while turtle.compareUp() do
  1847.   turtle.digUp()
  1848.   up()
  1849.  end
  1850.  while not turtle.detectDown() do
  1851.   turtle.down()
  1852.  end
  1853.  print("Finsihed!")
  1854.  print("Press Enter to get back into the menu.")
  1855.  read()
  1856. end
  1857.  
  1858. --FWCdigSpace
  1859.  
  1860. function UWCdigBaseSpace()
  1861.  turtle.turnLeft()
  1862.  forward()
  1863.  turtle.turnRight()
  1864.  dd()
  1865.  dd()
  1866.  for i=1,3 do
  1867.   for j=1,4 do
  1868.    turtle.dig()
  1869.    forward()
  1870.    turtle.digUp()
  1871.   end
  1872.   if i<3 then
  1873.    for j=1,4 do
  1874.     back()
  1875.    end
  1876.    turtle.turnRight()
  1877.    turtle.dig()
  1878.    forward()
  1879.    turtle.digUp()
  1880.    turtle.turnLeft()
  1881.   end
  1882.  end
  1883.  back()
  1884.  turtle.digDown()
  1885.  db()
  1886.  turtle.digDown()
  1887.  df()
  1888.  up()
  1889.  up()
  1890.  turtle.turnLeft()
  1891. end
  1892.  
  1893. function FWCdigSpace()
  1894.  os.sleep(2)
  1895.  turtle.select(1)
  1896.  turtle.refuel(5)
  1897.  back()
  1898.  back()
  1899.  UWCdigBaseSpace()
  1900.  moveForward(5)
  1901.  turtle.turnRight()
  1902.  forward()
  1903.  turtle.digDown()
  1904.  down()
  1905.  turtle.digDown()
  1906.  down()
  1907.  turtle.digDown()
  1908.  for i=1,5 do
  1909.   for j=1,11 do
  1910.    turtle.dig()
  1911.    turtle.forward()
  1912.    turtle.digUp()
  1913.    turtle.digDown()
  1914.   end
  1915.   turtle.turnRight()
  1916.   turtle.dig()
  1917.   turtle.forward()
  1918.   turtle.turnRight()
  1919.   turtle.digUp()
  1920.   turtle.digDown()
  1921.   for j=1,11 do
  1922.    turtle.dig()
  1923.    turtle.forward()
  1924.    turtle.digUp()
  1925.    turtle.digDown()  
  1926.   end
  1927.   if i < 5 then
  1928.    turtle.turnLeft()
  1929.    turtle.dig()
  1930.    turtle.forward()
  1931.    turtle.turnLeft()
  1932.    turtle.digDown()
  1933.    turtle.digUp()
  1934.   end
  1935.  end
  1936.  turtle.back()
  1937.  turtle.turnRight()
  1938.  turtle.forward()
  1939.  turtle.down()
  1940.  turtle.digDown()
  1941.  turtle.down()
  1942.  for i=1,8 do
  1943.   turtle.turnRight()
  1944.   turtle.dig()
  1945.   turtle.turnLeft()
  1946.   turtle.dig()
  1947.   turtle.forward()
  1948.  end
  1949.  turtle.turnLeft()
  1950.  turtle.up()
  1951.  turtle.up()
  1952.  turtle.up()
  1953.  turtle.up()
  1954.  turtle.turnLeft()
  1955.  moveForward(4)
  1956.  turtle.turnRight()
  1957.  moveForward(3)
  1958.  turtle.turnLeft()
  1959.  turtle.turnLeft()
  1960.  print("Finished!")
  1961.  print("Press Enter to get back into the menu!")
  1962.  read()
  1963. end
  1964.  
  1965. -- VARIABLE CHANGE MENU
  1966.  
  1967. function varBonemeal()
  1968.  local input = 0
  1969.  
  1970.  print("Bonemeal")
  1971.  print("Should the turtle take out bonemeal of the chest and use it on the tree to get wood faster?")
  1972.  print("If not the turtle will wait until the tree is fully grown.")
  1973.  print("Standard: true")
  1974.  print("Use bonemeal: 1")
  1975.  print("Dont use bonemeal: 0")
  1976.  print("Current: " .. tostring(usebonemeal))
  1977.  input = tonumber(read())
  1978.  if input then
  1979.   input = math.floor(input)
  1980.   if input == 1 then usebonemeal = true
  1981.   elseif input == 0 then usebonemeal = false end
  1982.  end
  1983.  clearScreen()
  1984.  
  1985.  print("Set to: " .. tostring(usebonemeal))
  1986.  print("")
  1987.  print("Bonemeal")
  1988.  print("How many bonemeal should be used on the tree at the same time if the turtle should use it?")
  1989.  print("Standard: 2")
  1990.  print("Minimum: 1")
  1991.  print("Maximum: 10")
  1992.  print("Current: " .. amountbonemealtimes)
  1993.  input = tonumber(read())
  1994.  if input then
  1995.   input = math.floor(input)
  1996.   if input >= 1 and input <= 10 then amountbonemealtimes = input end
  1997.  end
  1998.  clearScreen()
  1999.  
  2000.  print("Set to: " .. amountbonemealtimes)
  2001.  print("")
  2002.  print("Saving variables...")
  2003.  saveVariables()
  2004.  sleep(0.2)
  2005.  print("Saved variables!")
  2006.  sleep(0.2)
  2007. end
  2008.  
  2009. function varAmount()
  2010.  local input = 0
  2011.  
  2012.  print("Amount")
  2013.  print("Turtle needs this amount or more bonemeal in slot 2 before keep going.")
  2014.  print("Standard: 8")
  2015.  print("Minimum: 3 Maximum: 64")
  2016.  print("Current: " .. amountMinBonemeal)
  2017.  input = tonumber(read())
  2018.  if input then
  2019.   input = math.floor(input)
  2020.   if input > 2 and input < 65 then amountMinBonemeal = input end
  2021.  end
  2022.  clearScreen()
  2023.  
  2024.  print("Set to: " .. amountMinBonemeal)
  2025.  print("")
  2026.  print("Amount")
  2027.  print("Turtle needs this amount or more saplings in slot 1 before keep going.")
  2028.  print("Standard: 17")
  2029.  print("Minimum: 5 Maximum: 64")
  2030.  print("Current: " .. amountMinSaplings)
  2031.  input = tonumber(read())
  2032.  if input then
  2033.   input = math.floor(input)
  2034.   if input > 4 and input < 65 then amountMinSaplings = input end
  2035.  end
  2036.  clearScreen()
  2037.  
  2038.  print("Set to: " .. amountMinSaplings)
  2039.  print("")
  2040.  print("Amount")
  2041.  print("After chopping down trees, the turtle places some wood into the furnace.")
  2042.  print("How many wood should be put into the furnace if bonemeal is used?")
  2043.  print("Standard: 16")
  2044.  print("Minimum: 0  Maximum: 64")
  2045.  print("Current: " .. amountFurnaceWoodBonemeal)
  2046.  input = tonumber(read())
  2047.  if input then
  2048.   input = math.floor(input)
  2049.   if input >= 0 and input < 65 then amountFurnaceWoodBonemeal = input end
  2050.  end
  2051.  clearScreen()
  2052.  
  2053.  print("Set to: " .. amountFurnaceWoodBonemeal)
  2054.  print("")
  2055.  print("Amount")
  2056.  print("After chopping down trees, the turtle places some wood into the furnace.")
  2057.  print("How many wood should be put into the furnace if no bonemeal is used?")
  2058.  print("Standard: 8")
  2059.  print("Minimum: 0  Maximum: 64")
  2060.  print("Current: " .. amountFurnaceWoodNoBonemeal)
  2061.  input = tonumber(read())
  2062.  if input then
  2063.   input = math.floor(input)
  2064.   if input >= 0 and input < 65 then amountFurnaceWoodNoBonemeal = input end
  2065.  end
  2066.  clearScreen()
  2067.  
  2068.  print("Set to: " .. amountFurnaceWoodNoBonemeal)
  2069.  print("Amount")
  2070.  print("At base the turtle refuels charcoal up to this fuel level before chopping down more trees.")
  2071.  print("Standard: 1200")
  2072.  print("Set this to 0 if you dont want the turtle to use coal!")
  2073.  print("Current: " .. amountMinFuelLevel)
  2074.  input = tonumber(read())
  2075.  if input then
  2076.   input = math.floor(input)
  2077.   if input >= 0 then amountMinFuelLevel = input end
  2078.  end
  2079.  clearScreen()
  2080.  
  2081.  print("Set to: " .. amountMinFuelLevel)
  2082.  print("")
  2083.  print("Saving variables...")
  2084.  saveVariables()
  2085.  sleep(0.2)
  2086.  print("Saved variables!")
  2087.  sleep(0.2)
  2088. end
  2089.  
  2090. function varTimer()
  2091.  local input = 0
  2092.  
  2093.  print("Timer")
  2094.  print("Turtle fails to take enough materials out of a chest.")
  2095.  print("How long does he waits until it tries again?")
  2096.  print("In this time the turtle can be terminated by the user.")
  2097.  print("Standard: 2")
  2098.  print("Minimum: 1")
  2099.  print("Current: " .. cancelTimer)
  2100.  input = tonumber(read())
  2101.  if input then
  2102.   input = math.floor(input)
  2103.   if input >= 1 then cancelTimer = input end
  2104.  end
  2105.  clearScreen()
  2106.  
  2107.  print("Set to: " .. cancelTimer)
  2108.  print("")
  2109.  print("Timer")
  2110.  print("Turtle fails to fertilize the tree with bonemeal.")
  2111.  print("How long should it wait until it tries again?")
  2112.  print("Standard: 120")
  2113.  print("Current: " .. bonemealTimer)
  2114.  input = tonumber(read())
  2115.  if input then
  2116.   input = math.floor(input)
  2117.   if input >= 0 then bonemealTimer = input end
  2118.  end
  2119.  clearScreen()
  2120.  
  2121.  print("Set to: " .. bonemealTimer)
  2122.  print("")
  2123.  print("Timer")
  2124.  print("Turtle planted the saplings.")
  2125.  print("How long should the turtle wait before fertilizing the first time?")
  2126.  print("Standard: 0")
  2127.  print("Current: " .. bonemealFirstDelay)
  2128.  input = tonumber(read())
  2129.  if input then
  2130.   input = math.floor(input)
  2131.   if input >= 0 then bonemealFirstDelay = input end
  2132.  end
  2133.  clearScreen()
  2134.  
  2135.  print("Set to: " .. bonemealFirstDelay)
  2136.  print("")
  2137.  print("Saving variables...")
  2138.  saveVariables()
  2139.  sleep(0.2)
  2140.  print("Saved variables!")
  2141.  sleep(0.2)
  2142. end
  2143.  
  2144. function varSlot()
  2145.  local input = 0
  2146.  
  2147.  print("Slot")
  2148.  print("Turtle goes back to base if the inventory slot has items in it.")
  2149.  print("Which slot should it be if the turtle uses bonemeal?")
  2150.  print("Standard: 14")
  2151.  print("Minimum: 3  Maximum: 16")
  2152.  print("Current: " .. amountMaxWoodSlotBonemeal)
  2153.  turtle.select(tonumber(amountMaxWoodSlotBonemeal))
  2154.  input = tonumber(read())
  2155.  if input then
  2156.   input = math.floor(input)
  2157.   if input >= 3 and input <= 16 then amountMaxWoodSlotBonemeal = input end
  2158.  end
  2159.  clearScreen()
  2160.  
  2161.  print("Set to: " .. amountMaxWoodSlotBonemeal)
  2162.  print("")
  2163.  print("Slot")
  2164.  print("Turtle goes back to base if inventory slot has items in it.")
  2165.  print("Which slot should it be if the turtle doesnt use bonemeal?")
  2166.  print("Standard: 7")
  2167.  print("Minimum: 2  Maximum: 16")
  2168.  print("Current: " .. amountMaxWoodSlotNoBonemeal)
  2169.  turtle.select(tonumber(amountMaxWoodSlotNoBonemeal))
  2170.  input = tonumber(read())
  2171.  if input then
  2172.   input = math.floor(input)
  2173.   if input >= 2 and input <= 16 then amountMaxWoodSlotNoBonemeal = input end
  2174.  end
  2175.  clearScreen()
  2176.  
  2177.  print("Set to: " .. amountMaxWoodSlotNoBonemeal)
  2178.  print("")
  2179.  print("Saving variables...")
  2180.  saveVariables()
  2181.  sleep(0.2)
  2182.  print("Saved variables!")
  2183.  sleep(0.2)
  2184. end
  2185.  
  2186. function varHeight()
  2187.  local input = 0
  2188.  
  2189.  print("Height")
  2190.  print("If the turtle debugs the farm, it checks how height it is.")
  2191.  print("At which height should it turn back down?")
  2192.  print("Standard: 55")
  2193.  print("Minimum: 1  Maximum: 200")
  2194.  print("Current: " .. debugMaxHeight)
  2195.  input = tonumber(read())
  2196.  if input then
  2197.   input = math.floor(input)
  2198.   if input > 0 and input < 201 then debugMaxHeight = input end
  2199.  end
  2200.  clearScreen()
  2201.  
  2202.  print("Set to: " ..debugMaxHeight)
  2203.  print("")
  2204.  print("Saving variables...")
  2205.  saveVariables()
  2206.  sleep(0.2)
  2207.  print("Saved variables!")
  2208.  sleep(0.2)
  2209. end
  2210.  
  2211. function varPersistence()
  2212.  print("Persistence")
  2213.  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.")
  2214.  print("")
  2215.  persistence = not persistence
  2216.  term.write("Persistence is ")
  2217.  if persistence then
  2218.   print("ENABLED!")
  2219.  else
  2220.   print("DISABLED!")
  2221.  end
  2222.  print("")
  2223.  print("Saving variables...")
  2224.  saveVariables()
  2225.  sleep(0.2)
  2226.  print("Saved variables!")
  2227.  sleep(7)
  2228. end
  2229.  
  2230.  
  2231. function UWCvariables()
  2232.  print("Welcome in the variable change menu.")
  2233.  print("You have the choice to individualise your chopping turtle.")
  2234.  print("These variables are just used for the farm and get saved and loaded every time.")
  2235.  read()
  2236.  print("Select a type of variables and you are getting shown the variables one by one.")
  2237.  read()
  2238.  print("If you want to skip a variable and leave it where it is, you just have to press Enter.")
  2239.  read()
  2240.  print("If you want to change a variable, type in the number and press Enter.")
  2241.  print("Press Enter to continue...")
  2242.  read()
  2243.  clearScreen()
  2244. end
  2245.  
  2246.  
  2247. function UWCgodown()
  2248.  while not turtle.detectDown() do
  2249.   turtle.down()
  2250.  end
  2251. end
  2252.  
  2253. function control()
  2254.  local blockslot = 1
  2255.  local mode = "move"
  2256.  local working = true
  2257.  turtle.select(blockslot)
  2258.  
  2259.  function info()
  2260.   clearScreen()
  2261.   print("Navigate your turtle with your keyboard.")
  2262.   print("W A S D --- Horizontal")
  2263.   print("Space SHIFT --- Vertical")
  2264.   print("E --- Switch between dig mode/ place mode/ move mode")
  2265.   print("Q --- Select next slot")
  2266.   print("Strg --- Leave the conrol interface.")
  2267.   print("")
  2268.   print("Turtle Mode: " .. mode)
  2269.  end
  2270.  
  2271.  while working do
  2272.   info()
  2273.   local id, key = os.pullEvent("key")
  2274.   if key == 29 then
  2275.    working = false
  2276.   elseif key == 16 then
  2277.    blockslot = blockslot + 1
  2278.    if blockslot == 17 then
  2279.     blockslot = 1
  2280.    end
  2281.    turtle.select(blockslot)
  2282.   elseif key == 30 then
  2283.    turtle.turnLeft()
  2284.   elseif key == 31 then
  2285.    turtle.back()
  2286.   elseif key == 32 then
  2287.    turtle.turnRight()
  2288.  
  2289.   elseif mode == "move" then
  2290.    if key == 17 then
  2291.     turtle.forward()
  2292.    elseif key == 57 then
  2293.     turtle.up()
  2294.    elseif key == 42 then
  2295.     turtle.down()
  2296.    elseif key == 18 then
  2297.     mode = "dig"
  2298.    end
  2299.  
  2300.   elseif mode == "dig" then
  2301.    if key == 17 then
  2302.     turtle.dig()
  2303.    elseif key == 57 then
  2304.     turtle.digUp()
  2305.    elseif key == 42 then
  2306.     turtle.digDown()
  2307.    elseif key == 18 then
  2308.     mode = "place"
  2309.    end
  2310.  
  2311.   elseif mode == "place" then
  2312.    if key == 17 then
  2313.     turtle.place()
  2314.    elseif key == 57 then
  2315.     turtle.placeUp()
  2316.    elseif key == 42 then
  2317.     turtle.placeDown()
  2318.    elseif key == 18 then
  2319.     mode = "move"
  2320.    end
  2321.   end
  2322.  end
  2323. end
  2324.  
  2325.  
  2326. --MAIN PROGRAM
  2327.  
  2328. if fs.exists(savefile) then
  2329.  loadVariables()
  2330. end
  2331.  
  2332. checkForLastSession()
  2333.  
  2334. while running == true do
  2335.  runMenu()
  2336. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement