SHARE
TWEET

Untitled

a guest Jun 16th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- transactions.lua
  2. local M = {}
  3.  
  4. local cp = requires("component")
  5. local tap = component.transposer
  6.  
  7. --range as being a list of indices
  8. local function getOpenSlotInRange(chest, range)
  9.     local n = # range
  10.     for i = range[1], n do
  11.         slot = range[i]
  12.         stack = tap.getStackInSlot(chest, slot)
  13.  
  14.         if stack == nil then
  15.             return slot
  16.         end
  17.     end
  18.  
  19. end
  20.  
  21. local function getFilledSlotsInRange(chest, range)
  22.     local n = # range
  23.     for i = range[1], n do
  24.         slot = range[i]
  25.         stack = tap.getStackInSlot(chest, slot)
  26.  
  27.         if stack == nil then
  28.             -- do nothing return range[i]
  29.         else
  30.             return slot
  31.         end
  32.     end
  33.  
  34.     return range[1] -- return first value if all else fails
  35. end
  36.  
  37. M.getOpenSlotInRange = getOpenSlotInRange
  38. M.getFilledSlotsInRange = getFilledSlotsInRange
  39.  
  40.  
  41. return M
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top