2020-10-21 13:45:45 +02:00
|
|
|
local Poll = {
|
|
|
|
send_poll_result_to_discord = function()
|
|
|
|
end
|
|
|
|
}
|
2019-02-20 11:43:29 +01:00
|
|
|
local Token = require 'utils.token'
|
|
|
|
local Server = require 'utils.server'
|
|
|
|
|
|
|
|
--- This module is for the web server to call functions and raise events.
|
|
|
|
-- Not intended to be called by scripts.
|
|
|
|
-- Needs to be in the _G table so it can be accessed by the web server.
|
|
|
|
ServerCommands = {}
|
|
|
|
|
|
|
|
ServerCommands.get_poll_result = Poll.send_poll_result_to_discord
|
|
|
|
|
|
|
|
function ServerCommands.raise_callback(func_token, data)
|
|
|
|
local func = Token.get(func_token)
|
|
|
|
func(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
ServerCommands.raise_data_set = Server.raise_data_set
|
2024-03-28 23:37:14 +01:00
|
|
|
ServerCommands.raise_admins = Server.raise_admins
|
2019-02-20 11:43:29 +01:00
|
|
|
ServerCommands.get_tracked_data_sets = Server.get_tracked_data_sets
|
|
|
|
|
2023-09-24 01:01:43 +02:00
|
|
|
ServerCommands.raise_scenario_changed = Server.raise_scenario_changed
|
|
|
|
ServerCommands.get_tracked_scenario = Server.get_tracked_scenario
|
|
|
|
|
2019-02-20 11:43:29 +01:00
|
|
|
function ServerCommands.server_started()
|
|
|
|
script.raise_event(Server.events.on_server_started, {})
|
|
|
|
end
|
|
|
|
|
2022-10-21 21:49:49 +02:00
|
|
|
function ServerCommands.changes_detected()
|
|
|
|
script.raise_event(Server.events.on_changes_detected, {})
|
|
|
|
end
|
|
|
|
|
2019-02-20 11:43:29 +01:00
|
|
|
ServerCommands.set_time = Server.set_time
|
2023-11-25 20:48:06 +01:00
|
|
|
ServerCommands.set_output = Server.set_output
|
2020-10-21 13:34:59 +02:00
|
|
|
ServerCommands.set_ups = Server.set_ups
|
2020-10-21 13:45:45 +02:00
|
|
|
ServerCommands.get_ups = Server.get_ups
|
2020-10-26 23:55:06 +01:00
|
|
|
ServerCommands.export_stats = Server.export_stats
|
2021-01-11 23:34:19 +01:00
|
|
|
ServerCommands.set_start_data = Server.set_start_data
|
2022-01-18 00:07:25 +01:00
|
|
|
ServerCommands.set_instances = Server.set_instances
|
2019-02-20 11:43:29 +01:00
|
|
|
ServerCommands.query_online_players = Server.query_online_players
|
2022-11-24 15:21:41 +01:00
|
|
|
ServerCommands.ban_handler = Server.ban_handler
|
2019-02-20 11:43:29 +01:00
|
|
|
|
2022-07-10 19:41:26 +02:00
|
|
|
function is_loaded(module)
|
|
|
|
local res = _G.package.loaded[module]
|
|
|
|
if res then
|
|
|
|
return res
|
|
|
|
end
|
2023-06-17 23:32:35 +02:00
|
|
|
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
function is_loaded_bool(module)
|
|
|
|
local res = _G.package.loaded[module]
|
|
|
|
if res then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
2022-07-10 19:41:26 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function is_game_modded()
|
|
|
|
local active_mods = game.active_mods
|
|
|
|
local i = 0
|
|
|
|
for _, _ in pairs(active_mods) do
|
|
|
|
i = i + 1
|
|
|
|
if i > 1 then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2019-02-20 11:43:29 +01:00
|
|
|
return ServerCommands
|