-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnet_tags.lua
More file actions
69 lines (59 loc) · 1.46 KB
/
Copy pathnet_tags.lua
File metadata and controls
69 lines (59 loc) · 1.46 KB
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
-- These are the types of messages the client and server both know about
ESTABLISH_YES = "id confirmed"
ESTABLISH_REQ = "est"
EXIT = "exit"
BEAT = "beat"
ITERATE = "iterate_num"
SYNC = "NUM " -- space is important!
TABLE_REQ = "TABLEREQ "
TABLE_SET = "TABLESET "
STARTGAME = "START "
-- Example:
-- getArgFrom("NUM 5","NUM") --> '5'
-- getArgFrom("NUM 5","TABLEREQ") --> nil
-- getArgFrom("TABLESET foo bar","TABLESET") --> "TABLESET" "foo" "bar"
function getArgFrom(recv,command)
local val = {}
if recv:match(command..".*") then
val = stringSplit(recv)
end
if #val == 0 then
return nil
end
if #val == 2 then
return val[2]
end
return val
end
function stringSplit(str)
words = {}
for word in str:gmatch("%w+") do
table.insert(words, word)
end
return words
end
function constructOutput()
local output = ""
output = output .. myip .. ':' .. PORT .. '\n'
if server ~= nil then
if isClient then
output = output .. "Is Client\n"
if established then
output = output .. "Connected!\n"
else
output = output .. "Not Connected\n"
end
output = output .. TheNumber .. "\n"
else
output = output .. "Is Server\n"
output = output .. "Clients on board:\n"
for i=1,#Agents do
output = output .. Agents[i].ID .. '\n'
output = output .. '\t' .. Agents[i].ttk .. '\n'
end
output = output .. "------"
output = output .. '\n'
end
end
return output
end