Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local pi = component.playerinterface
- local chest = component.chest
- local chatbox = nil
- ------ CONFIG SECTION STARTS HERE -------
- pi.setOutputSide("south") -- Hopper side
- pi.setInputSide("west") -- Oxygen supply chest side
- local playername = "Subtixx" -- (Your) Playername to chat to
- local delay = 5 -- Delay between checks
- local tankToKeepInInv = 3 -- Amount of tanks to keep supplied in your inventory
- local shouldSmallTanksCount = false -- Count small tanks to tank keep in inv
- local stockSmallTanks = false -- Should small tanks be transferred to player
- local stockHotbar = false -- Should the hotbar counted in when searching for a free inventory spot?
- local enableChatBox = true --
- ------ DO NOT MODIFY BEYOND THIS POINT -------
- if(enableChatBox) then
- chatbox = component.peripheralsplusplus_chatbox
- end
- local player = pi.getPlayerInv(playername).value
- local cooldown = {}
- function outputCooldown(text)
- if(cooldown[text] ~= nil) then
- if(cooldown[text] <= (os.time() * 1000/60/60) - 6000) then
- cooldown[text] = nil
- end
- else
- if(enableChatbox) then
- chatbox.tell(playername, tostring(text))
- end
- print(tostring(text))
- cooldown[text] = (os.time() * 1000/60/60) + 6000 -- 12000 (-6000)
- end
- end
- function findFirstFreeInventorySlot()
- for i=0, 36, 1 do
- local itemStack = player.getStackInSlot(i)
- if(itemStack == nil) then
- return i
- end
- end
- outputCooldown("NO ROOM! YOUR INVENTORY IS FULL!")
- end
- function findFirstOxygenChestSlot()
- for i=1, chest.getInventorySize() do
- local itemStack = chest.getStackInSlot(i)
- if(itemStack ~= nil) then
- if(itemStack.id == "GalacticraftCore:item.oxygenTankHeavyFull" or
- (stockSmallTanks and (itemStack.id == "GalacticraftCore:item.oxygenTankMedFull" or
- itemStack.id == "GalacticraftCore:item.oxygenTankLightFull"))) then
- if(i <= 9 and stockHotbar) or (i > 9) then
- return i - 1
- end
- end
- end
- end
- outputCooldown("NO OXYGEN TANKS LEFT! CHECK THE OXYGEN CHEST!")
- end
- function replaceTanks()
- local totalTanks = 0
- for i=0, 36, 1 do
- local itemStack = player.getStackInSlot(i)
- if(itemStack ~= nil) then
- if(itemStack.name == "GalacticraftCore:item.oxygenTankHeavyFull") then
- if(itemStack.meta >= 2700) then
- -- Extract
- player.retrieveFromSlot(i, 1)
- else
- totalTanks = totalTanks + 1
- end
- elseif(itemStack.name == "GalacticraftCore:item.oxygenTankMedFull") then
- if(itemStack.meta >= 1800) then
- player.retrieveFromSlot(i, 1)
- elseif(shouldSmallTanksCount) then
- totalTanks = totalTanks + 1
- end
- elseif(itemStack.name == "GalacticraftCore:item.oxygenTankLightFull") then
- if(itemStack.meta >= 900) then
- player.retrieveFromSlot(i, 1)
- elseif(shouldSmallTanksCount) then
- totalTanks = totalTanks + 1
- end
- end
- end
- end
- while totalTanks < tankToKeepInInv do
- local oxygenSlot = findFirstOxygenChestSlot()
- local inventorySlot = findFirstFreeInventorySlot()
- player.push(oxygenSlot, inventorySlot)
- totalTanks = totalTanks + 1
- end
- end
- while true do
- replaceTanks()
- os.sleep(delay)
- end
Add Comment
Please, Sign In to add comment