Advertisement
Guest User

powerManager.lua

a guest
Apr 6th, 2020
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1. function switch()
  2.     repeat
  3.         redstone.setOutput("left", true)
  4.         redstone.setOutput("right", true)
  5.         redstone.setOutput("top", true)
  6.         sleep(1)
  7.         redstone.setOutput("left", false)
  8.         redstone.setOutput("right", false)
  9.         redstone.setOutput("top", false)
  10.         sleep(10)
  11.     until redstone.getInput("back")
  12. end    
  13.  
  14. function checkPower(value)
  15.     power = redstone.getAnalogInput("back")
  16.     if value == "full" then
  17.         return power == 15
  18.     elseif value == "empty" then
  19.         return power == 0
  20.     end
  21. end    
  22.  
  23. while true do
  24.     if checkPower(arg[1]) then
  25.         print("Switching Power Cell")
  26.         switch()
  27.     else
  28.         print("Not switching")
  29.     end
  30.     os.pullEvent("redstone")
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement