Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------------
- --> Variables <--
- --------------------------------------------------------
- local me = peripheral.find("appeng_me_tilecable") or peripheral.find("appeng_me_tilecolorlesscable")
- local pim = peripheral.find("pim")
- local chest = peripheral.find("crystal")
- local chestDirection = "north"
- --------------------------------------------------------
- --> Key Names <--
- --------------------------------------------------------
- key_name = nil
- l_key_name = nil
- if fs.exists("/keyNames") then
- local list = gcapi.getListFromFile("/keyNames")
- key_name = list["key_name"]
- l_key_name = list["l_key_name"]
- else
- error("You need to create the keyNames file with the names of the keys ({key_name and l_key_name})")
- end
- --------------------------------------------------------
- --> ME STUFF <--
- --------------------------------------------------------
- function emptyChest()
- me.insertItem(1,64,"up")
- end
- --------------------------------------------------------
- --> PIM STUFF <--
- --------------------------------------------------------
- function checkPlayer(player)
- if getCurrentPlayer() == player then
- return true
- end
- return false
- end
- function getCurrentPlayer()
- return pim.getInventoryName()
- end
- function getKeysInInventory()
- --CONFIG
- local id = 131
- local name = key_name
- qty = 0
- for i,item in pairs(pim.getAllStacks()) do
- if item["id"] == id then
- if item["name"] == name then
- if item["ench"] ~= nil then
- if item["ench"][1] ~= nil and item["ench"][1] == "Unbreaking I" then
- qty = qty + item["qty"]
- end
- end
- end
- end
- end
- return qty
- end
- function moveKeysToSystem(amount)
- --CONFIG
- local id = 131
- local name = key_name
- if amount > getKeysInInventory() then
- return false, "Not enough keys"
- end
- local qty = 0
- for i,item in pairs(pim.getAllStacks()) do
- if item["id"] == id then
- if item["name"] == name then
- if item["ench"] ~= nil then
- if item["ench"][1] ~= nil and item["ench"][1] == "Unbreaking I" then
- local keysMoved = pim.pushItemIntoSlot(chestDirection, i, amount, 1)
- qty = qty + keysMoved
- amount = amount - keysMoved
- end
- end
- end
- end
- end
- emptyChest()
- return qty
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement