Advertisement
raphael76280

Turtle waiter

Aug 9th, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.22 KB | None | 0 0
  1. -- mouvement
  2. while true do
  3. local blockFront, blockF = turtle.inspect()
  4. local blockBottom, blockB = turtle.inspectDown()
  5. local command = false
  6. local wireless = peripheral.wrap("left")
  7. wireless.open(69)
  8. wireless.open(70)
  9.  
  10. local foodName
  11. local foodQuan
  12. local foodHave
  13. local echStats
  14.  
  15. -- fuel
  16. if (turtle.getFuelLevel() < 40) then
  17. turtle.select(1)
  18. turtle.refuel(1)
  19. print("refuel ! ")
  20. end
  21.  
  22. -- mouvement bloc de face
  23. if blockFront then
  24. if (blockF.name == "minecraft:sandstone") then
  25. turtle.up()
  26. turtle.forward()
  27. end
  28.  
  29. if (blockF.name == "chisel:limestone") then
  30. turtle.down()
  31. end
  32.  
  33. if (blockF.name == "minecraft:glass") then
  34. turtle.turnRight()
  35. end
  36.  
  37. if (blockF.name == "minecraft:sand") then
  38. turtle.turnLeft()
  39. end
  40.  
  41. if (blockF.name == "minecraft:planks") then
  42.   if (command == false) then
  43.         local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  44.        
  45.                 if (senderChannel == 69) then
  46.                         foodName = message
  47.                         command = true
  48.                 end
  49.                 if (senderChannel == 70) then
  50.                         foodQuan = message
  51.                         command = true
  52.                 end
  53.                
  54.   end
  55.         if (foodHave == true) then
  56.                 turtle.select(2)
  57.                 turtle.dropUp()
  58.                 foodHave = false
  59.         end
  60.  
  61.         turtle.turnLeft()
  62.         turtle.turnLeft()
  63. end
  64. -- fin block de devant
  65. end
  66.  
  67.  
  68. -- mouvement bloc de dessou
  69. if blockBottom then
  70. if (blockB.name == "minecraft:stone") then
  71. turtle.forward()
  72. end
  73.  
  74. if (blockB.name == "minecraft:sandstone") then
  75. turtle.forward()
  76. end
  77.  
  78. if (blockB.name == "chisel:marble") then
  79.   turtle.turnLeft()
  80.         if (command == true) then
  81.                 turtle.select(2)
  82.                 turtle.suck(1)
  83.                 echStats = turtle.getItemDetail()
  84.                 if (echStats.name == foodName) then
  85.                         turtle.suck(foodQuan - 1)
  86.                         foodHave = true
  87.                         command = false
  88.                 end
  89.         end
  90.                 turtle.turnRight()
  91.                 turtle.forward()
  92. end
  93.  
  94. --fin block de dessou
  95. end
  96.  
  97.  
  98. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement