Advertisement
GauHelldragon

PowerMon v0.1

Jun 2nd, 2013
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2. local power = sensor.wrap("left")
  3. if ( power == nil ) then
  4.     print("No sensor!")
  5.     os.exit()
  6. end
  7.  
  8. -- coordinates of block to monitor
  9. local location = "-1,1,0"
  10.  
  11. -- amount of energy space needed to turn on
  12. local trigger = 2000
  13.  
  14.  
  15. function getEnergySpace()
  16.     local blockInfo = power.getTargetDetails(location)
  17.     if ( blockInfo == nil ) then
  18.       print("Can't get block info")
  19.       os.exit()
  20.     end
  21.     return blockInfo["EnergySunken"]
  22. end
  23.  
  24.  
  25. while true do
  26.     if ( getEnergySpace() < trigger ) then
  27.         rs.setOutput("top",true)
  28.         os.sleep(2)
  29.     else
  30.         rs.setOutput("top",false)
  31.         os.sleep(10)
  32.     end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement