mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-17 20:58:13 +02:00
commit
c7fd81da94
@ -1,9 +1,11 @@
|
||||
[ic]
|
||||
transfer_car=Transfer Car
|
||||
car_settings=Car Settings
|
||||
allow_anyone=Allow everyone to enter: ON
|
||||
allow_anyone=Allow everyone to enter: On
|
||||
auto_upgrade=Auto Upgrade Vehicle: On
|
||||
add_player=Add Player
|
||||
off=Off
|
||||
on=On
|
||||
select_player=Select Player
|
||||
discard=Discard
|
||||
save=Save
|
||||
|
@ -1161,20 +1161,32 @@ local function show_mvps(player)
|
||||
local sent_to_discord = WPT.get('sent_to_discord')
|
||||
|
||||
if not sent_to_discord then
|
||||
local result = {}
|
||||
table.insert(result, 'HIGHEST WAVE: \\n')
|
||||
table.insert(result, wave_defense_table.wave_number .. '\\n')
|
||||
table.insert(result, '\\n')
|
||||
table.insert(result, 'MVP Fighter: \\n')
|
||||
table.insert(result, mvp.killscore.name .. ' with a killing score of ' .. mvp.killscore.score .. ' kills!\\n')
|
||||
table.insert(result, '\\n')
|
||||
table.insert(result, 'MVP Builder: \\n')
|
||||
table.insert(result, mvp.built_entities.name .. ' built ' .. mvp.built_entities.score .. ' things!\\n')
|
||||
table.insert(result, '\\n')
|
||||
table.insert(result, 'MVP Miners: \\n')
|
||||
table.insert(result, mvp.mined_entities.name .. ' mined a total of ' .. mvp.mined_entities.score .. ' entities!\\n')
|
||||
local message = table.concat(result)
|
||||
Server.to_discord_embed(message)
|
||||
local message = {
|
||||
title = 'Game over',
|
||||
description = 'Player statistics is below',
|
||||
color = 'failure',
|
||||
field1 = {
|
||||
text1 = 'Highest Wave:',
|
||||
text2 = wave_defense_table.wave_number,
|
||||
inline = 'false'
|
||||
},
|
||||
field2 = {
|
||||
text1 = 'MVP Fighter:',
|
||||
text2 = mvp.killscore.name .. ' with a killing score of ' .. mvp.killscore.score .. ' kills!',
|
||||
inline = 'false'
|
||||
},
|
||||
field3 = {
|
||||
text1 = 'MVP Builder:',
|
||||
text2 = mvp.built_entities.name .. ' built ' .. mvp.built_entities.score .. ' things!',
|
||||
inline = 'false'
|
||||
},
|
||||
field4 = {
|
||||
text1 = 'MVP Miners:',
|
||||
text2 = mvp.mined_entities.name .. ' mined a total of ' .. mvp.mined_entities.score .. ' entities!',
|
||||
inline = 'false'
|
||||
}
|
||||
}
|
||||
Server.to_discord_embed_parsed(message)
|
||||
local wave = WD.get_wave()
|
||||
local threat = WD.get('threat')
|
||||
local collapse_speed = Collapse.get_speed()
|
||||
@ -1187,26 +1199,72 @@ local function show_mvps(player)
|
||||
local tier = WPT.get('pickaxe_tier')
|
||||
local pick_tier = pickaxe_tiers[tier]
|
||||
|
||||
local server_name = Server.check_server_name('Mtn Fortress')
|
||||
local server_name_matches = Server.check_server_name('Mtn Fortress')
|
||||
if WPT.get('prestige_system_enabled') then
|
||||
RPG_Progression.save_all_players()
|
||||
end
|
||||
if server_name then
|
||||
local date = Server.get_start_time()
|
||||
game.server_save('Final_Mtn_Fortress_v3_' .. tostring(date))
|
||||
--ignore
|
||||
local text = '**Statistics!**\\n\\n' ..
|
||||
'Time played: ' .. time_played ..
|
||||
'\\n' .. 'Game Difficulty: ' .. diff.name ..
|
||||
'\\n' .. 'Highest wave: ' .. format_number(wave, true) ..
|
||||
'\\n' .. 'Total connected players: ' .. total_players ..
|
||||
'\\n' .. 'Threat: ' .. format_number(threat, true) ..
|
||||
'\\n' .. 'Pickaxe Upgrade: ' .. pick_tier .. ' (' .. tier ..
|
||||
')\\n' .. 'Collapse Speed: ' .. collapse_speed ..
|
||||
'\\n' .. 'Collapse Amount: ' .. collapse_amount .. '\\n'
|
||||
Server.to_discord_named_embed(send_ping_to_channel, text)
|
||||
WPT.set('sent_to_discord', true)
|
||||
local date = Server.get_start_time()
|
||||
game.server_save('Final_Mtn_Fortress_v3_' .. tostring(date))
|
||||
local text = {
|
||||
title = 'Game over <:helper:627426785918713877>',
|
||||
description = 'Game statistics from the game is below',
|
||||
color = 'failure',
|
||||
field1 = {
|
||||
text1 = 'Time played:',
|
||||
text2 = time_played,
|
||||
inline = 'true'
|
||||
},
|
||||
field2 = {
|
||||
text1 = 'Game Difficulty:',
|
||||
text2 = diff.name,
|
||||
inline = 'true',
|
||||
emptyField = 'true',
|
||||
emptyInline = 'true'
|
||||
},
|
||||
field3 = {
|
||||
text1 = 'Highest wave:',
|
||||
text2 = format_number(wave, true),
|
||||
inline = 'true'
|
||||
},
|
||||
field4 = {
|
||||
text1 = 'Total connected players:',
|
||||
text2 = total_players,
|
||||
inline = 'true',
|
||||
emptyField = 'true',
|
||||
emptyInline = 'true'
|
||||
},
|
||||
field5 = {
|
||||
text1 = 'Threat:',
|
||||
text2 = format_number(threat, true),
|
||||
inline = 'true'
|
||||
},
|
||||
field6 = {
|
||||
text1 = 'Pickaxe Upgrade:',
|
||||
text2 = pick_tier .. ' (' .. tier .. ')',
|
||||
inline = 'true',
|
||||
emptyField = 'true',
|
||||
emptyInline = 'true'
|
||||
},
|
||||
field7 = {
|
||||
text1 = 'Collapse Speed:',
|
||||
text2 = collapse_speed,
|
||||
inline = 'true'
|
||||
},
|
||||
field8 = {
|
||||
text1 = 'Collapse Amount:',
|
||||
text2 = collapse_amount,
|
||||
inline = 'true',
|
||||
emptyField = 'true',
|
||||
emptyInline = 'true'
|
||||
}
|
||||
}
|
||||
if server_name_matches then
|
||||
Server.to_discord_named_parsed_embed(send_ping_to_channel, text)
|
||||
else
|
||||
Server.to_discord_embed_parsed(text)
|
||||
end
|
||||
|
||||
WPT.set('sent_to_discord', true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -40,7 +40,8 @@ local function get_trusted_system(player)
|
||||
players = {
|
||||
[player.name] = true
|
||||
},
|
||||
allow_anyone = 'right'
|
||||
allow_anyone = 'right',
|
||||
auto_upgrade = 'left'
|
||||
}
|
||||
end
|
||||
|
||||
@ -1051,10 +1052,15 @@ function Public.create_car(event)
|
||||
return player.print('Multi-surface is not supported at the moment.', Color.warning)
|
||||
end
|
||||
|
||||
local storage = get_trusted_system(player)
|
||||
|
||||
if
|
||||
get_owner_car_name(player) == 'car' and ce.name == 'tank' or get_owner_car_name(player) == 'car' and ce.name == 'spidertron' or
|
||||
get_owner_car_name(player) == 'tank' and ce.name == 'spidertron'
|
||||
then
|
||||
if storage.auto_upgrade and storage.auto_upgrade == 'right' then
|
||||
return
|
||||
end
|
||||
upgrade_surface(player, ce)
|
||||
render_owner_text(renders, player, ce)
|
||||
player.print('Your car-surface has been upgraded!', Color.success)
|
||||
|
@ -26,6 +26,7 @@ local main_toolbar_name = Gui.uid_name()
|
||||
local add_player_name = Gui.uid_name()
|
||||
local transfer_car_name = Gui.uid_name()
|
||||
local allow_anyone_to_enter_name = Gui.uid_name()
|
||||
local auto_upgrade_name = Gui.uid_name()
|
||||
local kick_player_name = Gui.uid_name()
|
||||
local destroy_surface_name = Gui.uid_name()
|
||||
|
||||
@ -48,7 +49,8 @@ local function create_player_table(player)
|
||||
players = {
|
||||
[player.name] = true
|
||||
},
|
||||
allow_anyone = 'right'
|
||||
allow_anyone = 'right',
|
||||
auto_upgrade = 'left'
|
||||
}
|
||||
end
|
||||
return trust_system[player.index]
|
||||
@ -376,6 +378,17 @@ local function draw_main_frame(player)
|
||||
right_label_caption = ({'ic.off'})
|
||||
}
|
||||
)
|
||||
local auto_upgrade =
|
||||
inside_table.add(
|
||||
{
|
||||
type = 'switch',
|
||||
name = auto_upgrade_name,
|
||||
switch_state = player_list.auto_upgrade,
|
||||
allow_none_state = false,
|
||||
left_label_caption = ({'ic.auto_upgrade'}),
|
||||
right_label_caption = ({'ic.off'})
|
||||
}
|
||||
)
|
||||
|
||||
local player_table =
|
||||
inside_table.add {
|
||||
@ -429,6 +442,7 @@ local function draw_main_frame(player)
|
||||
transfer_car_frame = transfer_car_frame,
|
||||
destroy_surface_frame = destroy_surface_frame,
|
||||
allow_anyone_to_enter = allow_anyone_to_enter,
|
||||
auto_upgrade = auto_upgrade,
|
||||
player = player
|
||||
}
|
||||
draw_players(data)
|
||||
@ -596,6 +610,35 @@ Gui.on_click(
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
auto_upgrade_name,
|
||||
function(event)
|
||||
local player = event.player
|
||||
if not player or not player.valid or not player.character then
|
||||
return
|
||||
end
|
||||
|
||||
local player_list = create_player_table(player)
|
||||
|
||||
local screen = player.gui.screen
|
||||
local frame = screen[main_frame_name]
|
||||
|
||||
if frame and frame.valid then
|
||||
if player_list.auto_upgrade == 'right' then
|
||||
player_list.auto_upgrade = 'left'
|
||||
player.print('[IC] Auto upgrade is now enabled!', Color.success)
|
||||
else
|
||||
player_list.auto_upgrade = 'right'
|
||||
player.print('[IC] Auto upgrade is now disabled!', Color.warning)
|
||||
end
|
||||
|
||||
if player.gui.screen[main_frame_name] then
|
||||
toggle(player, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
save_add_player_button_name,
|
||||
function(event)
|
||||
|
@ -62,6 +62,7 @@ local discord_jailed_embed_tag = '[DISCORD-JAILED-EMBED]'
|
||||
local discord_unjailed_tag = '[DISCORD-UNJAILED]'
|
||||
local discord_unjailed_embed_tag = '[DISCORD-UNJAILED-EMBED]'
|
||||
local discord_admin_raw_tag = '[DISCORD-ADMIN-RAW]'
|
||||
local discord_embed_parsed_tag = '[DISCORD-EMBED-PARSED]'
|
||||
local discord_embed_tag = '[DISCORD-EMBED]'
|
||||
local discord_embed_raw_tag = '[DISCORD-EMBED-RAW]'
|
||||
local discord_admin_embed_tag = '[DISCORD-ADMIN-EMBED]'
|
||||
@ -70,6 +71,7 @@ local discord_named_tag = '[DISCORD-NAMED]'
|
||||
local discord_named_raw_tag = '[DISCORD-NAMED-RAW]'
|
||||
local discord_named_bold_tag = '[DISCORD-NAMED-BOLD]'
|
||||
local discord_named_embed_tag = '[DISCORD-NAMED-EMBED]'
|
||||
local discord_named_embed_parsed_tag = '[DISCORD-NAMED-EMBED-PARSED]'
|
||||
local discord_named_embed_raw_tag = '[DISCORD-NAMED-EMBED-RAW]'
|
||||
local start_scenario_tag = '[START-SCENARIO]'
|
||||
local stop_scenario_tag = '[STOP-SCENARIO]'
|
||||
@ -103,6 +105,27 @@ local function assert_non_empty_string_and_no_spaces(str, argument_name)
|
||||
end
|
||||
end
|
||||
|
||||
local function getOnlineAdmins()
|
||||
local online = game.connected_players
|
||||
local i = 0
|
||||
for _, p in pairs(online) do
|
||||
if p.admin then
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
return i
|
||||
end
|
||||
|
||||
local function build_embed_data()
|
||||
local d = {
|
||||
time = Public.format_time(game.ticks_played),
|
||||
onlinePlayers = #game.connected_players,
|
||||
totalPlayers = #game.players,
|
||||
onlineAdmins = getOnlineAdmins()
|
||||
}
|
||||
return d
|
||||
end
|
||||
|
||||
--- The event id for the on_server_started event.
|
||||
-- The event is raised whenever the server goes from the starting state to the running state.
|
||||
-- It provides a good opportunity to request data from the web server.
|
||||
@ -181,6 +204,28 @@ function Public.to_discord_named_embed(channel_name, message)
|
||||
raw_print(concat({discord_named_embed_tag, channel_name, ' ', message}))
|
||||
end
|
||||
|
||||
--- Sends an embed message that is parsed to the named discord channel. The message is sanitized of markdown server side.
|
||||
-- @param message<string> the content of the embed.
|
||||
function Public.to_discord_named_parsed_embed(channel_name, message)
|
||||
assert_non_empty_string_and_no_spaces(channel_name, 'channel_name')
|
||||
local table_to_json = game.table_to_json
|
||||
|
||||
if not type(message) == 'table' then
|
||||
return
|
||||
end
|
||||
|
||||
if not message.title then
|
||||
return
|
||||
end
|
||||
if not message.description then
|
||||
return
|
||||
end
|
||||
|
||||
message.channelName = channel_name
|
||||
|
||||
raw_print(discord_named_embed_parsed_tag, table_to_json(message))
|
||||
end
|
||||
|
||||
--- Sends an embed message to the named discord channel. The message is not sanitized of markdown.
|
||||
-- @param message<string> the content of the embed.
|
||||
function Public.to_discord_named_embed_raw(channel_name, message)
|
||||
@ -252,6 +297,23 @@ function Public.to_admin_raw(message, locale)
|
||||
end
|
||||
end
|
||||
|
||||
--- Sends a embed message to the linked discord channel. The message is sanitized/parsed of markdown server side.
|
||||
-- @param message<table> the content of the embed.
|
||||
function Public.to_discord_embed_parsed(message)
|
||||
local table_to_json = game.table_to_json
|
||||
if not type(message) == 'table' then
|
||||
return
|
||||
end
|
||||
|
||||
if not message.title then
|
||||
return
|
||||
end
|
||||
if not message.description then
|
||||
return
|
||||
end
|
||||
raw_print(discord_embed_parsed_tag .. table_to_json(message))
|
||||
end
|
||||
|
||||
--- Sends a embed message to the linked discord channel. The message is sanitized of markdown server side.
|
||||
-- @param message<string> the content of the embed.
|
||||
-- @param locale<boolean> if the message should be handled as localized.
|
||||
@ -501,27 +563,6 @@ local function validate_arguments(data_set, key, callback_token)
|
||||
end
|
||||
end
|
||||
|
||||
local function getOnlineAdmins()
|
||||
local online = game.connected_players
|
||||
local i = 0
|
||||
for _, p in pairs(online) do
|
||||
if p.admin then
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
return i
|
||||
end
|
||||
|
||||
local function build_embed_data()
|
||||
local d = {
|
||||
time = Public.format_time(game.ticks_played),
|
||||
onlinePlayers = #game.connected_players,
|
||||
totalPlayers = #game.players,
|
||||
onlineAdmins = getOnlineAdmins()
|
||||
}
|
||||
return d
|
||||
end
|
||||
|
||||
local function send_try_get_data(data_set, key, callback_token)
|
||||
data_set = double_escape(data_set)
|
||||
key = double_escape(key)
|
||||
|
Loading…
x
Reference in New Issue
Block a user