Advertisement
Guest User

PainCraft0.007

a guest
Mar 3rd, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --           Variables
  2.  
  3. -- slots
  4.  
  5. local slot = 0
  6. local slotActuel = 0
  7. local slotsMax = 16
  8. local nbItemSlot = 0
  9.  
  10. -- bucket
  11.  
  12. local bucketSlot = 0
  13. local bucketSlotFound = false;
  14. local bucketEmpty = "minecraft:bucket"
  15. local bucketFull = "minecraft:water_bucket"
  16. local bucketPlein = false;
  17. local bucketFound = false;
  18.  
  19.  
  20. --          Fonctions
  21.  
  22. -- Main
  23.  
  24. function main()
  25.  
  26. findBucketSlot()
  27.  
  28. end
  29.  
  30. -- Slot
  31.  
  32. function selectSlot(a)
  33.  
  34.     turtle.select(a)
  35.     majSlot()
  36.  
  37. end
  38.  
  39. function majSlot()  -- A LANCER APRES CHAQUE DEPLACEMENT
  40.  
  41. slotActuel = turtle.getSelectedSlot()
  42.    
  43.     if itemInSlot() then
  44.     slot = turtle.getDetailItem()
  45.     end
  46.  
  47.  
  48. end
  49.  
  50. function firstSlot()
  51.  
  52.     selectSlot(1)
  53.  
  54. end
  55.  
  56. function upSlot()
  57.    
  58.     selectSlot(slotActuel + 1)
  59.  
  60. end
  61.  
  62.  
  63.  
  64. function slotIsBucket()
  65.  
  66.     if slot.name == bucketEmpty or slot.name == bucketFull then
  67.     return true
  68.     else
  69.     return false
  70.     end
  71.  
  72.  
  73. end
  74.  
  75.  
  76. function itemInSlot()
  77.  
  78.     nbItemSlot = turtle.getItemCount()
  79.  
  80.     if nbItemSlot > 0 then
  81.     return true
  82.     else
  83.     return false
  84.     end
  85.  
  86. end
  87.  
  88.  
  89. -- Bucket
  90.  
  91. function bucketCheckSlot()
  92.    
  93.     if itemInSlot() then
  94.        
  95.         if slotIsBucket() then
  96.         bucketFound = true
  97.         else
  98.         end
  99.     end
  100. end
  101.  
  102. function findBucketSlot()
  103.  
  104. firstSlot()
  105.  
  106.     while not bucketFound do
  107.     bucketCheckSlot()
  108.     upSlot()
  109.     end
  110.  
  111.  
  112. end
  113.  
  114.  
  115. function bEtat()
  116.  
  117.     selectSlot(bucketSlot)
  118.  
  119.     if bIsEmpty() then
  120.     bucketPlein = false;
  121.    
  122.     elseif bIsFull() then
  123.     bucketPlein = true;
  124.  
  125.     end
  126.    
  127.  
  128. end
  129.  
  130. function bIsEmpty()
  131.  
  132.     if slot.name == bucketEmpty then
  133.    
  134.     return true
  135.     else
  136.     return false
  137.     end
  138.  
  139. end
  140.  
  141.  
  142. function bIsFull()
  143.  
  144.     if slot.name == bucketFull then
  145.  
  146.     return true
  147.     else
  148.     return false
  149.     end
  150.  
  151. end
  152.  
  153.  
  154.  
  155. -- exec
  156.  
  157. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement