Advertisement
dlord

/cc/pumpcontrol

Nov 1st, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.62 KB | None | 0 0
  1. --   Copyright 2012 John Paul Alcala
  2. --
  3. --   Licensed under the Apache License, Version 2.0 (the "License");
  4. --   you may not use this file except in compliance with the License.
  5. --   You may obtain a copy of the License at
  6. --
  7. --       http://www.apache.org/licenses/LICENSE-2.0
  8. --
  9. --   Unless required by applicable law or agreed to in writing, software
  10. --   distributed under the License is distributed on an "AS IS" BASIS,
  11. --   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. --   See the License for the specific language governing permissions and
  13. --   limitations under the License.
  14.  
  15.  
  16. local args = { ... }
  17. local cableLocation = "bottom"
  18. local drainPump = colors.black
  19. local fillPump = colors.blue
  20. local doorLock = colors.red
  21. local fillTime = 30
  22. local drainTime = 45
  23. local isDoorClosed = redstone.testBundledInput(cableLocation, doorLock)
  24.  
  25. local pumpControl = function(cableLocation, op, time)
  26.   redstone.setBundledOutput(cableLocation, op)
  27.   sleep(time)
  28.   redstone.setBundledOutput(cableLocation, 0)
  29. end
  30.  
  31. local fillAirlock = function()
  32.   if isDoorClosed then
  33.     print("Filling Airlock.")
  34.     pumpControl(cableLocation, fillPump, fillTime)
  35.   else
  36.     print("Close the door first!")
  37.   end
  38. end
  39.  
  40. local drainAirlock = function()
  41.   print("Draining Airlock.")
  42.   pumpControl(cableLocation, drainPump, drainTime)
  43. end
  44.  
  45. local checkArguments = function()
  46.   local arg = args[1]
  47.  
  48.   if arg == "fill" then
  49.     fillAirlock()
  50.   elseif arg == "drain" then
  51.     drainAirlock()
  52.   end
  53. end
  54.  
  55. -- check args
  56.  
  57. if #args > 0 then
  58.   checkArguments()
  59. else
  60.   print("pumpcontrol [fill/drain]")
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement