-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
116 lines (65 loc) · 2.26 KB
/
main.lua
File metadata and controls
116 lines (65 loc) · 2.26 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
if not dan.participants then dan.participants = {} end
local save_data_interval = 10 * 1000
local function is_time_to_save_data()
if dan.save_data_requested and ( (dan.save_data_requested + save_data_interval) < GetServerUptimeMs() ) then
return true
else
return false
end
end
local function handle_session_attributes_changed()
if is_time_to_save_data() then
SavePersistentData()
dan.save_data_requested = false
end
end
local function handle_session( event )
end
local function handle_partipant_created( event )
dan.participants[event.participantid] = {}
dan.participants[event.participantid].refid = event.refid
end
local function handle_partipant_destroyed( event )
if dan.participants[event.participantid] then
dan.participants[event.participantid] = nil
end
end
local function handle_partipant( event )
if ( event.name == "ParticipantCreated" ) then
handle_partipant_created( event )
elseif ( event.name == "ParticipantDestroyed" ) then
handle_partipant_destroyed( event )
end
end
local function main( callback, ... )
if callback == Callback.Tick then
flush()
elseif callback == Callback.SessionAttributesChanged then
-- used instead of Tick
handle_session_attributes_changed()
elseif callback == Callback.EventLogged then
local event = ...
if event.type == "Session" then
handle_session( event )
elseif event.type == "Participant" then
handle_partipant( event )
end
end
invoke_modules( callback, ... )
end
RegisterCallback( main )
EnableCallback( Callback.Tick )
EnableCallback( Callback.EventLogged )
EnableCallback( Callback.SessionAttributesChanged )
EnableCallback( Callback.ServerStateChanged )
-- EnableCallback( Callback.MemberStateChanged )
-- EnableCallback( Callback.MemberStateChanged )
-- EnableCallback( Callback.ParticipantAttributesChanged )
-- EnableCallback( Callback.MemberLeft )
-- EnableCallback( Callback.MemberJoined )
-- EnableCallback( Callback.HostMigrated )
-- EnableCallback( Callback.SessionManagerStateChanged )
-- EnableCallback( Callback.ParticipantCreated )
-- EnableCallback( Callback.ParticipantRemoved )
-- EnableCallback( Callback.NextSessionAttributesChanged )
-- EnableCallback( Callback.MemberAttributesChanged )