Advertisement
Guest User

Untitled

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