forked from acidjazz/drmon
-
Notifications
You must be signed in to change notification settings - Fork 2
/
pocket.lua
70 lines (65 loc) · 1.44 KB
/
pocket.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
61
62
63
64
65
66
67
68
69
local id, message
function update(text)
while true do
statusColor = colors.red
if text == "running" then
statusColor = colors.green
elseif text == "offline" then
statusColor = colors.gray
elseif text == "warming_up" then
statusColor = colors.orange
end
term.setTextColor(statusColor)
print(text)
end
end
function out()
modem = "none"
local list = peripheral.getNames()
for i = 1, #list do
check = peripheral.getMethods(list[i])
for a = 1, #check do
if check[a] == "isWireless" then
test = peripheral.wrap(list[i])
if test.isWireless() then
modem = list[i]
end
end
end
end
if modem ~= "none" then
while true do
if not rednet.isOpen(modem) then
rednet.open(modem)
end
rednet.broadcast("status")
sleep(10)
term.clear()
end
end
end
function input()
modem = "none"
local list = peripheral.getNames()
for i = 1, #list do
check = peripheral.getMethods(list[i])
for a = 1, #check do
if check[a] == "isWireless" then
test = peripheral.wrap(list[i])
if test.isWireless() then
modem = list[i]
end
end
end
end
if modem ~= "none" then
while true do
if not rednet.isOpen(modem) then
rednet.open(modem)
end
id,message = rednet.receive()
update(message.status)
end
end
end
parallel.waitForAll(out, input)