Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function initialize()
- _G.component = require("component")
- _G.sides = require("sides")
- _G.chestAccess = component.inventory_controller
- _G.transposer = component.transposer
- version = 0.2
- --Notes from chummy:
- --[[ -----------------------------------------------------------
- If you are editing variables in the global scope
- (Variables which are not local inside of your function,
- or above it), use _G. It means GLOBAL.
- If you wanted to make it so component/sides/chestAccess/transposer
- are local, you can make this function return them, like so:
- --return component, sides, chestAccess, transposer
- Note that you would have to remove _G from the declarations.
- I suggest searching "Variable Scoping In LUA"
- ]] -------------------------------------------------------------
- end
- function information()
- print("Version number: "..tostring(version))
- 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("---------------------------------------------------------------------------------------------------------------------------------------------------")
- print("Feel free to PM StormWolf with any functions you want added, they are mostly added on a per needed basis.")
- end
- 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
- return {
- initialize,
- isValid,
- inventoryScanner,
- getMaxSize,
- transferItem
- }
Add Comment
Please, Sign In to add comment