Advertisement
dlord

/reactorcontainment/cover

Nov 25th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 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. local args = { ... }
  16.  
  17. local coverOpen=colors.green
  18. local coverClose=colors.red
  19. local cableLocation="bottom"
  20.  
  21. local controlCover = function(cableLocation, op)
  22. for i=1,2 do
  23. redstone.setBundledOutput(cableLocation, op)
  24. sleep(0.100)
  25. redstone.setBundledOutput(cableLocation, 0)
  26. sleep(0.900)
  27. end
  28. end
  29.  
  30. local open = function()
  31. if redstone.testBundledInput(cableLocation, coverClose) then
  32. controlCover(coverOpen)
  33. else
  34. print("Nuclear Reactor Cover already opened!")
  35. end
  36. end
  37.  
  38. local close = function()
  39. if redstone.testBundledInput(cableLocation, coverClose) ~= true then
  40. controlCover(coverClose)
  41. else
  42. print("Nuclear Reactor Cover already closed!")
  43. end
  44. end
  45.  
  46.  
  47. local checkArguments = function()
  48. local action = args[1]
  49. local doorType = args[2]
  50.  
  51. if action == "open" then
  52. open()
  53. elseif action == "close" then
  54. close()
  55. end
  56. end
  57.  
  58. -- check arguments
  59.  
  60. if #args > 1 then
  61. checkArguments()
  62. else
  63. print("cover [open/close]")
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement