Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Change these sides to how you have your door configured
- local wirelessSide = "bottom" --The side with the wireless modem
- local doorSide = "front" --The side that you want the redstone output for your door to go
- local isPlayerDetector = false --Whether there is a player detector attached to the system or not
- local playerDetectorSide = "right" --The side that the player detector is inputing its redstone signal to
- local controllerID = 3 --The id of the computer with the monitor
- function checkStatus() --Checks the status of the door
- local x = redstone.getInput(doorSide) --gets the redsotne input of the door
- if x==false then --tells the controller if it is open or closed
- rednet.send(controllerID,"open")
- elseif x==true then
- rednet.send(controllerID,"closed")
- end
- end
- function playerTest()
- if redstone.getInput(playerDetectorSide)==true then --Tests to see if the player detector is on or off and opens/closes door
- redstone.setOutput(doorSide,false)
- checkStatus()
- elseif redstone.getInput(playerDetectorSide)==false then
- redstone.setOutput(doorSide, true)
- checkStatus()
- end
- end
- rednet.open(wirelessSide) --Opens the router for rednet signals
- while true do
- checkStatus()
- if isPlayerDetector==true then
- playerTest()
- end
- sleep(.1) --Sleep added so that the computer doesn't return an error
- senderId1, msg1, dist1 = rednet.receive(1) --Checks to see if a rednet signal is received to force it open
- if senderId1==controllerID and msg1=="force2" then --If it returns a signal it forces door1 open
- redstone.setOutput(doorSide,false)
- sleep(.1)
- checkStatus() --Updates controller on status
- isOpen=1
- senderId2, msg2, dist2 = rednet.receive() --Waits for signal to stop force opening door1
- end
- if (senderId2==controllerID and msg2=="force2") and isOpen==1 then --Stops force opening the door and updates controller on status
- redstone.setOutput(doorSide,true)
- sleep(.1)
- checkStatus()
- isOpen=0
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement