Advertisement
abouttabs

randomDrop

Jan 3rd, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. chestA = peripheral.wrap("back")
  2. chestB = peripheral.wrap("top")
  3. dispenserA = peripheral.wrap("left")
  4. dispenserB = peripheral.wrap("right")
  5. amountA = 0
  6. amountB = 0
  7. amountA = 0
  8. amountB = 0
  9. randomA = 0
  10. randomB = 0
  11. slotRA = 0
  12. slotRB = 0
  13.  
  14.  
  15.  
  16.  
  17. function amount()
  18.   for j = 1, chestA.getInventorySize() do
  19.     if chestA.getStackInSlot(j) ~= nil then
  20.     --Checks the amount of items in chest A
  21.       amountA = amountA + 1
  22.     end
  23.   end
  24.   print(amountA)
  25.   for k = 1, chestB.getInventorySize() do
  26.     if chestB.getStackInSlot(k) ~= nil then
  27.     --Checks the amount of items in chest B
  28.       amountB = amountB + 1
  29.     end
  30.   end
  31.   print(amountB)
  32. end
  33.  
  34. function numbers()
  35.   randomA = math.random(amountA)
  36.   randomB = math.random(amountB)
  37.   --Random numbers for output for randomizing drop
  38. end
  39.  
  40. function push()
  41.   chestA.pushItemIntoSlot("north",randomA,1,1)
  42.   --should push to chest in between of this one and dispenser
  43.   chestB.pushItemIntoSlot("south",randomB,1,1)
  44.   dispenserA.pullItemIntoSlot("east",1,1,5)
  45.   dispenserB.pullItemIntoSlot("up",1,1,5)  
  46.   rs.setOutput("left", true)
  47.   rs.setOutput("right", true)
  48.   sleep(0,5)
  49.   rs.setOutput("left", false)
  50.   rs.setOutput("right", false)
  51.   --dispenses things
  52. end
  53.  
  54. function wait()
  55.   backA = 0
  56.   backB = 0
  57.   while true do
  58.     if backA == 0 then
  59.       for l = 1, 9 do
  60.         if dispenserA.getStackInSlot(l) ~= nil then
  61.         --should wait for when item is reinserted to dispenser
  62.           backA = 1
  63.           slotRA = l
  64.           --logs which slot item had been put into
  65.         end
  66.       end
  67.     end
  68.     if backB == 0 then
  69.       for m = 1, 9 do
  70.         if dispenserB.getStackInSlot(m) ~=nil then
  71.         --should wait for when item is reinserted to dispenser
  72.           backB = 1
  73.           slotRB = m
  74.           --logs which slot item had been put into
  75.         end
  76.       end
  77.     end
  78.     if backA == 1 and backB == 1 then
  79.     --if both are back it breaks the loop
  80.       break
  81.     end
  82.   end
  83. end
  84.  
  85. function back()
  86.   dispenserA.pushItemIntoSlot("east",slotRA,1,1)
  87.   --takes from dispenser from slot that has been logged, inot chest inbetween
  88.   dispenserB.pushItemIntoSlot("up",slotRB,1,1)
  89.   chestA.pullItemIntoSlot("north", 1, 1, randomA)
  90.   chestB.pullItemIntoSlot("south", 1, 1, randomB)
  91. end
  92.  
  93. amount()
  94. numbers()
  95. push()
  96. wait()
  97. back()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement