Advertisement
LeslieCraft

[HUN] Minecraft, computercraft turtle. v0.7

Nov 20th, 2012
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   --Automata banyaszo Turtle v0.7--
  2.             --By Leslie--
  3.            --2012. 11.18--
  4.  
  5. --[[
  6. ----------------------------------------
  7. 0.1 -Banyaszas.
  8. 0.2 -Minden inditasnal tankol.
  9. 2012.11.19
  10. 0.3 -HotFIX: ha nincs elotte block
  11.       akkor is banyasz maga felett.
  12. 0.4 -Fordulokent elmegy es
  13.       kiuriti magat a chest-be.
  14. 0.5 -Ha soder hullik ra, erzekeli
  15.       es kibanyassza.
  16.     -Csak akkor tankol, ha 2000 ala
  17.       esik az uzemanyag szint.
  18. 0.6 -Maga alatt is banyasz.
  19.       A tankolas fordulonkent van, nem
  20.       indulasonkent.
  21. 2012.11.20
  22. 0.7 -Install parancsal, megcsinalja
  23.       maganak a dokkolo helyet. 6x6
  24.       3chest 2tabla tartalom leirassal.
  25.     -Tankolas opcio pontositva. Akkor
  26.       tankol, ha 100 ala esik az
  27.       uzemanyag szint. Masodik chestbol
  28.       kiveszi maganak a szenet, ha a
  29.       slot1 ben 30 ala esik a szen.
  30. ----------------------------------------
  31. ]]--
  32.  
  33. function telepitAera()
  34.  for i = 1, 6, 2 do
  35.        
  36.    for i = 1, 5 do
  37.      lepesE()
  38.    end
  39.      turnL()
  40.  
  41.    for i = 1, 5 do
  42.      lepesE()
  43.    end
  44.    turnR()
  45.  end
  46.  itemInstall()
  47. end
  48.  
  49.  
  50.  
  51. function itemGo()
  52.  turtle.turnLeft()
  53.  turtle.forward()
  54.  turtle.turnRight()
  55. end
  56.  
  57.  
  58.  
  59. function itemInstall()
  60.   turtle.turnRight()
  61.   turtle.select(2)
  62.   for i = 1, 5 do
  63.     lepesE()
  64.   end
  65.   for i = 1, 2 do
  66.     turtle.place()
  67.     itemGo()
  68.   end
  69.   turtle.select(3)
  70.   turtle.place([[Kibanyaszott
  71.   block-ok
  72.   -------->]])
  73.   itemGo()
  74.   turtle.select(2)
  75.   turtle.place()
  76.   itemGo()
  77.   turtle.select(4)
  78.   turtle.place([[Uzemanyag nekem
  79.   (szen)
  80.   :)
  81.   ------->]])
  82.   turtle.turnRight()
  83.   for i = 1, 4 do
  84.     turtle.forward()
  85.   end
  86.   turtle.turnRight()
  87.   for i = 1, 5 do
  88.     turtle.forward()
  89.   end
  90.   turtle.turnRight()
  91. end
  92.  
  93.  
  94.  
  95. function reFuel()
  96. fuel = turtle.getFuelLevel()
  97.   if fuel < 100 then    
  98.     turtle.select(1)
  99.     turtle.refuel(10)
  100.     print("Tankoltam.")
  101.   end
  102. end
  103.  
  104.  
  105.  
  106. function getFuel()
  107.   local fuelslot = turtle.getItemCount(1)
  108.   turtle.turnRight()
  109.   turtle.select(1)
  110.   turtle.turnLeft()
  111.   if fuelslot < 30 then
  112.     for i = 1, 3 do
  113.       turtle.forward()
  114.     end
  115.     turtle.turnRight()
  116.     turtle.suck(34)
  117.     turtle.turnRight()
  118.     for i = 1, 3 do
  119.       turtle.forward()
  120.     end    
  121.   end
  122. end
  123.  
  124.  
  125.  
  126. function dropAll()
  127.   local slot = 2
  128.  
  129.   while slot ~= 17 do
  130.     turtle.select(slot)
  131.     turtle.drop()
  132.     slot = slot+1
  133.   end
  134. end  
  135.  
  136.  
  137.  
  138. function targetC()
  139.   lepes = 0
  140.   turtle.turnRight()
  141.   while turtle.forward() do
  142.     lepes = lepes + 1
  143.     print("Lepesek a chest-ig: "..lepes)
  144.   end
  145.  
  146.   while not turtle.forward() do
  147.     dropAll()
  148.     turtle.turnLeft()
  149.     getFuel()
  150.     turtle.turnLeft()
  151.   end
  152.  
  153.   print("Ennyit megyek vissza: "..lepes)
  154.  
  155.   for i = 2, lepes do
  156.     turtle.forward()
  157.   end
  158.  
  159.   turtle.turnRight()  
  160. end
  161.  
  162.  
  163.  
  164. function digDown()
  165.  
  166.   while turtle.detectDown() do
  167.     turtle.digDown()
  168.   end
  169. end
  170.  
  171.  
  172.  
  173. function lepesE()
  174.  
  175.   while not turtle.forward() do
  176.     turtle.dig()
  177.   end
  178.   sleep(0.4)
  179.  
  180.   while turtle.detectUp() do
  181.     turtle.digUp()
  182.     sleep(0.4)
  183.   end
  184. end
  185.  
  186.  
  187.  
  188. function turnL()
  189.   turtle.turnLeft()
  190.   lepesE()
  191.   turtle.turnLeft()
  192. end
  193.  
  194.  
  195.  
  196. function turnR()
  197.   turtle.turnRight()
  198.   lepesE()
  199.   turtle.turnRight()
  200. end
  201.  
  202.  
  203. --Main program--
  204.  
  205. while true do
  206.   local fuel = turtle.getFuelLevel()
  207.   print("Online")
  208.   print("Ha a dokkolo helyet szeretned kialakitani, a [Hosszusag] reszhez ird be, hogy [install]")
  209.   print("Uzemanyag szint: "..fuel)
  210.   local hossz = 0
  211.   local szeles = 0
  212.   write("Szelesseg: ")                      
  213.   local szeles = read()
  214.   if fuel > 100 then
  215.     if szeles == "test" then
  216.       telepitAera()
  217.     elseif szeles == "install" then
  218.       print("Kerlek az egyes slotomba rakj 30db szenet. A kettes slotba 3db chest-et. A harmas es negyes slotba 1-1 tablat (sign) Ha keszen vagy nyomj egy entert, hogy kialakitsam a dokkolo helyemet.")
  219.       read()
  220.       telepitAera()
  221.     else
  222.       write("Hossz: ")
  223.       local hosszu = read()
  224.       local hosszu = hosszu-1
  225.       local szeles = szeles-1
  226.  
  227.       for i = 1, szeles, 2 do
  228.        
  229.         for i = 1, hosszu do
  230.           digDown()
  231.           lepesE()
  232.           digDown()
  233.         end
  234.           turnL()
  235.  
  236.         for i = 1, hosszu do
  237.           digDown()
  238.           lepesE()
  239.           digDown()
  240.         end
  241.        
  242.         reFuel()
  243.         turnR()
  244.         targetC()
  245.       end
  246.     end
  247.   else
  248.     print("Nincs uzemanyagom. Kerlek rakj szenet az egyes slotomba. Ha megvagy nyomj egy entert.")
  249.     read("")
  250.     turtle.select(1)
  251.     turtle.refuel(10)
  252.   end
  253.   term.clear()
  254.   term.setCursorPos(1,1)
  255. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement