Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Copyright 2012 John Paul Alcala
- --
- -- Licensed under the Apache License, Version 2.0 (the "License");
- -- you may not use this file except in compliance with the License.
- -- You may obtain a copy of the License at
- --
- -- http://www.apache.org/licenses/LICENSE-2.0
- --
- -- Unless required by applicable law or agreed to in writing, software
- -- distributed under the License is distributed on an "AS IS" BASIS,
- -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- -- See the License for the specific language governing permissions and
- -- limitations under the License.
- local args = { ... }
- local entranceHatchOpen=colors.blue
- local entranceHatchClose=colors.red
- local exitHatchOpen=colors.green
- local exitHatchClose=colors.yellow
- local controlDoor = function(op)
- for i=1,2 do
- redstone.setBundledOutput("top", op)
- sleep(0.100)
- redstone.setBundledOutput("top", 0)
- sleep(0.900)
- end
- end
- local openEntranceHatch = function()
- if redstone.testBundledInput("top", entranceHatchClose) then
- controlDoor(entranceHatchOpen)
- else
- print("Entrance Hatch already opened!")
- end
- end
- local closeEntranceHatch = function()
- if redstone.testBundledInput("top", entranceHatchClose) ~= true then
- controlDoor(entranceHatchClose)
- else
- print("Entrance Hatch already closed!")
- end
- end
- local openExitHatch = function()
- if redstone.testBundledInput("top", exitHatchClose) then
- controlDoor(exitHatchOpen)
- else
- print("Entrance Hatch already opened!")
- end
- end
- local closeExitHatch = function()
- if redstone.testBundledInput("top", exitHatchClose) ~= true then
- controlDoor(exitHatchClose)
- else
- print("Entrance Hatch already closed!")
- end
- end
- local checkArguments = function()
- local action = args[1]
- local doorType = args[2]
- if action == "open" then
- if doorType == "entrance" then
- print("Opening Entrance Hatch")
- openEntranceHatch()
- elseif doorType == "exit" then
- print("Opening Exit Hatch")
- openExitHatch()
- end
- elseif action == "close" then
- if doorType == "entrance" then
- print("Closing Entrance Hatch")
- closeEntranceHatch()
- elseif doorType == "exit" then
- print("Closing Exit Hatch")
- closeExitHatch()
- end
- end
- end
- -- check arguments
- if #args > 1 then
- checkArguments()
- else
- print("doorcontrol [open/close] [entrance/exit]")
- end
Advertisement
Add Comment
Please, Sign In to add comment