Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- local power = sensor.wrap("left")
- if ( power == nil ) then
- print("No sensor!")
- os.exit()
- end
- -- coordinates of block to monitor
- local location = "-1,1,0"
- -- amount of energy space needed to turn on
- local trigger = 2000
- function getEnergySpace()
- local blockInfo = power.getTargetDetails(location)
- if ( blockInfo == nil ) then
- print("Can't get block info")
- os.exit()
- end
- return blockInfo["EnergySunken"]
- end
- while true do
- if ( getEnergySpace() < trigger ) then
- rs.setOutput("top",true)
- os.sleep(2)
- else
- rs.setOutput("top",false)
- os.sleep(10)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement