1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-13 13:49:33 +02:00

Merge pull request #110 from Masamune0/master

Added mutagen log
This commit is contained in:
MewMew 2020-01-04 20:30:29 +01:00 committed by GitHub
commit a4d72a1f29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 125 additions and 1 deletions

View File

@ -70,6 +70,60 @@ local function print_feeding_msg(player, food, flask_amount)
end
end
function add_stats(player, food, flask_amount,biter_force_name,evo_before_science_feed,threat_before_science_feed)
local colored_player_name = table.concat({"[color=", player.color.r * 0.6 + 0.35, ",", player.color.g * 0.6 + 0.35, ",", player.color.b * 0.6 + 0.35, "]", player.name, "[/color]"})
local formatted_food = table.concat({"[color=", food_values[food].color, "][/color]", "[img=item/", food, "]"})
local formatted_amount = table.concat({"[font=heading-1][color=255,255,255]" .. flask_amount .. "[/color][/font]"})
local n = bb_config.north_side_team_name
local s = bb_config.south_side_team_name
if global.tm_custom_name["north"] then n = global.tm_custom_name["north"] end
if global.tm_custom_name["south"] then s = global.tm_custom_name["south"] end
local team_strings = {
["north"] = table.concat({"[color=120, 120, 255]", n, "[/color]"}),
["south"] = table.concat({"[color=255, 65, 65]", s, "[/color]"})
}
if flask_amount > 1 then
local feed_time = math.round(game.tick,0)
local feed_time_mins = math.round(game.tick / (60*60),0)
local minute_unit = ""
if feed_time_mins <= 1 then
minute_unit = "min"
else
minute_unit = "mins"
end
local shown_feed_time_hours = ""
local shown_feed_time_mins = ""
shown_feed_time_mins = feed_time_mins .. minute_unit
local formatted_feed_time = shown_feed_time_hours .. shown_feed_time_mins
evo_before_science_feed = math.round(evo_before_science_feed*100,1)
threat_before_science_feed = math.round(threat_before_science_feed,0)
local formatted_evo_after_feed = math.round(global.bb_evolution[biter_force_name]*100,1)
local formatted_threat_after_feed = math.round(global.bb_threat[biter_force_name],0)
local evo_jump = table.concat({evo_before_science_feed .. " to " .. formatted_evo_after_feed})
local threat_jump = table.concat({threat_before_science_feed .. " to ".. formatted_threat_after_feed})
local evo_jump_difference = math.round(formatted_evo_after_feed - evo_before_science_feed,1)
local threat_jump_difference = math.round(formatted_threat_after_feed - threat_before_science_feed,0)
local line_log_stats_to_add = table.concat({ formatted_amount .. " " .. formatted_food .. " by " .. colored_player_name .. " to " .. team_strings[get_enemy_team_of(player.force.name)]})
if global.science_logs_text then
table.insert(global.science_logs_date, formatted_feed_time)
table.insert(global.science_logs_text, line_log_stats_to_add)
table.insert(global.science_logs_evo_jump, evo_jump)
table.insert(global.science_logs_evo_jump_difference, evo_jump_difference)
table.insert(global.science_logs_threat, threat_jump)
table.insert(global.science_logs_threat_jump_difference, threat_jump_difference)
else
global.science_logs_date = { formatted_feed_time }
global.science_logs_text = { line_log_stats_to_add }
global.science_logs_evo_jump = { evo_jump }
global.science_logs_evo_jump_difference = { evo_jump_difference }
global.science_logs_threat = { threat_jump }
global.science_logs_threat_jump_difference = { threat_jump_difference }
end
end
end
function set_evo_and_threat(flask_amount, food, biter_force_name)
local decimals = 9
local math_round = math.round
@ -118,9 +172,13 @@ local function feed_biters(player, food)
i.remove({name = food, count = flask_amount})
print_feeding_msg(player, food, flask_amount)
print_feeding_msg(player, food, flask_amount)
evolution_before_feed = global.bb_evolution[biter_force_name]
threat_before_feed = global.bb_threat[biter_force_name]
set_evo_and_threat(flask_amount, food, biter_force_name)
add_stats(player, food, flask_amount ,biter_force_name, evolution_before_feed, threat_before_feed)
end
return feed_biters

View File

@ -15,6 +15,7 @@ local Team_manager = require "maps.biter_battles_v2.team_manager"
require "on_tick_schedule"
require "maps.biter_battles_v2.map_settings_tab"
require "maps.biter_battles_v2.sciencelogs_tab"
require "modules.spawners_contain_biters"
require "modules.mineable_wreckage_yields_scrap"

View File

@ -0,0 +1,65 @@
-- science logs tab --
local Tabs = require 'comfy_panel.main'
local function add_science_logs(element)
local t = element.add { type = "table", name = "science_logs_header_table", column_count = 4 }
local column_widths = {tonumber(90), tonumber(340), tonumber(170), tonumber(190)}
local headers = {
[1] = "Time",
[2] = "Details",
[3] = "Evo jump",
[4] = "Threat jump",
}
for _, w in ipairs(column_widths) do
local label = t.add { type = "label", caption = headers[_] }
label.style.minimal_width = w
label.style.maximal_width = w
label.style.font = "default-bold"
label.style.font_color = { r=0.98, g=0.66, b=0.22 }
if _ == 1 then
label.style.horizontal_align = "center"
end
end
-- List management
if global.science_logs_date then
local science_scrollpanel = element.add { type = "scroll-pane", name = "scroll_pane", direction = "vertical", horizontal_scroll_policy = "never", vertical_scroll_policy = "auto"}
science_scrollpanel.style.maximal_height = 530
for i = 1, #global.science_logs_date, 1 do
science_panel_table = science_scrollpanel.add { type = "table", column_count = 4 }
local label = science_panel_table.add { type = "label", name = "science_logs_date" .. i, caption = global.science_logs_date[i] }
label.style.minimal_width = column_widths[1]
label.style.maximal_width = column_widths[1]
label.style.horizontal_align = "center"
local label = science_panel_table.add { type = "label", name = "science_logs_text" .. i, caption = global.science_logs_text[i] }
label.style.minimal_width = column_widths[2]
label.style.maximal_width = column_widths[2]
local label = science_panel_table.add { type = "label", name = "science_logs_evo_jump" .. i, caption = global.science_logs_evo_jump[i].." [color=200,200,200](+"..global.science_logs_evo_jump_difference[i]..")[/color]" }
label.style.minimal_width = column_widths[3]
label.style.maximal_width = column_widths[3]
local label = science_panel_table.add { type = "label", name = "science_logs_threat" .. i, caption = global.science_logs_threat[i].." [color=200,200,200](+"..global.science_logs_threat_jump_difference[i]..")[/color]" }
label.style.minimal_width = column_widths[4]
label.style.maximal_width = column_widths[4]
science_scrollpanel.add({type = "line"})
end
end
end
local build_config_gui = (function (player, frame)
frame.clear()
add_science_logs(frame)
end)
local function on_gui_click(event)
if not event.element then return end
if not event.element.valid then return end
end
comfy_panel_tabs["MutagenLog"] = build_config_gui
local event = require 'utils.event'
event.add(defines.events.on_gui_click, on_gui_click)