Advertisement
AsTio

turtle test

Mar 22nd, 2019
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.63 KB | None | 0 0
  1. local chestSlot = 15
  2. local torchSlot = 16
  3. local cobbleSlot = 2
  4. local fuelSlot = 1
  5. local bucketSlot = 3
  6. local chose = 1
  7. local t=12
  8. local torchesplace = "No"
  9. local floorplace = "Yes"
  10. local chestplace = "No"
  11. local czank = 16
  12.  
  13. a = colors.green
  14. b = colors.yellow
  15. c = colors.yellow
  16. d = colors.yellow
  17.  
  18. -- ----------------------------------------------------
  19.  
  20. local function bucket()
  21. local success, data = turtle.inspectDown()
  22.         if data.name == "minecraft:flowing_lava" then
  23.             turtle.select(bucketSlot)
  24.             turtle.placeDown()
  25.             turtle.refuel()
  26.         end
  27.         if data.name == "minecraft:lava" then
  28.             turtle.select(bucketSlot)
  29.             turtle.placeDown()
  30.             turtle.refuel()
  31.         end
  32. end
  33.  
  34. -- -----------------------------------
  35.  
  36. local function screen()
  37.         term.clear()
  38.         term.setTextColor(colors.yellow)
  39.         print( "Fuel Level: "..turtle.getFuelLevel() )
  40.         print("")
  41.         print("")
  42.         print("Torch distance: "..t)
  43.     if floorplace == "Yes" then
  44.         print("Floor will be placed")
  45.     else
  46.         print("Floor won't be placed")
  47.     end
  48.     print("")
  49.     print("")
  50.     print("Fuel Slot:"..fuelSlot)
  51.     print("Build Block Slot:"..cobbleSlot)
  52.     print("Bucket Slot:"..bucketSlot)
  53.     print("Chest Slot:"..chestSlot)
  54.     print("Torch Slot:"..torchSlot)
  55. end
  56.    
  57. -- -----------------------------------
  58.  
  59.  
  60. local function fuel()
  61.     if turtle.getFuelLevel() < 50 then
  62.         turtle.select(fuelSlot)
  63.         turtle.refuel(5)
  64.     end
  65. end
  66.  
  67. -- --------------------------------------
  68.  
  69. local function dig()
  70.     while turtle.detect() == true do
  71.         turtle.dig()   
  72.     end
  73.     turtle.forward()
  74.     screen()
  75. end
  76.  
  77. -- -------------------------------------
  78.  
  79. local function floor()
  80.     if floorplace == "Yes" then
  81.         if turtle.detectDown() then
  82.         else
  83.             turtle.select(cobbleSlot)
  84.             turtle.placeDown()
  85.         end
  86.     end
  87. end
  88.  
  89. -- -------------------------------------
  90.  
  91. local function chest()
  92. if chestplace == "Yes" then
  93.     if turtle.getItemCount(14) >= 1 then
  94.         turtle.up()
  95.         turtle.turnRight()
  96.         turtle.dig()
  97.         turtle.down()
  98.         turtle.dig()
  99.         turtle.select(chestSlot)
  100.         turtle.place()
  101.     for y=14,4,-1 do
  102.             turtle.select(y)
  103.             turtle.drop()
  104.     end
  105.         turtle.turnLeft()
  106.     end
  107. end
  108. end
  109.  
  110. -- -------------------------------------
  111. local function torchchunk()
  112. if torchesplace == "Yes" then
  113.     turtle.up()
  114.     turtle.select(torchSlot)
  115.     turtle.placeDown()
  116. end
  117. end
  118. -- -------------------------------------
  119.  
  120. local function torch2x2()
  121. if torchesplace == "Yes" then
  122.     turtle.turnLeft()
  123.     turtle.up()
  124.     turtle.forward()
  125.  
  126. if turtle.detect() then
  127. else
  128.     turtle.select(cobbleSlot)
  129.     turtle.place()
  130. end
  131.  
  132.     turtle.turnLeft()
  133.     turtle.turnLeft()
  134.     turtle.forward()
  135.     turtle.turnLeft()
  136.     turtle.turnLeft()
  137.     turtle.select(torchSlot)
  138.     turtle.place()
  139.     turtle.turnRight()
  140.     turtle.down()
  141. end
  142. end
  143. -- --------------------------------
  144. local function mine1x2()
  145. end
  146. -- --------------------------------
  147. local function mine3x3()
  148. end
  149. -- --------------------------------
  150. local function chunk()
  151. turtle.refuel(5)
  152. print( "Fuel Level: "..turtle.getFuelLevel() )
  153.     while true do
  154.     czank_set=1
  155.     for h=4,1,-1 do
  156.     if czank_set==2 then
  157.         czank=czank-2
  158.         czank_set=0
  159.     end
  160.     if czank<=0 then
  161.         break
  162.     end
  163.     czank_set=czank_set+1
  164.     for g=czank,1,-1 do
  165.             fuel()
  166.             dig()
  167.             bucket()
  168.             floor()
  169.             turtle.turnLeft()
  170.             dig()
  171.             bucket()
  172.             floor()
  173.             turtle.turnRight()
  174.             turtle.digUp()
  175.             turtle.up()
  176.             turtle.turnRight()
  177.             dig()
  178.             turtle.turnLeft()
  179.             turtle.down()
  180.             chest()
  181.     end
  182.     torchchunk()
  183.     turtle.turnRight()
  184.     turtle.turnRight()
  185.     turtle.forward()
  186.     turtle.turnLeft()
  187.     turtle.down()
  188.     end
  189.     end
  190. end
  191. -- --------------------------------
  192. local function mine2x2()
  193. turtle.refuel(5)
  194. print( "Fuel Level: "..turtle.getFuelLevel() )
  195.     while true do
  196.     for i=t,1,-1 do
  197.         fuel()
  198.         dig()
  199.         bucket()
  200.         floor()
  201.         turtle.turnLeft()
  202.         dig()
  203.         bucket()
  204.         floor()
  205.         turtle.turnRight()
  206.         turtle.digUp()
  207.         turtle.up()
  208.         turtle.turnRight()
  209.         dig()
  210.         turtle.turnLeft()
  211.         turtle.down()
  212.         chest()
  213.     end
  214.         torch2x2()
  215.     end
  216. end
  217. -- --------------Mining----------------------
  218. local function MineSC()
  219.     term.clear()
  220.     term.setCursorPos(3,3);
  221.     term.setTextColor(a)
  222.     print("1x2")
  223.     term.setCursorPos(3,4);
  224.     term.setTextColor(b)
  225.     print("2x2")
  226.     term.setCursorPos(3,5);
  227.     term.setTextColor(c)
  228.     print("3x3")
  229.     term.setCursorPos(3,6);
  230.     term.setTextColor(d)
  231.     print("Chunk!")
  232. end
  233.  
  234. local function mine()
  235.     a = colors.green
  236.     b = colors.yellow
  237.     c = colors.yellow
  238.     d = colors.yellow
  239.     term.clear()
  240.     chose = 1
  241.     while true do
  242.         MineSC()
  243.         local event, key = os.pullEvent( "key" )
  244.         if key == keys.enter then
  245.             break
  246.         end
  247.         if key == keys.up then
  248.             chose = chose - 1
  249.         end
  250.         if key == keys.down then
  251.             chose = chose + 1
  252.         end
  253.         if chose <= 0 then
  254.             chose = 4
  255.         end
  256.         if chose >= 5 then
  257.             chose = 1
  258.         end
  259.         if chose == 1 then
  260.             a = colors.green
  261.             b = colors.yellow
  262.             c = b
  263.             d = b
  264.         end
  265.         if chose == 2 then
  266.             a = colors.yellow
  267.             b = colors.green
  268.             c = a
  269.             d = a
  270.         end
  271.         if chose == 3 then
  272.             a = colors.yellow
  273.             b = a
  274.             c = colors.green
  275.             d = a
  276.         end
  277.         if chose == 4 then
  278.             a = colors.yellow
  279.             b = a
  280.             c = a
  281.             d = colors.green
  282.         end
  283.     end
  284.     if chose == 1 then
  285.         mine1x2()
  286.     end
  287.     if chose == 2 then
  288.         mine2x2()
  289.     end
  290.     if chose == 3 then
  291.         mine3x3()
  292.     end
  293.     if chose == 4 then
  294.         chunk()
  295.     end
  296. end
  297. -- ------------------------------------------
  298. -- --------------OPTIONS----------------------
  299. local function OptionsSC()
  300.     term.clear()
  301.     term.setCursorPos(3,3);
  302.     term.setTextColor(a)
  303.     print("Place Torches: "..torchesplace)
  304.     term.setCursorPos(3,4);
  305.     term.setTextColor(b)
  306.     print("Place Floor: "..floorplace)
  307.     term.setCursorPos(3,5);
  308.     term.setTextColor(c)
  309.     print("Place Chest: "..chestplace)
  310.     term.setCursorPos(3,6);
  311.     term.setTextColor(d)
  312.     print("Back to menu")
  313. end
  314.  
  315. local function options()
  316.     a = colors.green
  317.     b = colors.yellow
  318.     c = colors.yellow
  319.     d = colors.yellow
  320.     term.clear()
  321.     chose = 1
  322.     while true do
  323.         OptionsSC()
  324.         local event, key = os.pullEvent( "key" )
  325.         if key == keys.enter then
  326.             break
  327.         end
  328.         if key == keys.up then
  329.             chose = chose - 1
  330.         end
  331.         if key == keys.down then
  332.             chose = chose + 1
  333.         end
  334.         if chose <= 0 then
  335.             chose = 4
  336.         end
  337.         if chose >= 5 then
  338.             chose = 1
  339.         end
  340.         if chose == 1 then
  341.             a = colors.green
  342.             b = colors.yellow
  343.             c = b
  344.             d = b
  345.         end
  346.         if chose == 2 then
  347.             a = colors.yellow
  348.             b = colors.green
  349.             c = a
  350.             d = a
  351.         end
  352.         if chose == 3 then
  353.             a = colors.yellow
  354.             b = a
  355.             c = colors.green
  356.             d = a
  357.         end
  358.         if chose == 4 then
  359.             a = colors.yellow
  360.             b = a
  361.             c = a
  362.             d = colors.green
  363.         end
  364.     end
  365.     if chose == 1 then
  366.         if torchesplace == "No" then
  367.             torchesplace = "Yes"
  368.             options()
  369.         else
  370.             torchesplace = "No"
  371.             options()
  372.         end
  373.     end
  374.     if chose == 2 then
  375.         if floorplace == "No" then
  376.             floorplace = "Yes"
  377.             options()
  378.         else
  379.             floorplace = "No"
  380.             options()
  381.         end
  382.     end
  383.     if chose == 3 then
  384.     if  chestplace == "No" then
  385.             chestplace = "Yes"
  386.             options()
  387.         else
  388.             chestplace = "No"
  389.             options()
  390.         end
  391.     end
  392.     if chose == 4 then
  393.     end
  394. end
  395.  
  396. -- ---------------MENU----------------------
  397.  
  398. local function MenuSC()
  399.     term.clear()
  400.     term.setCursorPos(3,3);
  401.     term.setTextColor(a)
  402.     print("Start")
  403.     term.setCursorPos(3,4);
  404.     term.setTextColor(b)
  405.     print("Options")
  406.     term.setCursorPos(3,5);
  407.     term.setTextColor(c)
  408.     print("Exit")
  409. end
  410. local function Menu()
  411.     term.clear()
  412.     chose = 1
  413.     while true do
  414.         MenuSC()
  415.         local event, key = os.pullEvent( "key" )
  416.         if key == keys.enter then
  417.             break
  418.         end
  419.         if key == keys.up then
  420.             chose = chose - 1
  421.         end
  422.         if key == keys.down then
  423.             chose = chose + 1
  424.         end
  425.         if chose <= 0 then
  426.             chose = 3
  427.         end
  428.         if chose >= 4 then
  429.             chose = 1
  430.         end
  431.         if chose == 1 then
  432.             a = colors.green
  433.             b = colors.yellow
  434.             c = colors.yellow
  435.         end
  436.         if chose == 2 then
  437.             a = colors.yellow
  438.             b = colors.green
  439.             c = colors.yellow
  440.         end
  441.         if chose == 3 then
  442.             a = colors.yellow
  443.             b = colors.yellow
  444.             c = colors.green
  445.         end
  446.     end
  447.     if chose == 1 then
  448.         mine()
  449.     end
  450.     if chose == 2 then
  451.         options()
  452.     end
  453.     if chose == 3 then
  454.         os.shutdown()
  455.     end
  456. end
  457. -- -------------------------------------------
  458. -- -----------------PROGRAM-------------------
  459. while true do
  460. local chose = 1
  461. a = colors.green
  462. b = colors.yellow
  463. c = colors.yellow
  464. d = colors.yellow
  465. Menu()
  466. end
  467. -- -------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement