Advertisement
Guest User

compressItems.lua

a guest
Mar 29th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. local component = require("component")
  2. local sides = require("sides")
  3. local transposer = component.transposer
  4. local thread = require("thread")
  5.  
  6. local chestSlots = transposer.getInventorySize(sides.front)
  7.  
  8. local activeSlot = 1
  9.  
  10. local allowedStackSize = 9
  11.  
  12. print("Input chest has " .. chestSlots .. " slots")
  13. print("Allowed stack size: " .. allowedStackSize)
  14. while(true) do
  15.   if(activeSlot > chestSlots) then activeSlot = 1 end
  16.  
  17.   --Check if less than transferStackSize -- if so, increment activeSlot by 1 and loop
  18.   --Else check destination is ready
  19.   --Once ready, send stack
  20.   --Loop
  21.  
  22.   local activeSlotStackSize = transposer.getSlotStackSize(sides.front,activeSlot)
  23.   local continue = true
  24.   print("Active Slot Stack Size: " .. activeSlotStackSize)
  25.   if(activeSlotStackSize < allowedStackSize) then
  26.     activeSlot = activeSlot + 1
  27.     continue = false
  28.   end
  29.  
  30.   while(continue) do
  31.     if(transposer.getSlotStackSize(sides.back,1) == 0) then
  32.       transposer.transferItem(sides.front, sides.back, allowedStackSize,activeSlot,1)
  33.       continue = false
  34.       print("Compressed 1 stack from slot " .. activeSlot)
  35.     end
  36.   end
  37.  
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement