1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-26 22:56:43 +02:00

Mtn: fix broken discord notifications

This commit is contained in:
Gerkiz 2024-10-26 01:34:21 +02:00
parent de6fb86efb
commit ab53e522b1
8 changed files with 39 additions and 39 deletions

View File

@ -6,7 +6,6 @@ local WD = require 'modules.wave_defense.table'
local Discord = require 'utils.discord_handler'
local Commands = require 'utils.commands'
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
local scenario_name = 'Mtn Fortress'
local gather_time_token =
Task.register(
@ -38,7 +37,7 @@ Commands.new('scenario', 'Usable only for admins - controls the scenario!')
this.reset_are_you_sure = nil
this.restart = false
this.soft_reset = true
Discord.send_notification_raw(scenario_name, player.name .. ' has enabled soft-reset!')
Discord.send_notification_raw(Public.discord_name, player.name .. ' has enabled soft-reset!')
player.print('Soft-reset is enabled.')
else
this.reset_are_you_sure = nil
@ -47,20 +46,20 @@ Commands.new('scenario', 'Usable only for admins - controls the scenario!')
if this.shutdown then
this.shutdown = false
end
Discord.send_notification_raw(scenario_name, player.name .. ' has disabled soft-reset! Restart will happen from scenario.')
Discord.send_notification_raw(Public.discord_name, player.name .. ' has disabled soft-reset! Restart will happen from scenario.')
player.print('Soft-reset is disabled! Server will restart from scenario to load new changes.')
end
elseif action == 'restartnow' then
this.reset_are_you_sure = nil
Server.start_scenario('Mountain_Fortress_v3')
Discord.send_notification_raw(scenario_name, player.name .. ' restarted the scenario.')
Discord.send_notification_raw(Public.discord_name, player.name .. ' restarted the scenario.')
player.print('Restarted the scenario.')
elseif action == 'shutdown' then
if this.shutdown then
this.reset_are_you_sure = nil
this.shutdown = false
this.soft_reset = true
Discord.send_notification_raw(scenario_name,
Discord.send_notification_raw(Public.discord_name,
player.name .. ' has enabled soft-reset. Server will NOT shutdown!')
player.print('Soft-reset is enabled.')
@ -72,7 +71,7 @@ Commands.new('scenario', 'Usable only for admins - controls the scenario!')
this.restart = false
end
Discord.send_notification_raw(scenario_name, player.name .. ' has disabled soft-reset. Server will shutdown!')
Discord.send_notification_raw(Public.discord_name, player.name .. ' has disabled soft-reset. Server will shutdown!')
player.print('Soft-reset is disabled! Server will shutdown.')
end
elseif action == 'reset' then
@ -80,10 +79,10 @@ Commands.new('scenario', 'Usable only for admins - controls the scenario!')
if player and player.valid then
game.print(mapkeeper .. ' ' .. player.name .. ', has reset the game!',
{ r = 0.98, g = 0.66, b = 0.22 })
Discord.send_notification_raw(scenario_name, player.name .. ' has reset the game!')
Discord.send_notification_raw(Public.discord_name, player.name .. ' has reset the game!')
else
game.print(mapkeeper .. ' server, has reset the game!', { r = 0.98, g = 0.66, b = 0.22 })
Discord.send_notification_raw(scenario_name, 'Server has reset the game!')
Discord.send_notification_raw(Public.discord_name, 'Server has reset the game!')
end
Public.reset_map()
player.print('Game has been reset!')
@ -98,7 +97,7 @@ Commands.new('mtn_set_queue_speed', 'Usable only for admins - sets the queue spe
:callback(
function (player, speed)
Task.set_queue_speed(speed)
Discord.send_notification_raw(scenario_name, player.name .. ' set the queue speed to: ' .. speed)
Discord.send_notification_raw(Public.discord_name, player.name .. ' set the queue speed to: ' .. speed)
player.print('Queue speed set to: ' .. speed)
end
)
@ -108,7 +107,7 @@ Commands.new('mtn_complete_quests', 'Usable only for admins - sets the queue spe
:require_validation()
:callback(
function (player)
Discord.send_notification_raw(scenario_name, player.name .. ' completed all the quest via command.')
Discord.send_notification_raw(Public.discord_name, player.name .. ' completed all the quest via command.')
local stateful = Public.get_stateful()
stateful.objectives_completed_count = 6
Task.set_timeout_in_ticks(50, gather_time_token, {})
@ -124,7 +123,7 @@ Commands.new('mtn_reverse_map', 'Usable only for admins - reverses the map!')
function (player)
local reversed = Public.get_stateful_settings('reversed')
Public.set_stateful_settings('reversed', not reversed)
Discord.send_notification_raw(scenario_name, player.name .. ' reversed the map.')
Discord.send_notification_raw(Public.discord_name, player.name .. ' reversed the map.')
Public.reset_map()
game.print(mapkeeper .. player.name .. ', has reverse the map and reset the game!',
{ r = 0.98, g = 0.66, b = 0.22 })
@ -140,12 +139,12 @@ Commands.new('mtn_disable_biters', 'Usable only for admins - disables wave defen
local tbl = WD.get()
if not tbl.game_lost then
Discord.send_notification_raw(scenario_name, player.name .. ' disabled the wave defense module.')
Discord.send_notification_raw(Public.discord_name, player.name .. ' disabled the wave defense module.')
game.print(mapkeeper .. ' ' .. player.name .. ', has disabled the wave_defense module!',
{ r = 0.98, g = 0.66, b = 0.22 })
tbl.game_lost = true
else
Discord.send_notification_raw(scenario_name, player.name .. ' enabled the wave defense module.')
Discord.send_notification_raw(Public.discord_name, player.name .. ' enabled the wave defense module.')
game.print(mapkeeper .. ' ' .. player.name .. ', has enabled the wave_defense module!',
{ r = 0.98, g = 0.66, b = 0.22 })
tbl.game_lost = false
@ -162,12 +161,12 @@ Commands.new('mtn_toggle_orbital_strikes',
local this = Public.get()
if this.orbital_strikes.enabled then
Discord.send_notification_raw(scenario_name, player.name .. ' disabled the orbital strike module.')
Discord.send_notification_raw(Public.discord_name, player.name .. ' disabled the orbital strike module.')
game.print(mapkeeper .. ' ' .. player.name .. ', has disabled the orbital_strikes module!',
{ r = 0.98, g = 0.66, b = 0.22 })
this.orbital_strikes.enabled = false
else
Discord.send_notification_raw(scenario_name, player.name .. ' enabled the orbital strike module.')
Discord.send_notification_raw(Public.discord_name, player.name .. ' enabled the orbital strike module.')
game.print(mapkeeper .. ' ' .. player.name .. ', has enabled the orbital_strikes module!',
{ r = 0.98, g = 0.66, b = 0.22 })
this.orbital_strikes.enabled = true
@ -191,11 +190,11 @@ Commands.new('mtn_disable_collapse', 'Usable only for admins - toggles the colla
function (player)
if not Collapse.has_collapse_started() then
Collapse.start_now(true, false)
Discord.send_notification_raw(scenario_name, player.name .. ' has enabled collapse.')
Discord.send_notification_raw(Public.discord_name, player.name .. ' has enabled collapse.')
game.print(mapkeeper .. ' ' .. player.name .. ', has enabled collapse!', { r = 0.98, g = 0.66, b = 0.22 })
else
Collapse.start_now(false, true)
Discord.send_notification_raw(scenario_name, player.name .. ' has disabled collapse.')
Discord.send_notification_raw(Public.discord_name, player.name .. ' has disabled collapse.')
game.print(mapkeeper .. ' ' .. player.name .. ', has disabled collapse!',
{ r = 0.98, g = 0.66, b = 0.22 })
end

View File

@ -1202,7 +1202,7 @@ local function show_mvps(player)
miners_label_text.style.font_color = { r = 0.33, g = 0.66, b = 0.9 }
local sent_to_discord = Public.get('sent_to_discord')
local server_name_matches = Server.check_server_name(scenario_name)
local server_name_matches = Server.check_server_name(Public.discord_name)
if not sent_to_discord and server_name_matches then
local message = {

View File

@ -33,7 +33,7 @@ local trust_player_name = Gui.uid_name()
local drive_player_name = Gui.uid_name()
local kick_player_name = Gui.uid_name()
local destroy_surface_name = Gui.uid_name()
local scenario_name = 'Mtn Fortress'
local discord_name = 'Mtn Fortress'
local add_toolbar
local remove_toolbar
@ -951,7 +951,7 @@ Gui.on_click(
local suc, count = Functions.kill_car_but_save_surface(entity)
if suc then
game.print('[IC] ' .. player.name .. ' has destroyed their surface!', Color.warning)
Discord.send_notification_raw(scenario_name,
Discord.send_notification_raw(discord_name,
player.name ..
' deleted their vehicle surface at x = ' .. position.x .. ' y = ' .. position.y .. '.')
else

View File

@ -46,7 +46,6 @@ local Beam = require 'modules.render_beam'
-- Use these settings for live
local send_ping_to_channel = Discord.channel_names.mtn_channel
local role_to_mention = Discord.role_mentions.mtn_fortress
local scenario_name = Public.scenario_name
-- Use these settings for testing
-- bot-lounge
-- local send_ping_to_channel = Discord.channel_names.bot_quarters
@ -117,7 +116,7 @@ end
local announce_new_map =
Task.register(
function ()
local server_name = Server.check_server_name(scenario_name)
local server_name = Server.check_server_name(Public.discord_name)
if server_name then
Server.to_discord_named_raw(send_ping_to_channel, role_to_mention .. ' ** Mtn Fortress was just reset! **')
end
@ -359,12 +358,13 @@ function Public.reset_map()
WD.disable_spawning_biters(true)
end
if not this.disable_startup_notification then
Task.set_timeout_in_ticks(25, announce_new_map)
end
Public.equip_players(nil, false)
Task.set_timeout_in_ticks(100, partial_reset_token, {})
if not this.disable_startup_notification then
Task.set_timeout_in_ticks(125, announce_new_map)
end
end
local is_locomotive_valid = function ()

View File

@ -12,7 +12,6 @@ local score_key = 'mtn_v3'
local score_key_dev = 'mtn_v3_dev'
local set_data = Server.set_data
local try_get_data = Server.try_get_data
local scenario_name = Public.scenario_name
local insert = table.insert
@ -88,7 +87,7 @@ function Public.get_season_scores()
if not secs then
return
else
local server_name_matches = Server.check_server_name(scenario_name)
local server_name_matches = Server.check_server_name(Public.discord_name)
if server_name_matches then
try_get_data(score_dataset, score_key, get_scores)
else
@ -103,7 +102,7 @@ function Public.set_season_scores()
if not secs then
return
else
local server_name_matches = Server.check_server_name(scenario_name)
local server_name_matches = Server.check_server_name(Public.discord_name)
if server_name_matches then
write_additional_stats(score_key)
else

View File

@ -83,7 +83,7 @@ local function notify_won_to_discord(buff)
if not buff then
return error('Buff is required when sending message to discord.', 2)
end
local server_name_matches = Server.check_server_name(scenario_name)
local server_name_matches = Server.check_server_name(Public.discord_name)
local stateful = Public.get_stateful()

View File

@ -73,7 +73,7 @@ local function upperCase(str)
end
local function notify_season_over_to_discord()
local server_name_matches = Server.check_server_name(scenario_name)
local server_name_matches = Server.check_server_name(Public.discord_name)
local stateful = Public.get_stateful()
@ -1261,7 +1261,7 @@ local function apply_startup_settings(settings)
current_date = round(Utils.convert_date(current_date.year, current_date.month, current_date.day))
local server_name_matches = Server.check_server_name(scenario_name)
local server_name_matches = Server.check_server_name(Public.discord_name)
settings = settings or {}
local stored_date = this.current_date
@ -1314,7 +1314,7 @@ end
local apply_settings_token =
Task.register(
function (data)
local server_name_matches = Server.check_server_name(scenario_name)
local server_name_matches = Server.check_server_name(Public.discord_name)
local settings = data and data.value or nil
local current_time = Server.get_current_time()
if not current_time then
@ -1420,7 +1420,7 @@ function Public.save_settings()
current_date = this.current_date
}
local server_name_matches = Server.check_server_name(scenario_name)
local server_name_matches = Server.check_server_name(Public.discord_name)
if server_name_matches then
Server.set_data(dataset, dataset_key, settings)
else
@ -1439,7 +1439,7 @@ function Public.save_settings_before_reset()
current_date = this.current_date
}
local server_name_matches = Server.check_server_name(scenario_name)
local server_name_matches = Server.check_server_name(Public.discord_name)
if server_name_matches then
Server.set_data(dataset, dataset_key_previous, settings)
else
@ -1851,7 +1851,7 @@ function Public.stateful_on_server_started()
return
end
local server_name_matches = Server.check_server_name(scenario_name)
local server_name_matches = Server.check_server_name(Public.discord_name)
this.settings_applied = true
@ -1870,7 +1870,7 @@ Event.add(
return
end
local server_name_matches = Server.check_server_name(scenario_name)
local server_name_matches = Server.check_server_name(Public.discord_name)
this.settings_applied = true

View File

@ -44,6 +44,8 @@ Public.events = {
local scenario_name = 'nauvis'
Public.scenario_name = scenario_name
local discord_name = 'Mtn Fortress'
Public.discord_name = discord_name
Global.register(
this,
@ -412,7 +414,7 @@ function Public.remove(key, sub_key)
end
function Public.save_stateful_settings()
local server_name_matches = Server.check_server_name(scenario_name)
local server_name_matches = Server.check_server_name(Public.discord_name)
if server_name_matches then
Server.set_data(dataset, dataset_key, stateful_settings)
@ -424,7 +426,7 @@ end
local apply_settings_token =
Task.register(
function (data)
local server_name_matches = Server.check_server_name(scenario_name)
local server_name_matches = Server.check_server_name(Public.discord_name)
local settings = data and data.value or nil
if not settings then
@ -449,7 +451,7 @@ Event.add(
local start_data = Server.get_start_data()
if not start_data.initialized then
local server_name_matches = Server.check_server_name(scenario_name)
local server_name_matches = Server.check_server_name(Public.discord_name)
if server_name_matches then
Server.try_get_data(dataset, dataset_key, apply_settings_token)