CCJJSax

AltoOS

Apr 3rd, 2013
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 24.34 KB | None | 0 0
  1. cv_AltoOS = 1.2
  2.  
  3. casedisplay = 0
  4. lastbutton = "just started"
  5.  
  6. if fs.exists("helpcenter") then
  7.     HelpCenterbutton = "?"
  8. elseif fs.exists("helpcenter") == false then
  9.     shell.run("pastebin get WBHDDpch helpcenter")
  10.     HelpCenterbutton = " "
  11. end
  12.  
  13. if fs.exists("sorter") then
  14.     Sorteri = "i"
  15. elseif fs.exists("sorter") == false then
  16.     Sorteri = " "
  17. end
  18.  
  19. local function labelget()
  20.     if os.getComputerLabel() == nil then
  21.         tlabel = " ID: "..os.getComputerID()
  22.         infoget = "Label your computer!"
  23.     else
  24.         tlabel = string.sub(os.getComputerLabel(),1,18)
  25.         infoget = nil
  26.     end
  27. end
  28.  
  29. local function getperipheraltype()
  30.     if peripheral.getType("right") == "workbench" then
  31.         peripheraltype = "c"
  32.     else
  33.         peripheraltype = " "
  34.     end
  35. end
  36. getperipheraltype()
  37. labelget()
  38.  
  39. local function checkFuel()
  40.     if turtle.getFuelLevel() <50 then
  41.         infoget = nil
  42.         if turtle.refuel() == false then
  43.         x = 1
  44.             repeat
  45.                 turtle.select(x)
  46.                 turtle.refuel()
  47.                 x = x+1
  48.             until turtle.getFuelLevel() > 50 or x == 17
  49.         end
  50.         if turtle.getFuelLevel() > 50 then
  51.             infoget = "turtle needs fuel"
  52.         else
  53.             infoget = nil
  54.         end
  55.     turtle.select(1)
  56.     end
  57. end
  58.  
  59.  
  60. local function movementdisplay()
  61.     checkFuel()
  62.     labelget()
  63.     if casedisplay == 0 then
  64.         term.clear()
  65.         term.setCursorPos(1, 1)
  66.         print("Lower case display: "..tlabel)
  67.             if turtle.getFuelLevel() == 0 then
  68.                 while turtle.getFuelLevel() <= 9 do
  69.                     term.clear()
  70.                     term.setCursorPos(1,1)
  71.                     print("Waiting for fuel")
  72.                     checkFuel()
  73.                     sleep(4)
  74.                 end
  75.                 os.reboot()
  76.             elseif turtle.getFuelLevel() <= 50 then
  77.                 print("What shall I do?     Very Low Fuel: "..turtle.getFuelLevel())
  78.             elseif turtle.getFuelLevel() <= 150 then
  79.                 print("What shall I do?     Low Fuel: "..turtle.getFuelLevel())
  80.             elseif turtle.getFuelLevel() > 999999 then
  81.                 print("What shall I do?     Fuel level: Enough")
  82.             elseif turtle.getFuelLevel() <= 999999 then  
  83.                 print("What shall I do?     Fuel level: "..turtle.getFuelLevel())
  84.             end
  85.         print("Press ~ to run any program.")
  86.         print("Press ' to change display case.")
  87.         print("~                  -  +")
  88.         print("q w e r   y   "..Sorteri.."          |           -")
  89.         print("a s d     h         '       4  5  6  +")
  90.         print("z   "..peripheraltype.." v        , . "..HelpCenterbutton.."           2      ")
  91.         print("I "..lastbutton..".")
  92.             if infoget == nil then
  93.                 if turtle.getFuelLevel() < 50 then
  94.                     infoget = "turtle needs fuel"
  95.                 end
  96.             else
  97.                 print("Extra info: "..infoget)
  98.             end
  99.     else
  100.         term.clear()
  101.         term.setCursorPos(1, 1)
  102.         print("Upper case display: "..tlabel)
  103.             if turtle.getFuelLevel() == 0 then
  104.                 while turtle.getFuelLevel() <= 9 do
  105.                     term.clear()
  106.                     term.setCursorPos(1,1)
  107.                     print("Waiting for fuel")
  108.                     checkFuel()
  109.                     sleep(4)
  110.                 end
  111.                 os.reboot()
  112.             elseif turtle.getFuelLevel() <= 50 then
  113.                 print("What shall I do?     Very Low Fuel: "..turtle.getFuelLevel())
  114.             elseif turtle.getFuelLevel() <= 150 then
  115.                 print("What shall I do?     Low Fuel: "..turtle.getFuelLevel())
  116.             elseif turtle.getFuelLevel() > 999999 then
  117.                 print("What shall I do?     Fuel level: Enough")
  118.             elseif turtle.getFuelLevel() <= 999999 then  
  119.                 print("What shall I do?     Fuel level: "..turtle.getFuelLevel())
  120.             end
  121.         print("Press ~ to run any program.")
  122.         print("Press ' to change display case.")
  123.         print("~             ^     _   ")
  124.         print("  W                      |           -")
  125.         print("  S                         4  5  6  +")
  126.         print("               < > "..HelpCenterbutton.."           2      ")
  127.         print("I "..lastbutton..".")
  128.             if infoget == nil and turtle.getFuelLevel() < 50 then
  129.                 print("turtle needs fuel")
  130.             elseif infoget ~= false then
  131.                 print("Extra info: "..infoget)
  132.             end
  133.     end
  134. end
  135.  
  136. local function flip()
  137.     turtle.turnLeft()
  138.     turtle.turnLeft()
  139. end
  140.  
  141. local function checkdig()
  142.     x = 0
  143.     attacknumber = 0
  144.     if turtle.detect() == true then
  145.         if turtle.suck() == true then
  146.             lastbutton = "got an item from inventory"
  147.             infoget = nil
  148.         elseif turtle.detect() and turtle.dig() == true then
  149.             x = x+1
  150.             lastbutton = "mined "..x.." blocks"
  151.             infoget = nil
  152.             movementdisplay()
  153.             sleep(.5)
  154.             while turtle.dig() == true do
  155.                 x = x+1
  156.                 lastbutton = "mined "..x.." blocks"
  157.                 movementdisplay()
  158.                 sleep(.5)
  159.             end
  160.         elseif turtle.detect() and turtle.dig() == false then
  161.             lastbutton = "attempted to break block"
  162.             infoget = "failed to break"
  163.             movementdisplay()
  164.         end
  165.     elseif turtle.detect() == false then
  166.         while turtle.attack() == true do
  167.             turtle.attack()
  168.             attacknumber = attacknumber+1
  169.             lastbutton = "attacked: "..attacknumber
  170.             infoget = nil
  171.             movementdisplay()
  172.         end
  173.         if turtle.suck() then
  174.             lastbutton = "sucked up an entity"
  175.             while turtle.suck() == true do
  176.             turtle.suck()
  177.             end
  178.         elseif turtle.suck() == false and x == 0 and attacknumber == 0 then
  179.             lastbutton = "had nothing to mine"
  180.             infoget = nil
  181.         end
  182.     end
  183. end
  184.  
  185. local function checkdigUp()
  186.     x = 0
  187.     attacknumber = 0
  188.     if turtle.detectUp() then
  189.         if turtle.suckUp() == true then
  190.             lastbutton = "got an item from top inventory"
  191.             infoget = nil
  192.         elseif turtle.detectUp() and turtle.digUp() == true then
  193.                 x = x+1
  194.                 turtle.digUp()
  195.                 lastbutton = "mined "..x.." blocks above me"
  196.                 infoget = nil
  197.                 movementdisplay()
  198.                 sleep(.5)
  199.             while turtle.digUp() == true do
  200.                 x = x+1
  201.                 lastbutton = "mined "..x.." blocks above me"
  202.                 movementdisplay()
  203.                 sleep(.5)
  204.             end
  205.         elseif turtle.detectUp() and turtle.digUp() == false then
  206.             lastbutton = "attempted to break block above me"
  207.             infoget = "failed to break"
  208.             movementdisplay()
  209.         end
  210.     elseif turtle.detectUp() == false then
  211.         while turtle.attackUp() == true do
  212.             attacknumber = attacknumber+1
  213.             lastbutton = "attacked up "..attacknumber
  214.             infoget = nil
  215.             movementdisplay()
  216.         end
  217.         if turtle.suckUp() then
  218.             lastbutton = "sucked up an entity from above"
  219.             while turtle.suckUp() == true do
  220.             end
  221.         elseif turtle.suckUp() == false and x == 0 and attacknumber == 0 then
  222.             lastbutton = "had nothing to mine above me"
  223.             infoget = nil
  224.         end
  225.     end
  226. end
  227.  
  228. local function checkdigDown()
  229.     x = 0
  230.     attacknumber = 0
  231.     if turtle.detectDown() then
  232.         if turtle.suckDown() == true then
  233.             lastbutton = "got an item from bottom inventory"
  234.             infoget = nil
  235.         else
  236.             while turtle.detectDown() do
  237.                 x = x+1
  238.                 turtle.digDown()
  239.                 lastbutton = "mined "..x.." blocks below me"
  240.                 infoget = nil
  241.                 movementdisplay()
  242.                 sleep(.5)
  243.             end
  244.         end
  245.     elseif turtle.detectDown() == false then
  246.         while turtle.attackDown() == true do
  247.             turtle.attackDown()
  248.             attacknumber = attacknumber+1
  249.             lastbutton = "attacked down "..attacknumber
  250.             infoget = nil
  251.             movementdisplay()
  252.         end
  253.         if turtle.suckDown() then
  254.             lastbutton = "sucked up an entity from below"
  255.             while turtle.suckDown() == true do
  256.                 turtle.suckDown()
  257.             end
  258.         elseif turtle.suckDown() == false and x == 0 and attacknumber == 0 then
  259.             lastbutton = "had nothing to mine below me"
  260.             infoget = nil
  261.         end
  262.     end
  263. end
  264.  
  265. local function checkdigLeft()
  266.     turtle.turnLeft()
  267.     checkdig()
  268.     if lastbutton == "got an item from inventory" then
  269.         lastbutton = "grabbed item from left inventory"
  270.         infoget = nil
  271.     elseif lastbutton == "mined "..x.." blocks" then
  272.         lastbutton = "mined "..x.." blocks to the left"
  273.         infoget = nil
  274.     elseif lastbutton == "sucked up an entity" then
  275.         lastbutton = "sucked entity from the left"
  276.         infoget = nil
  277.     elseif infoget == "failed to break" then
  278.         lastbutton = "failed to break block to the left"
  279.         infoget = nil
  280.     elseif lastbutton == "had nothing to mine" then
  281.         lastbutton = "had nothing to mine to the left"
  282.     elseif attacknumber > 0 then
  283.         lastbutton = "attacked "..attacknumber.." to the left"
  284.     end
  285.     turtle.turnRight()
  286. end
  287.  
  288. local function checkdigRight()
  289.     turtle.turnRight()
  290.     checkdig()
  291.     if lastbutton == "got an item from inventory" then
  292.         lastbutton = "grabbed item from right inventory"
  293.         infoget = nil
  294.     elseif lastbutton == "mined "..x.." blocks" then
  295.         lastbutton = "mined "..x.." blocks to the right"
  296.         infoget = nil
  297.     elseif lastbutton == "sucked up an entity" then
  298.         lastbutton = "sucked entity from the right"
  299.         infoget = nil
  300.     elseif infoget == "failed to break" then
  301.         lastbutton = "failed to break block to the right"
  302.         infoget = nil
  303.     elseif lastbutton == "had nothing to mine" then
  304.         lastbutton = "had nothing to mine to the right"
  305.     elseif attacknumber > 0 then
  306.         lastbutton = "attacked "..attacknumber.." to the right"
  307.     end
  308.     turtle.turnLeft()
  309. end  
  310.  
  311. local function moveForward()
  312.     checkdig()
  313.     if lastbutton == "got an item from inventory" then
  314.         lastbutton = "couldn't move forward due to chest"
  315.         infoget = "sucked an item from chest"
  316.     elseif lastbutton == "mined "..x.." blocks" then
  317.         turtle.forward()
  318.         lastbutton = "mined "..x.." blocks and moved forward"
  319.     elseif lastbutton == "sucked up an entity" then
  320.         turtle.forward()
  321.         lastbutton = "sucked from front and moved forward"
  322.     elseif infoget == "failed to break" then
  323.         lastbutton = "cannot move forward"
  324.     elseif lastbutton == "had nothing to mine" then
  325.         lastbutton = "moved forward"
  326.         turtle.forward()
  327.     elseif attacknumber > 0 then
  328.         turtle.forward()
  329.         lastbutton = "attacked "..attacknumber.." and moved forward"
  330.     else
  331.         turtle.forward()
  332.     end
  333. end
  334.  
  335. local function moveLeft()
  336.     checkdig()
  337.     if lastbutton == "got an item from inventory" then
  338.         lastbutton = "couldn't move left due to chest"
  339.         infoget = "sucked an item from chest"
  340.     elseif lastbutton == "mined "..x.." blocks" then
  341.         turtle.forward()
  342.         lastbutton = "mined "..x.." blocks and moved left"
  343.     elseif lastbutton == "sucked up an entity" then
  344.         turtle.forward()
  345.         lastbutton = "sucked from front and moved left"
  346.     elseif infoget == "failed to break" then
  347.         lastbutton = "cannot move left"
  348.     elseif lastbutton == "had nothing to mine" then
  349.         lastbutton = "moved left"
  350.         turtle.forward()
  351.     elseif attacknumber > 0 then
  352.         turtle.forward()
  353.         lastbutton = "attacked "..attacknumber.." and moved left"
  354.     else
  355.         turtle.forward()
  356.     end
  357. end
  358.  
  359. local function moveRight()
  360.     checkdig()
  361.     if lastbutton == "got an item from inventory" then
  362.         lastbutton = "couldn't move right due to chest"
  363.         infoget = "sucked an item from chest"
  364.     elseif lastbutton == "mined "..x.." blocks" then
  365.         turtle.forward()
  366.         lastbutton = "mined "..x.." blocks and moved right"
  367.     elseif lastbutton == "sucked up an entity" then
  368.         turtle.forward()
  369.         lastbutton = "sucked from front and moved right"
  370.     elseif infoget == "failed to break" then
  371.         lastbutton = "cannot move right"
  372.     elseif lastbutton == "had nothing to mine" then
  373.         lastbutton = "moved right"
  374.         turtle.forward()
  375.     elseif attacknumber > 0 then
  376.         turtle.forward()
  377.         lastbutton = "attacked "..attacknumber.." and moved right"
  378.     else
  379.         turtle.forward()
  380.     end
  381. end
  382.  
  383. local function moveBack()
  384.     flip()
  385.         checkdig()
  386.         if lastbutton == "got an item from inventory" then
  387.             lastbutton = "couldn't move back due to chest"
  388.             infoget = "sucked an item from chest"
  389.         elseif lastbutton == "mined "..x.." blocks" then
  390.             turtle.forward()
  391.             lastbutton = "mined "..x.." blocks and moved back"
  392.         elseif lastbutton == "sucked up an entity" then
  393.             turtle.forward()
  394.             lastbutton = "sucked entity and moved back"
  395.         elseif infoget == "failed to break" then
  396.             lastbutton = "cannot move back"
  397.         elseif lastbutton == "had nothing to mine" then
  398.             lastbutton = "moved back"
  399.             turtle.forward()
  400.         elseif attacknumber > 0 then
  401.             turtle.forward()
  402.             lastbutton = "attacked "..attacknumber.." and moved back"
  403.         end
  404.  
  405. end
  406.  
  407. local function moveBackward()
  408.     infoget = "Something's in the way.  Resolving the issue now."
  409.     movementdisplay()
  410.     flip()
  411.     checkdig()
  412.     if lastbutton == "got an item from inventory" then
  413.         lastbutton = "couldn't move backward due to chest"
  414.         infoget = "sucked an item from chest"
  415.     elseif lastbutton == "mined "..x.." blocks" then
  416.         lastbutton = "mined "..x.." blocks and moved backward"
  417.     elseif infoget == "failed to break" then
  418.         lastbutton = "cannot move backward"
  419.     elseif attacknumber > 0 then
  420.         lastbutton = "attacked "..attacknumber.." and moved backward"
  421.     end
  422.     flip()
  423.     turtle.back()
  424. end
  425.  
  426. local function moveUp()
  427.     if turtle.detectUp() then
  428.         checkdigUp()
  429.         if lastbutton == "got an item from top inventory" then
  430.             lastbutton = "couldn't move up due to chest"
  431.             infoget = "sucked an item from chest"
  432.         elseif lastbutton == "mined "..x.." blocks above me" then
  433.             turtle.up()
  434.             lastbutton = "mined "..x.." blocks and moved up"
  435.         elseif lastbutton == "sucked up an entity from above" then
  436.             turtle.up()
  437.             lastbutton = "sucked entity and moved up"
  438.         elseif infoget == "failed to break" then
  439.             lastbutton = "cannot move up"
  440.         elseif lastbutton == "had nothing to mine above me" then
  441.             lastbutton = "moved up"
  442.             turtle.up()
  443.         elseif attacknumber > 0 then
  444.             turtle.up()
  445.             lastbutton = "attacked "..attacknumber.." and moved up"
  446.         end
  447.     else
  448.         turtle.up()
  449.     end
  450. end
  451.  
  452. local function moveDown()
  453.     checkdigDown()
  454.     if turtle.up() == true then
  455.         while turtle.suckUp() do
  456.         end
  457.         infoget = "Nothing was there"
  458.         movementdisplay()
  459.     elseif turtle.up() == false then
  460.         while turtle.up() == false do
  461.             infoget = "Possibly someone in the way."
  462.             movementdisplay()
  463.             turtle.attackUp()
  464.         end
  465.     end
  466. end
  467.  
  468. local function put()
  469.     attacknumber = 0
  470.     infoget = nil
  471.     x = 1
  472.     while turtle.suck() do
  473.     end
  474.     if turtle.detect() then
  475.         if turtle.compare() == false then
  476.             checkdig()
  477.             infoget = "a block is already there.  Replacing it now"
  478.             turtle.place()
  479.         elseif turtle.compare() == true then
  480.             infoget = "No need to replace the block"
  481.         end
  482.     elseif turtle.detect() == false then
  483.         while turtle.attack() do
  484.             turtle.attack()
  485.             attacknumber = attacknumber+1
  486.             infoget = "attacked: "..attacknumber
  487.             movementdisplay()
  488.             sleep(.5)
  489.         end
  490.         turtle.place()
  491.         if turtle.place() == false then
  492.             print("nothing to place")
  493.         elseif turtle.detect() == false and attacknumber == 0 then
  494.             turtle.place()
  495.             infoget = "placed a block"
  496.             movementdisplay()
  497.         end
  498.     end
  499. end
  500.  
  501. local function putUp()
  502.     attacknumber = 0
  503.     infoget = nil
  504.     x = 1
  505.     while turtle.suckUp() do
  506.     end
  507.     if turtle.detectUp() then
  508.         if turtle.compareUp() == false then
  509.             checkdigUp()
  510.             infoget = "a block is already there.  Replacing it now"
  511.             turtle.placeUp()
  512.         elseif turtle.compareUp() == true then
  513.             infoget = "No need to replace the block"
  514.         end
  515.     elseif turtle.detectUp() == false then
  516.         while turtle.attackUp() do
  517.             turtle.attackUp()
  518.             attacknumber = attacknumber+1
  519.             infoget = "attacked: "..attacknumber
  520.             movementdisplay()
  521.             sleep(.5)
  522.         end
  523.         turtle.placeUp()
  524.     elseif turtle.detectUp() == false and attacknumber == 0 then
  525.         turtle.placeUp()
  526.         infoget = "placed a block"
  527.         movementdisplay()
  528.     end
  529. end
  530.  
  531.  
  532. local function putDown()
  533.     attacknumber = 0
  534.     infoget = nil
  535.     x = 1
  536.     while turtle.suckDown() do
  537.     end
  538.     if turtle.detectDown() then
  539.         if turtle.compareDown() == false then
  540.             checkdigDown()
  541.             infoget = "a block is already there.  Replacing it now"
  542.             turtle.placeDown()
  543.         elseif turtle.compareDown() == true then
  544.             infoget = "No need to replace the block"
  545.         end
  546.     elseif turtle.detectDown() == false then
  547.         while turtle.attackDown() do
  548.             turtle.attackDown()
  549.             attacknumber = attacknumber+1
  550.             infoget = "attacked: "..attacknumber
  551.             movementdisplay()
  552.             sleep(.5)
  553.         end
  554.         turtle.placeDown()
  555.     elseif turtle.detectDown() == false and attacknumber == 0 then
  556.         turtle.placeDown()
  557.         infoget = "placed a block"
  558.         movementdisplay()
  559.     end
  560. end
  561.  
  562. local function putLeft()
  563.     turtle.turnLeft()
  564.     put()
  565.     turtle.turnRight()
  566. end
  567.  
  568. local function putRight()
  569.     turtle.turnRight()
  570.     put()
  571.     turtle.turnLeft()
  572. end
  573.  
  574. local function headroomnarrowdig()
  575.     y = x
  576.     term.write("How far shall I go? ")
  577.     times = read()
  578.     checkdigUp()
  579.     turtle.up()
  580.     for i = 0, times-1 do
  581.         checkdigUp()
  582.         checkdig()
  583.         turtle.forward()
  584.         turtle.digUp()
  585.         turtle.digDown()
  586.     end
  587.     turtle.down()
  588. end
  589.  
  590. local function stunnel()
  591.     term.clear()
  592.     term.setCursorPos(1, 1)
  593.     term.write("How far shall I go? ")
  594.     times = read()
  595.     checkdigUp()
  596.     for i=1,times do
  597.         turtle.placeDown()
  598.         checkdig()
  599.         turtle.forward()
  600.         checkdigUp()
  601.     end
  602. end
  603.  
  604. local function currentplace()
  605.     for i = 1, 4 do
  606.         if turtle.detect() then
  607.             turtle.turnLeft()
  608.             currentplacesuccess = false
  609.         elseif not turtle.detect() then
  610.             turtle.forward()
  611.             flip()
  612.             turtle.place()
  613.             currentplacesuccess = true
  614.             break
  615.         end
  616.     end
  617.     if currentplacesuccess == false then
  618.         if turtle.detectUp() then
  619.             if turtle.detectDown() then
  620.                 infoget = "Trapped"
  621.             elseif not turtle.detectDown() then
  622.                 turtle.down()
  623.                 turtle.placeUp()
  624.             end
  625.         else
  626.             turtle.up()
  627.             turtle.placeDown()
  628.         end
  629.     end
  630. end
  631.  
  632. local function runprogram()
  633.     infoget = "What program do you want to run?"
  634.     movementdisplay()
  635.     input = read()
  636.    
  637.     if string.sub(input, 1, 5) == "edit " then
  638.         lastbutton = "cannot edit programs from here"
  639. --[[    elseif fs.exists(input) == false then
  640.         lastbutton = "can't find "..input
  641.         infoget = "no such program"]]
  642.     elseif input == "" then
  643.         lastbutton = "can't run nothing"
  644.     else
  645.         infoget = nil
  646.         lastbutton = "ran an external program"
  647.         shell.run(input)
  648.         infoget = "I ran "..input
  649.         lastbutton = "ran an external program"
  650.     end
  651.     -- lastbutton = "ran an external program"
  652.     movementdisplay()
  653. end
  654.  
  655. local function digaround()
  656.     checkdig()
  657.     turtle.turnRight()
  658.     checkdig()
  659.     turtle.turnRight()
  660.     checkdig()
  661.     turtle.turnRight()
  662.     checkdig()
  663.     turtle.turnRight()
  664. end
  665.  
  666. local function allforward()
  667.     lastbutton = "am moving forward"
  668.     movementdisplay()
  669.     x = 0
  670.     repeat
  671.         if turtle.detect() == false then
  672.             if turtle.attack() == false then
  673.                 while turtle.suck() do
  674.                 end
  675.                 turtle.forward()
  676.                 x = x+1
  677.                 lastbutton = "went forward "..x
  678.                 movementdisplay()
  679.             else
  680.                 while turtle.attack() == true do
  681.                     turtle.attack()
  682.                 end
  683.             end
  684.         elseif turtle.detect() == true then
  685.             infoget = "Nowhere to go"
  686.         end
  687.     until turtle.detect()
  688. end
  689.  
  690. local function slotselection()
  691.     infoget = "Select a slot with arrows"
  692.     movementdisplay()
  693.     x = 1
  694.     turtle.select(x)
  695.     while true do
  696.         event, pl = os.pullEvent("key")
  697.         if pl == 200 then
  698.             x=x-4
  699.             if x<1 then
  700.                 x=x+16
  701.             end
  702.             lastbutton = "am selecting slot "..x
  703.             movementdisplay()
  704.         elseif pl == 17 then
  705.             x=x-4
  706.             if x<1 then
  707.                 x=x+16
  708.             end
  709.             lastbutton = "am selecting slot "..x
  710.             movementdisplay()
  711.         elseif pl == 203 then
  712.             x=x-1
  713.             if x<1 then
  714.                 x=x+16
  715.             end
  716.             lastbutton = "am selecting slot "..x
  717.             movementdisplay()
  718.         elseif pl == 30 then
  719.             x=x-1
  720.             if x<1 then
  721.                 x=x+16
  722.             end
  723.             lastbutton = "am selecting slot "..x
  724.             movementdisplay()
  725.         elseif pl == 208 then
  726.             x=x+4
  727.             if x>16 then
  728.                 x=x-16
  729.             end
  730.             lastbutton = "am selecting slot "..x
  731.             movementdisplay()
  732.         elseif pl == 31 then
  733.             x=x+4
  734.             if x>16 then
  735.                 x=x-16
  736.             end
  737.             lastbutton = "am selecting slot "..x
  738.             movementdisplay()
  739.         elseif pl == 205 then
  740.             x=x+1
  741.             if x>16 then
  742.                 x=x-16
  743.             end
  744.             lastbutton = "am selecting slot "..x
  745.             movementdisplay()
  746.         elseif pl == 32 then
  747.             x=x+1
  748.             if x>16 then
  749.                 x=x-16
  750.             end
  751.             lastbutton = "am selecting slot "..x
  752.             movementdisplay()
  753.         elseif pl == 28 or 13 then
  754.             lastbutton = "selected slot "..x
  755.             movementdisplay()
  756.             sleep(.01)
  757.             shell.dir()
  758.             break
  759.         end
  760.         turtle.select(x)
  761.     end
  762. end
  763.  
  764. local function sortinventory()
  765.     shell.run("sorter")
  766.     turtle.select(1)
  767. end
  768.  
  769. while true do
  770.     movementdisplay()
  771.     local evt, c = os.pullEvent("char")
  772.     if c == "w" then
  773.         if turtle.detect() == false and turtle.suck() == false and turtle.attack() == false then
  774.             turtle.forward()
  775.             lastbutton = "moved forward"
  776.         else
  777.             moveForward()
  778.             movementdisplay()
  779.         end
  780.     elseif c == "W" then
  781.         allforward()
  782.         movementdisplay()
  783.     elseif c == "a" then
  784.         turtle.turnLeft()
  785.         if turtle.detect() == false and turtle.suck() == false and turtle.attack() == false then
  786.             turtle.forward()
  787.             lastbutton = "moved left"
  788.         else
  789.             moveLeft()
  790.             movementdisplay()
  791.         end
  792.     elseif c == "d" then
  793.         turtle.turnRight()
  794.         if turtle.detect() == false and turtle.suck() == false and turtle.attack() == false then
  795.             turtle.forward()
  796.             lastbutton = "moved forward"
  797.         else
  798.             moveRight()
  799.             movementdisplay()
  800.         end
  801.     elseif c == "s" then
  802.         if turtle.back() == true then
  803.             lastbutton = "moved backward"
  804.             infoget = "Nothing was in the way"
  805.             movementdisplay()
  806.         else
  807.             moveBackward()
  808.             movementdisplay()
  809.         end
  810.     elseif c == "S" then
  811.         moveBack()
  812.         movementdisplay()
  813.     elseif c == "4" then
  814.         turtle.turnLeft()
  815.         lastbutton = "turned left"
  816.         infoget = nil
  817.         movementdisplay()
  818.     elseif c == "6" then
  819.         turtle.turnRight()
  820.         lastbutton = "turned right"
  821.         infoget = nil
  822.         movementdisplay()
  823.     elseif c == "2" then
  824.         flip()
  825.         lastbutton = "turned around"
  826.         infoget = nil
  827.         movementdisplay()
  828.     elseif c == "q" then
  829.         if turtle.detectUp() == false and turtle.suckUp() == false and turtle.attackUp() == false then
  830.             turtle.up()
  831.             lastbutton = "moved up"
  832.         else
  833.             moveUp()
  834.         end
  835.         movementdisplay()
  836.     elseif c == "z" then
  837.         checkFuel()
  838.         checkdigDown()
  839.         turtle.down()
  840.         lastbutton = "moved down"
  841.         movementdisplay()
  842.     elseif c == "5" then
  843.         x = 0
  844.         flip()
  845.         currentplace()
  846.         lastbutton = "placed block at old position"
  847.         movementdisplay()
  848.     elseif c == "e" then
  849.         checkdig()
  850.         movementdisplay()
  851.     elseif c == "r" then
  852.         put()
  853.         lastbutton = "placed a block forward"
  854.         movementdisplay()
  855.     elseif c == "|" then
  856.         headroomnarrowdig()
  857.         lastbutton = "dug a 3 high hole"
  858.         movementdisplay()
  859.     elseif c == "~" then
  860.         runprogram()
  861.         movementdisplay()
  862.     elseif c == "'" then
  863.         if casedisplay == 0 then
  864.             casedisplay = 1
  865.             infoget = "display is now uppercase"
  866.         elseif casedisplay == 1 then
  867.             casedisplay = 0
  868.             infoget = "display is now lowercase"
  869.         end
  870.         lastbutton = "changed display screens"
  871.         movementdisplay()
  872.     elseif c == "-" then
  873.         lastbutton = "am digging a 2 high hole"
  874.         movementdisplay()
  875.         stunnel()
  876.         lastbutton = "dug a 2 high hole"
  877.         movementdisplay()
  878.     elseif c == "y" then
  879.         putUp()
  880.         lastbutton = "placed a block up"
  881.         movementdisplay()
  882.     elseif c == "h" then
  883.         putDown()
  884.         lastbutton = "placed a block down"
  885.         movementdisplay()
  886.     elseif c == "^" then
  887.         checkdigUp()
  888.         movementdisplay()
  889.     elseif c == "v" then
  890.         checkdigDown()
  891.         movementdisplay()
  892.     elseif c == "<" then
  893.         checkdigLeft()
  894.         movementdisplay()
  895.     elseif c == ">" then
  896.         checkdigRight()
  897.         movementdisplay()
  898.     elseif c == "," then
  899.         putLeft()
  900.         lastbutton = "placed a block left"
  901.         movementdisplay()
  902.     elseif c == "." then
  903.         putRight()
  904.         lastbutton = "placed a block right"
  905.         movementdisplay()
  906.     elseif c == "+" then
  907.         digaround()
  908.         lastbutton = "dug the blocks on all my sides"
  909.         movementdisplay()
  910.     elseif c == "/" then
  911.         lastbutton = "refreshed"
  912.         infoget = nil
  913.         getperipheraltype()
  914.         labelget()
  915.         checkFuel()
  916.         movementdisplay()
  917.     elseif c == "=" then
  918.         lastbutton = "am waiting to select a slot"
  919.         movementdisplay()
  920.         slotselection()
  921.     elseif c == "i" then
  922.         if fs.exists("sorter") then
  923.             sortinventory()
  924.             lastbutton = "sorted my inventory"
  925.             infoget = nil
  926.         elseif fs.exists("sorter") == false then
  927.             lastbutton = "cannot run.  File doesn't exist"
  928.         end
  929.         movementdisplay()
  930.     elseif c == "?" then
  931.         if fs.exists("helpcenter") then
  932.             lastbutton = "went into the helpcenter"
  933.             shell.run("helpcenter")
  934.             infoget = ("Thank you for using the HelpCenter.  Please direct any problems or suggestions to Jared")
  935.         elseif fs.exists("helpcenter") == false then
  936.             lastbutton = "cannot run.  File doesn't exist"
  937.             infoget = "File: helpcenter"
  938.         end
  939.         movementdisplay()
  940.     elseif c == "c" and peripheraltype == "c" then
  941.         if turtle.craft() == true then
  942.             lastbutton = "crafted an item"
  943.             infoget = nil
  944.         elseif turtle.craft() == false then
  945.             lastbutton = "attempted to craft an item"
  946.             infoget = "failed to craft"
  947.         end
  948.         movementdisplay()
  949.     end
  950. end
Advertisement
Add Comment
Please, Sign In to add comment