-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdebugtools_server.lua
34 lines (29 loc) · 1.08 KB
/
debugtools_server.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
debugtools = {
}
local service_creation_order = {
'entity_tracker'
}
local function create_service(name)
local path = string.format('debugtools.services.server.%s.%s_service', name, name)
local service_path = require(path)
assert(service_path, "Could not find a debug tools service. Are you sure your debugtools mod folder is named correctly? It should be 'debugtools' not 'debugtools_master'")
local service = service_path()
local saved_variables = debugtools._sv[name]
if not saved_variables then
saved_variables = radiant.create_datastore()
debugtools._sv[name] = saved_variables
end
service.__saved_variables = saved_variables
service._sv = saved_variables:get_data()
saved_variables:set_controller(service)
service:initialize()
debugtools[name] = service
end
radiant.events.listen(debugtools, 'radiant:init', function()
debugtools._sv = debugtools.__saved_variables:get_data()
-- now create all the services
for _, name in ipairs(service_creation_order) do
create_service(name)
end
end)
return debugtools