Advertisement
Guest User

ferme

a guest
Jul 23rd, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1. local coal = 16
  2. local food = 1
  3. local id = 88
  4.  
  5.  
  6.  
  7. function init()
  8.  
  9.         while turtle.detectDown() == true do
  10.             turtle.back()
  11.         end
  12.  
  13.         while turtle.detect() do
  14.             turtle.turnRight()
  15.         end
  16.  
  17. end
  18.  
  19.  
  20. function refuel()
  21.   print("niveau de fuel :" .. turtle.getFuelLevel())
  22.  
  23.   if turtle.getFuelLevel() < 50 then
  24.         turtle.turnRight()
  25.         turtle.select(coal)
  26.         turtle.suck()
  27.         turtle.refuel()
  28.         turtle.select(food)
  29.     end
  30.  
  31. end
  32.  
  33.  
  34. function deplacement()
  35.   food = 1
  36.   init()
  37.  
  38.   turtle.select(food)
  39.   while turtle.forward() == true do
  40.     if food < 14 and turtle.getItemCount(food) < 1 then
  41.       food = food + 1
  42.       turtle.select(food)
  43.     end
  44.  
  45.         turtle.dropUp()
  46.   end
  47.  
  48.      while turtle.back() == true do end
  49.  
  50. end
  51.  
  52.  
  53.  
  54. function vide()
  55.  
  56.      turtle.turnLeft()
  57.      turtle.turnLeft()
  58.  
  59.      for i = 1, 16 do
  60.         turtle.select(i)
  61.         turtle.suck()
  62.     end
  63.   turtle.select(16)
  64.   turtle.drop()
  65.      turtle.turnRight()
  66.      turtle.turnRight()
  67.  
  68. end
  69.    
  70.    
  71.  
  72.  
  73. -- programme principal
  74. init()
  75.  
  76. while true do
  77.  
  78.         term.clear()
  79.         refuel()
  80.         deplacement()
  81.         vide()
  82.  
  83.         for i = 0, 60 do
  84.             os.startTimer(1)
  85.             os.pullEvent("timer")
  86.             term.clear()
  87.             print("je pars dans :" .. 60-i .. " secondes")
  88.         end
  89.  
  90. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement