Advertisement
LeslieCraft

[HUN] Minecraft, computercraft turtle. v0.6

Nov 20th, 2012
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.39 KB | None | 0 0
  1.   --Automata banyaszo Turtle v0.6--
  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. ----------------------------------------
  22. ]]--
  23.  
  24. function reFuel()
  25.   turtle.select(1)
  26.   turtle.refuel(10)
  27.   print("Tankoltam.")
  28. end
  29.  
  30.  
  31. function dropAll()
  32.   local slot = 2
  33.   turtle.select(1)
  34.  
  35.   while slot ~= 17 do
  36.     turtle.select(slot)
  37.     turtle.drop()
  38.     slot = slot+1
  39.   end
  40. end  
  41.  
  42.  
  43. function targetC()
  44.   lepes = 0
  45.   turtle.turnRight()
  46.   while turtle.forward() do
  47.     lepes = lepes + 1
  48.     print("Lepesek a chest-ig: "..lepes)
  49.   end
  50.  
  51.   while not turtle.forward() do
  52.     dropAll()
  53.     turtle.turnLeft()
  54.     turtle.turnLeft()
  55.   end
  56.  
  57.   print("Ennyit megyek vissza: "..lepes)
  58.  
  59.   for i = 2, lepes do
  60.     turtle.forward()
  61.   end
  62.  
  63.   turtle.turnRight()  
  64. end
  65.  
  66.  
  67. function lepesE()
  68.   while turtle.detectDown() do
  69.     turtle.digDown()
  70.   end
  71.  
  72.   while not turtle.forward() do
  73.     turtle.dig()
  74.   end
  75.   sleep(0.4)
  76.  
  77.   while turtle.detectUp() do
  78.     turtle.digUp()
  79.     sleep(0.4)
  80.   end
  81. end
  82.  
  83.  
  84. function turnL()
  85.   turtle.turnLeft()
  86.   lepesE()
  87.   turtle.turnLeft()
  88. end
  89.  
  90.  
  91. function turnR()
  92.   turtle.turnRight()
  93.   lepesE()
  94.   turtle.turnRight()
  95. end
  96.  
  97.  
  98. --Main program--
  99.  
  100. while true do
  101.   local fuel = turtle.getFuelLevel()
  102.   print("Online")
  103.   print("Uzemanyag szint: "..fuel)
  104.   local hossz = 0
  105.   local szeles = 0
  106.   write("Szelesseg: ")                      
  107.   local szeles = read()
  108.  
  109.     if szeles == "test" then
  110.       targetC()
  111.     else
  112.       write("Hossz: ")
  113.       local hosszu = read()
  114.       local hosszu = hosszu-1
  115.       local szeles = szeles-1
  116.  
  117.       for i = 1, szeles, 2 do
  118.        
  119.         for i = 1, hosszu do
  120.           lepesE()
  121.         end
  122.           turnL()
  123.  
  124.         for i = 1, hosszu do
  125.           lepesE()
  126.         end
  127.        
  128.         turnR()
  129.         targetC()
  130.        
  131.         if fuel < 2000 then
  132.           reFuel()
  133.         end
  134.      end
  135.   end
  136.   term.clear()
  137.   term.setCursorPos(1,1)
  138. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement