-
Notifications
You must be signed in to change notification settings - Fork 2
/
swarm_dstatus
35 lines (31 loc) · 863 Bytes
/
swarm_dstatus
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
-- SWARM Detail Status
-- Simple tool to send signal to drone(s) to query detailled status report.
-- If [id] argument is omitted, signal is broadcasted to all drones.
-- Usage: swarm_status [id]
print("SWARM Detail Status ["..os.getComputerID().."]")
local tArgs = { ... }
rednet.open("back")
if #tArgs == 1 then
rednet.send(tonumber(tArgs[1]),string.char(120))
else
rednet.broadcast(string.char(120))
end
print("Waiting for response(s), press Q to quit.")
local e,msg
while true do
--sleep(0)
e = {os.pullEvent()}
if e[1] == "key" then -- Handle key-presses
if e[2] == 16 then
print("Q pressed, quitting...")
break
end
elseif e[1] == "rednet_message" and e[3]:byte(1) == 121 then
print(e[2]..": "..string.sub(e[3],2))
local data = textutils.unserialize(string.sub(e[3],2))
print(data[1])
if #tArgs == 1 then
return
end
end
end