-
Notifications
You must be signed in to change notification settings - Fork 0
/
iris.lua
60 lines (52 loc) · 1.26 KB
/
iris.lua
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
50
51
52
53
54
55
56
57
58
59
60
-- Stargate Iris Control library by TinyDeskEngie1
-- Makes controlling AUNIS stargate iris via OpenComputers less tedious
c = require("component")
sg = c.stargate
iris = {}
iris.exists = function() -- Checks if there is an iris installed on the connected stargate.
if sg.getIrisType ~= "NULL" then
return true
else
return false
end
end
iris.isBusy = function() -- Checks if the iris is currently opening or closing
local state = sg.getIrisState()
if state == "CLOSING" or state == "OPENING" then
return true
else
return false
end
end
iris.isActive = function() -- Checks if the iris is set to be closed.
local state = sg.getIrisState()
if state == CLOSING or state == "CLOSED" then
return true
else
return false
end
end
iris.setState = function(newState) -- Changes the state of the iris based on a boolean value. Returns string based on result.
if not iris.exists() then
return "no_iris"
end
if iris.isBusy() then
return "iris_busy"
end
if newState then
if not iris.isActive() then
sg.toggleIris()
return "success"
else
return "no_change"
end
else
if iris.isActive() then
sg.toggleIris()
return "success"
else
return "no_change"
end
end
end
return iris