Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Recharger by KapitanWalnut
- --3/14/2014 v0.2
- --When incorporated with the proper devices, this program will attempt to recharge a flux device at set intervals.
- --do not have any adjacent redstone signals other then intended... machine looks for redstone signals
- --Intended to be used with continuous harvesting machines such as mob grinders or crop harvesters.
- --NOT intended to be used as remote recharge station. I have a different program for that ;)
- --CONFIG
- waitTime = 60 --seconds to wait before attempting another recharge
- invSide = "left" --side that receives redstone indication signal about state of managed inventory (inv)
- suckSide = "bottom" --side to output redstone signal in order to suck contents from managed inv
- --whether or not device is in charging mode
- charging = false
- --INITIALIZE
- --note: upon initialization, program will assume any items in adjacent inventory need to be recharged.
- function initialize()
- term.clear()
- term.setCursorPos(1,1)
- print("Initializing...")
- sleep(5)
- charging = rs.getInput(invSide) --if nothing in inv, assume it is recharging
- if not charging then --if something in inv, send it to recharge
- suckOn()
- charging = true
- end
- end
- --turn sucker on
- function suckOn()
- rs.setOutput(suckSide, true)
- end
- --turn sucker off
- function suckOff()
- rs.setOutput(suckSide, false)
- end
- --main logic function: handles the mechanics of recharging and waiting to charge
- function mainLogic()
- --wait for redstone signal to change
- os.pullEvent("redstone")
- --get state of input
- tempState = rs.getInput(invSide)
- if tempState then --if true, means inventory is empty, so turn sucker off
- suckOff()
- term.clear()
- term.setCursorPos(1,1)
- print("Device sent to charger...")
- else --if false, means inventory has item in it
- term.clear()
- term.setCursorPos(1,1)
- print("Device received from charger.")
- print("Harvesting for ",waitTime," seconds...")
- sleep(waitTime) --wait specified time
- suckOn() --turn on sucker to charge again
- end
- end
- --main function
- function main()
- initialize()
- while true do --infinite loop
- mainLogic()
- end
- end
- --run main function
- main()
Advertisement
Add Comment
Please, Sign In to add comment