Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Original door by Snirkimmington, modified door by Dragon53535
- local minX = -3 local maxX = 0 -- You're going to need to edit these to where you want them to stand to open the door.
- local minY = 0 local maxY = 4
- local minZ = 0 local maxZ = 2
- local Side = "bottom" -- What side is the sensor on?
- local output = 'right' -- Where to output the signal
- local initial = true -- what to output the first signal as
- local initial2 = false -- what to output the second signal as
- local output2 = "top" -- where to output the second signal
- local Filename = "Config"
- local sensor
- if peripheral.isPresent(Side) then
- sensor = peripheral.wrap(Side)
- end
- local nameData = {}
- local file = fs.open(Filename,"r")
- local line = file.readLine()
- repeat
- table.insert(nameData,line)
- line = file.readLine()
- until line == nil
- file.close()
- local lolol = false
- local timer = os.startTimer(0.05) -- where the sensor is
- local alpha = false
- -- Initial output
- sleep(0.5)
- redstone.setOutput(output, initial)
- redstone.setOutput(output2,initial2)
- local function Sensor()
- players = sensor.getPlayerNames()
- if #players ~= 0 then -- There are players
- for _, name in pairs(players) do
- for _,user in pairs(nameData) do
- if user == name then
- info = sensor.getPlayerData(name)
- pos = info.position
- if pos.x >= minX and pos.x <= maxX
- and pos.y >= minY and pos.y <= maxY
- and pos.z >= minZ and pos.z <= maxZ then
- redstone.setOutput(output2,not initial2)
- sleep(0.05)
- redstone.setOutput(output,not initial)
- timer = os.startTimer(0.1)
- alpha = true
- break
- end
- if alpha then
- alpha = false
- break
- end
- end
- end
- end
- end
- end
- local function Timer()
- while true do
- local event, param1 = os.pullEvent()
- if event == "timer" and param1 == timer then
- redstone.setOutput(output2, initial2)
- sleep(0.05)
- redstone.setOutput(output,initial)
- elseif event == "char" and param1 == "c" then
- lolol = true
- break
- end
- end
- end
- local function Resetconfig()
- nameData = {}
- file = fs.open(Filename,"r")
- line = file.readLine()
- repeat
- table.insert(nameData,line)
- line = file.readLine()
- until line == nil
- end
- while true do
- if lolol then
- shell.run("edit",Filename)
- lolol = false
- Resetconfig()
- else
- parallel.waitForAny(Timer,Sensor)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment