Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function initialize()
- transposer = require("transposer")
- inventory_controller = require("inventory_controller")
- sides = require("sides")
- chestAccess = component.inventory_controler
- transposer = component.transposer
- end
- function information()
- print("StormWolf's Chest API for manipulating and checking inventories around it. Open source as long as I am creditted as the original author.")
- print("REQUIRES A TRANSPOSER AND AN INVENTORY CONTROLLER")
- print("All functions return 0 if there is no inventory unless otherwise documented.")
- print("Available functions:")
- print("inventoryScanner(side) - returns the inventory of inventory on given side.")
- print("getMaxSize(side) - gives the maxiumum size of the inventory.")
- print("transferItem(source, destination, sourceSlot, destinationSlot, quantity) - provide the written values and it will transfer an item.")
- print("---------------------------------------------------------------------------------------------------------------------------------------------------")
- print("Feel free to PM StormWolf with any functions you want added, they are mostly added on a per needed basis.")
- end
- local function isValid(side)
- if not chestAccess.getInventorySize(side) then
- return false
- elseif chestAccess.getInventorySize(side) then
- return true
- end
- return 0
- end
- function inventoryScanner(side)
- if not chestAccess.getInventorySize(side) then return 0 end
- size = chestAccess.getInventorySize(side)
- i = 1
- while i<size do
- item = chestAccess.getStackInSlot(side, i)
- if isValid(side)==false then break end
- inventory[i] = tostring(item.label)
- i=i+1
- end
- return inventory
- end
- function getMaxSize(side)
- if isValid(side)==false then return 0 end
- size = chestAccess.getInventorySize(side)
- return size
- end
- function transferItem(source, destination, sourceSlot, destinationSlot, quantity)
- source = tonumber(source)
- destination = tonumber(destination)
- sourceSlot = tonumber(sourceSlot)
- destinationSlot = tonumber(destinationSlot)
- quantity = tonumber(quantity)
- if not isValid(source) then return 0 end
- if not isValid(destination) then return 0 end
- invAccess.transferItem(source, destination, sourceSlot, location, quantity)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement