Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modem = peripheral.wrap("bottom")
- local charger = "batbox_1"
- local charger2 = "tile_thermalexpansion_machine_charger_name_2"
- local chest = peripheral.wrap("right")
- local cSize = chest.getInventorySize()
- print("This computer monitors the batbox and chest connected to it")
- print("When a jetpack is in the chest and is not fully charged, it is pushed into batbox.")
- print("When an item is in the batbox and is fully charged, it is pushed into the chest")
- function isCharging()
- local item = modem.callRemote(charger,"getStackInSlot",1)
- if ( item == nil ) then
- -- print "no item"
- return false
- end
- if ( item.dmg <= 1 ) then
- -- print "item is charged, pushing"
- modem.callRemote(charger,"pushItem","north",1)
- os.sleep(1)
- return false
- end
- -- print "item is not charged"
- return true
- end
- function isCharging2()
- local item = modem.callRemote(charger2,"getStackInSlot",1)
- if ( item == nil ) then
- return false
- end
- return true
- end
- function isChargableItem(item)
- if ( item == nil ) then return false end
- if ( item.id == 30209 ) then --Jetpack
- if ( item.dmg > 1 ) then return true end
- end
- return false
- end
- function isChargableItem2(item)
- if ( item == nil ) then return false end
- if ( item.id == 20759 ) then --Flux Sword
- if ( item.energyStored < item.maxEnergyStored ) then return true end
- end
- return false
- end
- function chargeItem()
- for slot = 1,cSize do
- local item = chest.getStackInSlot(slot)
- if ( item ~= nil and isChargableItem(item) ) then
- chest.pushItem("south",slot)
- os.sleep(1)
- return
- end
- if ( item ~= nil and isChargableItem2(item )) then
- chest.pushItem("west",slot)
- os.sleep(1)
- return
- end
- end
- end
- while true do
- if ( isCharging() == false or isCharging2() == false ) then
- chargeItem()
- else
- os.sleep(10)
- end
- os.sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement