Advertisement
Guest User

PainCraft0.006

a guest
Mar 3rd, 2015
188
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.  
  101. function findBucketSlot()
  102.  
  103. firstSlot()
  104.  
  105.     while not bucketFound do
  106.     bucketCheckSlot()
  107.     upSlot()
  108.     end
  109.  
  110.  
  111. end
  112.  
  113.  
  114. function bEtat()
  115.  
  116.     selectSlot(bucketSlot)
  117.  
  118.     if bIsEmpty() then
  119.     bucketPlein = false;
  120.    
  121.     elseif bIsFull() then
  122.     bucketPlein = true;
  123.  
  124.     end
  125.    
  126.  
  127. end
  128.  
  129. function bIsEmpty()
  130.  
  131.     if slot.name == bucketEmpty then
  132.    
  133.     return true
  134.     else
  135.     return false
  136.     end
  137.  
  138. end
  139.  
  140.  
  141. function bIsFull()
  142.  
  143.     if slot.name == bucketFull then
  144.  
  145.     return true
  146.     else
  147.     return false
  148.     end
  149.  
  150. end
  151.  
  152.  
  153.  
  154. -- exec
  155.  
  156. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement