-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgate.lua
More file actions
49 lines (42 loc) · 808 Bytes
/
gate.lua
File metadata and controls
49 lines (42 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
-- By Roachy
sleepWait = .5
delayWait = 2
open = false
closed = true
inputSide = "left"
outputSide = "back"
local function getState()
return redstone.getOutput(outputSide)
end
local function getInput()
return redstone.getInput(inputSide)
end
local function doOpen()
print("Toggling gate to OPEN...")
redstone.setOutput(outputSide, open)
end
local function doClose()
print("Toggling gate to CLOSED...")
redstone.setOutput(outputSide, closed)
end
local function toggle()
state = getState()
if(state == closed) then
doOpen()
elseif(state == open) then
doClose()
else
print("Invalid state detected. Opening gate...")
doOpen()
end
end
print("Starting up...")
doClose()
while true do
sleep(sleepWait)
if(getInput()) then
print("Input received.")
toggle()
sleep(delayWait)
end
end