1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-11-23 22:22:34 +02:00

Various changes

This commit is contained in:
Gerkiz
2025-05-10 12:43:38 +02:00
parent 1327fc711d
commit 613bd5fc9c
26 changed files with 1077 additions and 793 deletions

View File

@@ -257,6 +257,6 @@ Tabs.on_click(
module_name,
function (event)
local player = event.player
Tabs.reload_active_tab(player)
Tabs.reload_active_tab(player, nil, 'MutagenLog')
end
)

View File

@@ -237,7 +237,7 @@ Gui.on_click(
module_name,
function(event)
local player = event.player
Gui.reload_active_tab(player)
Gui.reload_active_tab(player, nil, 'ChronoTrain')
end
)

View File

@@ -144,6 +144,7 @@ local random = math.random
local floor = math.floor
local blacklist = {
['atomic-bomb'] = true,
['cargo-wagon'] = true,
['locomotive'] = true,
['artillery-wagon'] = true,

View File

@@ -19,7 +19,8 @@ local function draw_charging_gui(player, activate_custom_buttons)
type = 'sprite-button',
name = charging_station_name,
sprite = 'item/battery-mk2-equipment',
tooltip = {
tooltip =
{
'modules.charging_station_tooltip'
},
style = Gui.button_style
@@ -36,7 +37,7 @@ local function draw_charging_gui(player, activate_custom_buttons)
end
local function discharge_accumulators(surface, position, force, power_needs)
local accumulators = surface.find_entities_filtered { name = 'accumulator', force = force, position = position, radius = 13 }
local accumulators = surface.find_entities_filtered { type = 'accumulator', force = force, position = position, radius = 13 }
local power_drained = 0
power_needs = power_needs * 1
for _, accu in pairs(accumulators) do
@@ -59,6 +60,7 @@ local function discharge_accumulators(surface, position, force, power_needs)
end
local function charge(player)
local warn = module_name .. 'No valid armor to charge was found.'
if not player.character then
return player.print(module_name .. 'It seems that you are not in the realm of living.', { color = Color.warning })
end
@@ -67,15 +69,15 @@ local function charge(player)
end
local armor_inventory = player.get_inventory(defines.inventory.character_armor)
if not armor_inventory.valid then
return player.print(module_name .. 'No valid armor to charge was found.', { color = Color.warning })
return player.print(warn, { color = Color.warning })
end
local armor = armor_inventory[1]
if not armor.valid_for_read then
return player.print(module_name .. 'No valid armor to charge was found.', { color = Color.warning })
return player.print(warn, { color = Color.warning })
end
local grid = armor.grid
if not grid or not grid.valid then
return player.print(module_name .. 'No valid armor to charge was found.', { color = Color.warning })
return player.print(warn, { color = Color.warning })
end
local ents = player.physical_surface.find_entities_filtered { name = 'accumulator', force = player.force, position = player.physical_position, radius = 13 }
@@ -115,7 +117,8 @@ local function on_player_joined_game(event)
{
player = player,
element_name = charging_station_name,
tooltip = {
tooltip =
{
'modules.charging_station_tooltip'
},
sprite = 'item/battery-mk2-equipment'

View File

@@ -32,7 +32,8 @@ local is_modded = Public.is_modded
local notice_frame_name = Gui.uid_name()
local close_notice_frame_name = Gui.uid_name()
local this = {
local this =
{
power_sources = { index = 1 },
refill_turrets = { index = 1 },
magic_crafters = { index = 1 },
@@ -41,20 +42,26 @@ local this = {
editor_mode = {},
techs = {},
limit_types = {},
starting_items = {
['pistol'] = {
starting_items =
{
['pistol'] =
{
count = 1
},
['firearm-magazine'] = {
['firearm-magazine'] =
{
count = 16
},
['rail'] = {
['rail'] =
{
count = 16
},
['wood'] = {
['wood'] =
{
count = 16
},
['explosives'] = {
['explosives'] =
{
count = 32
}
}
@@ -68,7 +75,8 @@ local exit_editor_mode_token =
end
)
local random_respawn_messages = {
local random_respawn_messages =
{
'The doctors stitched you up as best they could.',
'Ow! Your right leg hurts.',
'Ow! Your left leg hurts.',
@@ -78,7 +86,8 @@ local random_respawn_messages = {
'Adrenalin is kicking in, but your body is damaged.'
}
local health_values = {
local health_values =
{
'0.35',
'0.40',
'0.45',
@@ -111,7 +120,8 @@ local magic_crafters_per_tick = 3
local magic_fluid_crafters_per_tick = 8
local tile_damage = 50
local artillery_target_entities = {
local artillery_target_entities =
{
'character',
'tank',
'car',
@@ -178,7 +188,8 @@ local function draw_notice_frame(player)
end
local function show_text(msg, pos, surface, player)
surface.create_entity({
surface.create_entity(
{
name = 'compi-speech-bubble',
position = pos,
text = msg,
@@ -367,7 +378,8 @@ local artillery_target_callback =
local d = dx * dx + dy * dy
if d >= 1024 and d <= 441398 then -- 704 in depth~
if entity.name == 'character' then
entity.surface.create_entity {
entity.surface.create_entity
{
name = 'artillery-projectile',
position = position,
target = entity,
@@ -376,7 +388,8 @@ local artillery_target_callback =
}
fired_at_target = true
elseif entity.name ~= 'character' then
entity.surface.create_entity {
entity.surface.create_entity
{
name = 'rocket',
position = position,
target = entity,
@@ -492,7 +505,8 @@ local function do_season_fix()
Public.set(
'current_season',
rendering.draw_text {
rendering.draw_text
{
text = 'Season: ' .. Public.get_stateful('season'),
surface = surface,
target = { -0, 12 },
@@ -872,7 +886,8 @@ local function add_magic_crafter_output(entity, output, distance)
local rate = output.min_rate + output.distance_factor * distance
local fluidbox_index = output.fluidbox_index
local data = {
local data =
{
entity = entity,
last_tick = game.tick,
base_rate = round(rate, 8),
@@ -1288,6 +1303,10 @@ local boost_movement_speed_on_respawn =
end
local rpg_t = RPG.get_value_from_player(player.index)
if not rpg_t then
return
end
if rpg_t.has_boost_on_respawn then
return
end
@@ -1354,7 +1373,8 @@ local function on_player_cursor_stack_changed(event)
local pm = player.permission_group.name
local blacklisted_spawn_items = {
local blacklisted_spawn_items =
{
['cut-paste-tool'] = true,
['spidertron-remote'] = true,
['artillery-targeting-remote'] = true,
@@ -1400,7 +1420,8 @@ function Public.clear_all_chart_tags()
end
function Public.set_xp_yield()
RPG.set_rpg_xp_yield({
RPG.set_rpg_xp_yield(
{
['biter-spawner'] = 64,
['spitter-spawner'] = 64,
['behemoth-biter'] = 64,
@@ -1560,7 +1581,8 @@ function Public.set_unit_raffle()
end
function Public.set_threat_values()
WD.set('threat_values', {
WD.set('threat_values',
{
['biter-spawner'] = 128,
['spitter-spawner'] = 128,
['behemoth-biter'] = 64,
@@ -1720,7 +1742,8 @@ function Public.set_threat_values()
})
local unit_settings = WD.get('unit_settings')
unit_settings.scale_units_by_health = {
unit_settings.scale_units_by_health =
{
['small-biter'] = 1,
['medium-biter'] = 0.75,
['big-biter'] = 0.5,
@@ -1854,7 +1877,8 @@ function Public.set_threat_values()
['mtn-addon-behemoth-fire-spitter-t2'] = 0.25,
['mtn-addon-behemoth-fire-spitter-t3'] = 0.25,
}
unit_settings.scale_worms_by_health = {
unit_settings.scale_worms_by_health =
{
['land-mine'] = 0.5, -- not active as of now
['gun-turret'] = 0.5, -- not active as of now
['flamethrower-turret'] = 0.4, -- not active as of now
@@ -1913,7 +1937,8 @@ function Public.find_void_tiles_and_replace()
local cp = Collapse.get_position()
local rp = Collapse.get_reverse_position()
local area = {
local area =
{
left_top = { x = (-zone_settings.zone_width / 2) + 10, y = rp.y },
right_bottom = { x = (zone_settings.zone_width / 2) - 10, y = cp.y }
}
@@ -1921,7 +1946,8 @@ function Public.find_void_tiles_and_replace()
local adjusted_zones = Public.get('adjusted_zones')
if adjusted_zones.reversed then
area = {
area =
{
left_top = { x = ((zone_settings.zone_width / 2) + 10) * -1, y = cp.y },
right_bottom = { x = math.abs((-zone_settings.zone_width / 2) - 10), y = rp.y },
}
@@ -2097,7 +2123,8 @@ function Public.render_direction(surface, reversed)
Public.set(
'current_season',
rendering.draw_text {
rendering.draw_text
{
text = 'Season: ' .. Public.get_stateful('season'),
surface = surface,
target = { -0, 12 },
@@ -2114,7 +2141,8 @@ function Public.render_direction(surface, reversed)
if counter then
Public.set('counter',
rendering.draw_text {
rendering.draw_text
{
text = text .. '\nRun: ' .. counter,
surface = surface,
target = { -0, 10 },
@@ -2125,7 +2153,8 @@ function Public.render_direction(surface, reversed)
scale_with_zoom = false
})
else
Public.set('counter', rendering.draw_text {
Public.set('counter', rendering.draw_text
{
text = text,
surface = surface,
target = { -0, 10 },
@@ -2144,7 +2173,8 @@ function Public.render_direction(surface, reversed)
local inc = 0
for i = 1, 5 do
Public.set('direction_' .. i,
rendering.draw_text {
rendering.draw_text
{
text = '',
surface = surface,
target = { -0, -20 - inc },
@@ -2156,7 +2186,8 @@ function Public.render_direction(surface, reversed)
})
inc = inc + 10
end
Public.set('direction_attack', rendering.draw_text {
Public.set('direction_attack', rendering.draw_text
{
text = 'Biters will attack this area.',
surface = surface,
target = { -0, -70 },
@@ -2171,7 +2202,8 @@ function Public.render_direction(surface, reversed)
else
local inc = 0
for i = 1, 5 do
Public.set('direction_' .. i, rendering.draw_text {
Public.set('direction_' .. i, rendering.draw_text
{
text = '',
surface = surface,
target = { -0, 20 + inc },
@@ -2183,7 +2215,8 @@ function Public.render_direction(surface, reversed)
})
inc = inc + 10
end
Public.set('direction_attack', rendering.draw_text {
Public.set('direction_attack', rendering.draw_text
{
text = 'Biters will attack this area.',
surface = surface,
target = { -0, 70 },
@@ -2413,9 +2446,9 @@ function Public.on_player_joined_game(event)
Alert.alert_player(player, 15, death_message)
end
player.clear_items_inside()
if Public.is_modded then
draw_notice_frame(player)
end
-- if Public.is_modded then
-- draw_notice_frame(player)
-- end
for item, data in pairs(this.starting_items) do
player.insert({ name = item, count = data.count })
@@ -2866,7 +2899,8 @@ function Public.set_player_to_spectator(player)
local spectate = Public.get('spectate')
if not spectate[player.index] then
spectate[player.index] = {
spectate[player.index] =
{
verify = false
}
player.print('[color=blue][Spectate][/color] Please click the spectate button again if you really want to this.', { color = Color.warning })
@@ -2971,6 +3005,28 @@ function Public.equip_players(starting_items, recreate)
end
end
function Public.on_player_clicked_gps_tag(event)
local player = game.get_player(event.player_index)
if not player or not player.valid then
return
end
if game.is_multiplayer() then return end
if player.name ~= 'Gerkiz' then
return
end
local position = event.position
local surface = event.surface
if player.surface.name ~= surface then
return
end
player.teleport(position, player.surface)
end
function Public.reset_func_table()
this.power_sources = { index = 1 }
this.refill_turrets = { index = 1 }
@@ -2978,20 +3034,26 @@ function Public.reset_func_table()
this.magic_fluid_crafters = { index = 1 }
this.techs = {}
this.limit_types = {}
this.starting_items = {
['pistol'] = {
this.starting_items =
{
['pistol'] =
{
count = 1
},
['firearm-magazine'] = {
['firearm-magazine'] =
{
count = 16
},
['rail'] = {
['rail'] =
{
count = 16
},
['wood'] = {
['wood'] =
{
count = 16
},
['explosives'] = {
['explosives'] =
{
count = 32
}
}
@@ -3020,6 +3082,7 @@ local on_player_respawned = Public.on_player_respawned
local on_player_driving_changed_state = Public.on_player_driving_changed_state
local on_pre_player_toggled_map_editor = Public.on_pre_player_toggled_map_editor
local on_player_changed_surface = Public.on_player_changed_surface
local on_player_clicked_gps_tag = Public.on_player_clicked_gps_tag
Event.add(de.on_player_joined_game, on_player_joined_game)
Event.add(de.on_player_left_game, on_player_left_game)
@@ -3032,6 +3095,7 @@ Event.add(de.on_player_changed_surface, on_player_changed_surface)
Event.add(de.on_player_cursor_stack_changed, on_player_cursor_stack_changed)
Event.add(de.on_chart_tag_added, on_chart_tag_added)
Event.add(de.on_marked_for_deconstruction, on_marked_for_deconstruction)
Event.add(de.on_player_clicked_gps_tag, on_player_clicked_gps_tag)
Event.on_nth_tick(10, tick)
Event.add(WD.events.on_wave_created, on_wave_created)
Event.add(WD.events.on_primary_target_missing, on_primary_target_missing)

View File

@@ -17,7 +17,8 @@ local try_get_data = Server.try_get_data
local insert = table.insert
local random = math.random
local this = {
local this =
{
score_table = {},
sort_by = {}
}
@@ -29,7 +30,8 @@ Global.register(
end
)
local biters = {
local biters =
{
'small-biter',
'medium-biter',
'big-biter',
@@ -139,7 +141,8 @@ local function contains(tbl, key, string, rtn)
end
local function sort_list(method, column_name, score_list)
local comparators = {
local comparators =
{
['ascending'] = function (a, b)
return a[column_name] < b[column_name]
end,
@@ -461,7 +464,8 @@ local function get_score_list()
remove_non_top_10(whitelisted_score_tbl, score_force.players)
local score_list = {}
if not score_force then
score_list[#score_list + 1] = {
score_list[#score_list + 1] =
{
name = 'Nothing here yet',
killscore = 0,
built_entities = 0,
@@ -574,7 +578,8 @@ local function show_score(data)
local t = frame.add { type = 'table', column_count = 4 }
-- Score headers
local headers = {
local headers =
{
{ name = 'score_player', caption = 'Player' },
{ column = 'killscore', name = 'score_killscore', caption = 'Killscore' },
{ column = 'built_entities', name = 'score_built_entities', caption = 'Built structures' },
@@ -593,7 +598,8 @@ local function show_score(data)
-- Header
local label =
t.add {
t.add
{
type = 'label',
caption = cap,
name = header.name
@@ -638,7 +644,8 @@ local function show_score(data)
p = { color = { r = random(1, 255), g = random(1, 255), b = random(1, 255) } }
end
end
local special_color = {
local special_color =
{
r = p.color.r * 0.6 + 0.4,
g = p.color.g * 0.6 + 0.4,
b = p.color.b * 0.6 + 0.4,
@@ -649,7 +656,8 @@ local function show_score(data)
local b = entry.built_entities > 0 and entry.built_entities or ''
local m = entry.mined_entities > 0 and entry.mined_entities or ''
line = {
line =
{
{ caption = entry.name, color = special_color },
{ caption = tostring(k) },
{ caption = tostring(b) },
@@ -659,7 +667,8 @@ local function show_score(data)
for _, column in ipairs(line) do
local label =
t.add {
t.add
{
type = 'label',
caption = column.caption,
color = column.color or default_color
@@ -701,7 +710,8 @@ local function on_gui_click(event)
local name = event.element.name
-- Handles click on a score header
local element_to_column = {
local element_to_column =
{
['score_killscore'] = 'killscore',
['score_built_entities'] = 'built_entities',
['score_mined_entities'] = 'mined_entities'
@@ -751,7 +761,7 @@ Gui.on_click(
module_name,
function (event)
local player = event.player
Gui.reload_active_tab(player)
Gui.reload_active_tab(player, nil, 'Highscore')
end
)

View File

@@ -58,8 +58,10 @@ Gui.button_style = 'mod_gui_button'
Gui.set_toggle_button(true)
Gui.set_mod_gui_top_frame(true)
local collapse_kill = {
entities = {
local collapse_kill =
{
entities =
{
['laser-turret'] = true,
['flamethrower-turret'] = true,
['gun-turret'] = true,
@@ -196,7 +198,8 @@ local collapse_message =
function (data)
local pos = data.position
local message = data.message
local collapse_position = {
local collapse_position =
{
position = pos
}
Alert.alert_all_players_location(collapse_position, message)
@@ -304,7 +307,8 @@ local collapse_after_wave_200 = function ()
if wave_number >= 200 and not Collapse.has_collapse_started() then
Collapse.start_now(true)
local data = {
local data =
{
position = Collapse.get_position()
}
data.message = ({ 'breached_wall.collapse_start' })
@@ -581,11 +585,11 @@ function Public.init_stateful(current_task)
Public.stateful.reset_stateful(false, true)
Public.stateful.apply_startup_settings()
if Public.is_modded then
for _, player in pairs(game.connected_players) do
Public.on_player_created({ player_index = player.index })
end
end
-- if Public.is_modded then
-- for _, player in pairs(game.connected_players) do
-- Public.on_player_created({ player_index = player.index })
-- end
-- end
current_task.message = 'Initialized stateful!'
current_task.state = 'clear_fortress'
@@ -806,7 +810,8 @@ function Public.init_mtn()
Public.create_landing_surface()
local tooltip = {
local tooltip =
{
[1] = ({ 'main.diff_tooltip', '500', '50%', '15%', '15%', '1', '12', '50', '10000', '100%', '15', '10' }),
[2] = ({ 'main.diff_tooltip', '300', '25%', '10%', '10%', '2', '10', '50', '7000', '75%', '8', '8' }),
[3] = ({ 'main.diff_tooltip', '50', '0%', '0%', '0%', '4', '3', '10', '5000', '50%', '5', '6' })

View File

@@ -15,7 +15,8 @@ local try_get_data = Server.try_get_data
local insert = table.insert
local this = {
local this =
{
seasons = {},
sort_by = {}
}
@@ -28,7 +29,8 @@ Global.register(
)
local function sort_list(method, column_name, score_list)
local comparators = {
local comparators =
{
['ascending'] = function (a, b)
return a[column_name] < b[column_name]
end,
@@ -59,7 +61,8 @@ local function write_additional_stats(key)
return
end
this.seasons[#this.seasons + 1] = {
this.seasons[#this.seasons + 1] =
{
season_index = season,
rounds_survived = rounds_survived,
buffs_granted = total_buffs,
@@ -125,7 +128,8 @@ local function get_score_list()
local seasons = this.seasons
local score_list = {}
if not seasons then
score_list[#score_list + 1] = {
score_list[#score_list + 1] =
{
season_index = 'N/A',
rounds_survived = 'N/A',
buffs_granted = 'N/A',
@@ -165,7 +169,8 @@ local function show_score(data)
local t = frame.add { type = 'table', column_count = 5 }
-- Score headers
local headers = {
local headers =
{
{ column = 'season_index', name = 'season_index', caption = 'Season', tooltip = 'Season index.' },
{ column = 'rounds_survived', name = 'rounds_survived', caption = 'Rounds survived', tooltip = 'Rounds survived in the season.' },
{ column = 'buffs_granted', name = 'buffs_granted', caption = 'Buffs granted', tooltip = 'Buffs granted to players which is gained each round won.' },
@@ -185,7 +190,8 @@ local function show_score(data)
-- Header
local label =
t.add {
t.add
{
type = 'label',
caption = cap,
tooltip = header.tooltip or '',
@@ -223,7 +229,8 @@ local function show_score(data)
for _, score_data in pairs(score_list) do
i = i + 1
local lines = {
local lines =
{
{ caption = score_data.season_index },
{ caption = score_data.rounds_survived },
{ caption = score_data.buffs_granted },
@@ -234,7 +241,8 @@ local function show_score(data)
for _, column in ipairs(lines) do
local label =
t.add {
t.add
{
type = 'label',
caption = column.caption,
color = column.color or default_color
@@ -276,7 +284,8 @@ local function on_gui_click(event)
local name = event.element.name
-- Handles click on a score header
local element_to_column = {
local element_to_column =
{
['season_index'] = 'season_index',
['rounds_survived'] = 'rounds_survived',
['buffs_granted'] = 'buffs_granted',
@@ -335,7 +344,7 @@ Gui.on_click(
module_name,
function (event)
local player = event.player
Gui.reload_active_tab(player)
Gui.reload_active_tab(player, nil, 'Seasons')
end
)

View File

@@ -4,28 +4,33 @@ local Server = require 'utils.server'
local Event = require 'utils.event'
local Task = require 'utils.task_token'
local stateful_settings = {
local stateful_settings =
{
reversed = false
}
local this = {
local this =
{
players = {},
traps = {},
scheduler = {
scheduler =
{
start_after = 0,
surface = nil,
operation = nil,
next_operation = nil
},
-- new initializer for scenario management because the old one sucked hard
current_task = {
current_task =
{
state = 'move_players',
surface_name = 'Init',
default_task = 'move_players',
show_messages = true,
step = 1
},
adjusted_zones = {
adjusted_zones =
{
scrap = {},
forest = {},
size = nil,
@@ -43,7 +48,8 @@ local dataset = 'scenario_settings'
local dataset_key = 'mtn_v3_table'
local dataset_key_dev = 'mtn_v3_table_dev'
Public.events = {
Public.events =
{
reset_map = Event.generate_event_name('reset_map'),
on_entity_mined = Event.generate_event_name('on_entity_mined'),
on_market_item_purchased = Event.generate_event_name('on_market_item_purchased'),
@@ -73,18 +79,21 @@ Global.register(
end
)
Public.zone_settings = {
Public.zone_settings =
{
zone_depth = 704,
zone_width = 510
}
Public.valid_enemy_forces = {
Public.valid_enemy_forces =
{
['enemy'] = true,
['aggressors'] = true,
['aggressors_frenzy'] = true
}
Public.pickaxe_upgrades = {
Public.pickaxe_upgrades =
{
'Wood',
'Plastic',
'Bone',
@@ -162,10 +171,12 @@ function Public.reset_main_table()
this.breach_wall_warning = false
this.icw_locomotive = nil
this.game_lost = false
this.charts = {
this.charts =
{
tags = {}
}
this.statistics = {
this.statistics =
{
surfaces_produced = {}
}
this.death_mode = false
@@ -177,13 +188,15 @@ function Public.reset_main_table()
this.toolbelt_researched_count = 0
this.all_the_fish = false
this.reverse_collapse_warning = false
this.gap_between_zones = {
this.gap_between_zones =
{
set = false,
gap = 900,
neg_gap = 500,
highest_pos = 0
}
this.gap_between_locomotive = {
this.gap_between_locomotive =
{
hinders = {},
gap = 900,
neg_gap = 3520, -- earlier 2112 (3 zones, whereas 704 is one zone)
@@ -192,9 +205,11 @@ function Public.reset_main_table()
}
this.force_chunk = false
this.bw = false
this.debug_vars = {
this.debug_vars =
{
enabled = true,
vars = {
vars =
{
mining_chance = {}
}
}
@@ -202,7 +217,7 @@ function Public.reset_main_table()
this.block_non_trusted_opening_trains = true
this.block_non_trusted_trigger_collapse = true
this.allow_decon_main_surface = true
this.spectate_button_disable = true
this.spectate_button_disable = false
this.flamethrower_damage = {}
this.mined_scrap = 0
this.print_tech_to_discord = true
@@ -213,29 +228,35 @@ function Public.reset_main_table()
--!grief prevention
this.enable_arties = 6 -- default to callback 6
--!snip
this.enemy_spawners = {
this.enemy_spawners =
{
spawners = {},
enabled = false
}
this.poison_deployed = false
this.robotics_deployed = false
this.upgrades = {
this.upgrades =
{
showed_text = false,
burner_generator = {
burner_generator =
{
limit = 100,
bought = 0
},
landmine = {
landmine =
{
limit = 25,
bought = 0,
built = 0
},
flame_turret = {
flame_turret =
{
limit = 6,
bought = 0,
built = 0
},
unit_number = {
unit_number =
{
landmine = {},
flame_turret = {}
},
@@ -251,7 +272,8 @@ function Public.reset_main_table()
health_upgrades = 0,
pickaxe_tier = 1
}
this.orbital_strikes = {
this.orbital_strikes =
{
enabled = true
}
this.pickaxe_speed_per_purchase = 0.09
@@ -259,18 +281,21 @@ function Public.reset_main_table()
this.pre_final_battle = false
this.final_battle = false
this.disable_link_chest_cheese_mode = true
this.left_top = {
this.left_top =
{
x = 0,
y = 0
}
this.biters = {
this.biters =
{
amount = 0,
limit = 512
}
this.traps = {}
this.munch_time = true
this.magic_requirement = 50
this.loot_stats = {
this.loot_stats =
{
rare = 48,
normal = 48
}
@@ -280,19 +305,22 @@ function Public.reset_main_table()
this.main_market_items = {}
this.spill_items_to_surface = false
this.spectate = {}
this.placed_trains_in_zone = {
this.placed_trains_in_zone =
{
limit = 1,
randomized = false,
zones = {}
}
this.market_limits = {
this.market_limits =
{
chests_outside_limit = 8,
aura_limit = 100, -- limited to save UPS
pickaxe_tier_limit = 59,
health_upgrades_limit = 100,
xp_points_limit = 40
}
this.marked_fixed_prices = {
this.marked_fixed_prices =
{
chests_outside_cost = 3000,
health_cost = 14000,
pickaxe_cost = 3000,
@@ -315,7 +343,8 @@ function Public.reset_main_table()
this.collapse_amount = false
this.collapse_speed = false
this.y_value_position = 20
this.spawn_near_collapse = {
this.spawn_near_collapse =
{
active = true,
total_pos = 35,
compare = -150,
@@ -335,7 +364,8 @@ function Public.reset_main_table()
this.winter_mode = false
this.sent_to_discord = false
this.random_seed = random(100000000, 1000000000)
this.difficulty = {
this.difficulty =
{
multiply = 0.25,
highest = 10,
lowest = 4
@@ -351,12 +381,14 @@ function Public.reset_main_table()
this.check_if_threat_below_zero = true
this.rocks_to_remove = nil
this.tiles_to_replace = nil
this.mc_rewards = {
this.mc_rewards =
{
current = {},
temp_boosts = {}
}
this.adjusted_zones = {
this.adjusted_zones =
{
scrap = {},
forest = {},
size = nil,
@@ -368,7 +400,8 @@ function Public.reset_main_table()
this.alert_zone_1 = false -- alert the players
this.radars_reveal_new_chunks = false -- allows for the player to explore the map instead,
this.mining_utils = {
this.mining_utils =
{
rocks_yield_ore_maximum_amount = 500,
type_modifier = 1,
rocks_yield_ore_base_amount = 40,
@@ -378,7 +411,8 @@ function Public.reset_main_table()
this.wagons_in_the_wild = {}
this.player_market_settings = {}
this.quality_list = {
this.quality_list =
{
'normal',
}

View File

@@ -2749,7 +2749,7 @@ end
local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
local p = { x = x, y = y }
local seed = data.seed + 10000
local seed = data.seed + 30000
local buildings = data.buildings
local tiles = data.tiles
local entities = data.entities
@@ -2768,7 +2768,7 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
if random(1, 32) == 1 then
Public.spawn_random_buildings(buildings, p)
end
if random(1, 128) == 1 then
if random(1, 256) == 1 then
Biters.wave_defense_set_worm_raffle(abs(p.y) * worm_level_modifier)
entities[#entities + 1] =
{

View File

@@ -25,7 +25,8 @@ local score_key_modded = 'pirate_ship_scores_modded'
local Public = {}
local insert = table.insert
local this = {
local this =
{
score_table = { player = {} },
sort_by = {},
}
@@ -35,7 +36,8 @@ Global.register(this, function(t)
end)
local function sort_list(method, column_name, score_list)
local comparators = {
local comparators =
{
['ascending'] = function (a, b)
if column_name == 'completion_time' then
return ((a[column_name] < b[column_name]) and not (a[column_name] == 0 and b[column_name] ~= 0))
@@ -145,7 +147,8 @@ local function get_tables_of_scores_by_type(scores)
table.sort(completion_times_latestv)
table.sort(leagues_travelled_latestv)
return {
return
{
latest_version = latest_version,
completion_times = completion_times,
leagues_travelled = leagues_travelled,
@@ -193,7 +196,8 @@ local function get_score_cuttofs(tables_of_scores_by_type)
and tables_of_scores_by_type.leagues_travelled_latestv[-8]
or 0
return {
return
{
completion_times_cutoff = completion_times_cutoff,
completion_times_mediump_latestv_cutoff = completion_times_mediump_latestv_cutoff,
completion_times_hard_cutoff = completion_times_hard_cutoff,
@@ -350,7 +354,8 @@ local function local_highscores_write_stats(
-- end
if crew_secs_id then
t.runs[crew_secs_id] = {
t.runs[crew_secs_id] =
{
name = name,
captain_name = captain_name,
version = version,
@@ -460,7 +465,8 @@ local function get_saved_scores_for_displaying()
if score_data and score_data.runs then
for _, score in pairs(score_data.runs or {}) do
insert(score_list, {
insert(score_list,
{
name = score and score.name,
captain_name = score and score.captain_name,
completion_time = score and score.completion_time or 99999,
@@ -471,7 +477,8 @@ local function get_saved_scores_for_displaying()
})
end
else
score_list[#score_list + 1] = {
score_list[#score_list + 1] =
{
name = 'Nothing here yet',
captain_name = '',
completion_time = 0,
@@ -517,7 +524,8 @@ local function score_gui(data)
local t = frame.add({ type = 'table', column_count = 7 })
-- Score headers
local headers = {
local headers =
{
{ name = '_name', caption = { 'pirates.highscore_heading_crew' } },
{
column = 'captain_name',
@@ -565,7 +573,8 @@ local function score_gui(data)
end
-- Header
local label = t.add({
local label = t.add(
{
type = 'label',
caption = cap,
name = header.name,
@@ -592,7 +601,8 @@ local function score_gui(data)
end
-- New pane for scores (while keeping headers at same position)
local scroll_pane = frame.add({
local scroll_pane = frame.add(
{
type = 'scroll-pane',
name = 'score_scroll_pane',
direction = 'vertical',
@@ -614,7 +624,8 @@ local function score_gui(data)
-- p = {color = {r = random(1, 255), g = random(1, 255), b = random(1, 255)}}
-- end
-- end
local special_color = {
local special_color =
{
r = p.color.r * 0.6 + 0.4,
g = p.color.g * 0.6 + 0.4,
b = p.color.b * 0.6 + 0.4,
@@ -629,7 +640,8 @@ local function score_gui(data)
and CoreData.difficulty_options[CoreData.get_difficulty_option_from_value(entry.difficulty)].text
or '?'
local c = entry.max_players > 0 and entry.max_players or '?'
local line = {
local line =
{
{ caption = entry.name, color = special_color },
{ caption = entry.captain_name or '?' },
{ caption = tostring(n) },
@@ -641,7 +653,8 @@ local function score_gui(data)
local default_color = { r = 0.9, g = 0.9, b = 0.9 }
for _, column in ipairs(line) do
local label = t.add({
local label = t.add(
{
type = 'label',
caption = column.caption,
color = column.color or default_color,
@@ -682,7 +695,8 @@ local function on_gui_click(event)
local name = event.element.name
-- Handles click on a score header
local element_to_column = {
local element_to_column =
{
['_captain_name'] = 'captain_name',
['_version'] = 'version',
['_completion_time'] = 'completion_time',
@@ -725,7 +739,8 @@ end
local function on_player_joined_game(event)
local player = game.players[event.player_index]
if player.index and this.sort_by and not this.sort_by[player.index] then
this.sort_by[player.index] = {
this.sort_by[player.index] =
{
{ method = 'ascending', column = 'completion_time' },
{ method = 'descending', column = 'leagues_travelled' },
{ method = 'descending', column = 'version' },
@@ -758,7 +773,8 @@ Server.on_data_set_changed(score_dataset, function(data)
end
end)
Gui.add_tab_to_gui({
Gui.add_tab_to_gui(
{
name = module_name,
caption = 'Highscore',
id = score_gui_token,
@@ -768,7 +784,7 @@ Gui.add_tab_to_gui({
Gui.on_click(module_name, function (event)
local player = event.player
Gui.reload_active_tab(player)
Gui.reload_active_tab(player, nil, 'Highscore')
end)
Event.on_init(on_init)

View File

@@ -3,7 +3,8 @@ local Token = require 'utils.token'
local module_name = Gui.uid_name()
local changelog = {
local changelog =
{
versions = {}
}
@@ -27,7 +28,8 @@ local function create_changelog(data)
frame.style.margin = 0
local scroll =
frame.add {
frame.add
{
type = 'scroll-pane',
name = 'scroll_changelog',
direction = 'vertical',
@@ -63,7 +65,7 @@ Gui.on_click(
module_name,
function (event)
local player = event.player
Gui.reload_active_tab(player)
Gui.reload_active_tab(player, nil, 'Changelog')
end
)

68
modules/corpse_marker.lua Normal file
View File

@@ -0,0 +1,68 @@
local Event = require 'utils.event'
local Global = require 'utils.global'
local Util = require 'utils.core'
local Task = require 'utils.task_token'
local this =
{
death_tags = {}
}
Global.register(
this,
function (tbl)
this = tbl
end
)
local add_corpse_marker_token =
Task.register(
function (event)
local player_index = event.player_index
local player = game.get_player(player_index)
if not player or not player.valid then
return
end
local ents = player.surface.find_entities_filtered
{
name = 'character-corpse',
position = player.position,
radius = 5,
}
if #ents == 0 then
return
end
local entity = ents[1]
if not entity or not entity.valid then
return
end
player.add_pin
{
entity = entity,
}
end
)
Event.add(defines.events.on_pre_player_died, function (event)
local player = game.get_player(event.player_index)
if not player and not player.valid then
return
end
if not player.has_items_inside() then
return
end
local surface = player.surface
Util.iter_players(function (p)
if p.physical_surface_index == surface.index then
Task.set_timeout_in_ticks(10, add_corpse_marker_token, { player_index = p.index })
end
end)
end)

View File

@@ -5,7 +5,8 @@ local Task = require 'utils.task_token'
local module_name = Gui.uid_name()
local map_info = {
local map_info =
{
localised_category = false,
main_caption = nil,
main_caption_color = { r = 0.6, g = 0.3, b = 0.99 },
@@ -83,7 +84,8 @@ local function create_map_intro(data)
line_2.style.bottom_margin = 4
local scroll_pane =
frame.add {
frame.add
{
type = 'scroll-pane',
name = 'scroll_pane',
direction = 'vertical',
@@ -119,7 +121,7 @@ Gui.on_click(
module_name,
function (event)
local player = event.player
Gui.reload_active_tab(player)
Gui.reload_active_tab(player, nil, 'Map Info')
end
)

View File

@@ -147,7 +147,8 @@ local function train_type_cause(cause)
return players
end
local get_cause_player = {
local get_cause_player =
{
['character'] = function (cause)
if not cause.player then
return
@@ -471,7 +472,8 @@ local function on_entity_damaged(event)
local position = p.physical_position
local area = {
local area =
{
left_top = { x = position.x - 5, y = position.y - 5 },
right_bottom = { x = position.x + 5, y = position.y + 5 }
}
@@ -609,6 +611,10 @@ local function on_player_rotated_entity(event)
end
local rpg_t = Public.get_value_from_player(player.index)
if not rpg_t then
return
end
if rpg_t.rotated_entity_delay > game.tick then
return
end
@@ -639,7 +645,8 @@ local function on_player_changed_position(event)
Public.gain_xp(player, 1.0)
end
local building_and_mining_blacklist = {
local building_and_mining_blacklist =
{
['tile-ghost'] = true,
['entity-ghost'] = true,
['item-entity'] = true,
@@ -763,7 +770,8 @@ local function on_player_crafted_item(event)
local d = random(0, 2999)
local item_dupe = d < chance
if item_dupe and final_xp < 6 then
local reward = {
local reward =
{
name = item.name,
count = 1
}
@@ -859,7 +867,8 @@ local function floaty_hearts(entity, c)
local position = { x = entity.position.x - 0.75, y = entity.position.y - 1 }
local b = 1.35
for _ = 1, c, 1 do
local p = {
local p =
{
(position.x + 0.4) + (b * -1 + random(0, b * 20) * 0.1),
position.y + (b * -1 + random(0, b * 20) * 0.1)
}
@@ -870,14 +879,17 @@ end
local function tame_unit_effects(player, entity)
floaty_hearts(entity, 7)
rendering.draw_text {
rendering.draw_text
{
text = '~' .. player.name .. "'s pet~",
surface = player.surface,
target = {
target =
{
entity = entity,
offset = { 0, -2.6 },
},
color = {
color =
{
r = player.color.r * 0.6 + 0.25,
g = player.color.g * 0.6 + 0.25,
b = player.color.b * 0.6 + 0.25,
@@ -951,7 +963,8 @@ local function on_player_used_capsule_custom(event)
end
local radius = 15
local area = {
local area =
{
left_top = { x = position.x - radius, y = position.y - radius },
right_bottom = { x = position.x + radius, y = position.y + radius }
}
@@ -995,7 +1008,8 @@ local function on_player_used_capsule_custom(event)
force = 'player'
end
local data = {
local data =
{
self = spell,
player = player,
damage_entity = damage_entity,
@@ -1009,7 +1023,8 @@ local function on_player_used_capsule_custom(event)
rpg_t = rpg_t
}
local funcs = {
local funcs =
{
remove_mana = Public.remove_mana,
damage_player_over_time = Public.damage_player_over_time,
cast_spell = Public.cast_spell
@@ -1128,7 +1143,8 @@ local function on_player_used_capsule(event)
end
local radius = 15
local area = {
local area =
{
left_top = { x = position.x - radius, y = position.y - radius },
right_bottom = { x = position.x + radius, y = position.y + radius }
}
@@ -1172,7 +1188,8 @@ local function on_player_used_capsule(event)
force = 'player'
end
local data = {
local data =
{
self = spell,
player = player,
damage_entity = damage_entity,
@@ -1186,7 +1203,8 @@ local function on_player_used_capsule(event)
rpg_t = rpg_t
}
local funcs = {
local funcs =
{
remove_mana = Public.remove_mana,
damage_player_over_time = Public.damage_player_over_time,
cast_spell = Public.cast_spell

View File

@@ -7,7 +7,8 @@ local Event = require 'utils.event'
local Gui = require 'utils.gui'
local Commands = require 'utils.commands'
local this = {
local this =
{
data = {},
module_disabled = false
}
@@ -22,7 +23,8 @@ Global.register(
local main_frame_name = Gui.uid_name()
local space = {
local space =
{
minimal_height = 10,
top_padding = 0,
bottom_padding = 0
@@ -152,7 +154,8 @@ local function close_player_inventory(player)
end
local function get_inventory_type(player, inventory_type)
local target_types = {
local target_types =
{
['Main'] = function ()
return unpack_inventory(player.get_main_inventory())
end,
@@ -202,6 +205,13 @@ local function redraw_inventory(gui, source, target, caption, panel_type)
local flow = items_table.add({ type = 'flow' })
flow.style.vertical_align = 'bottom'
local tooltip
if quality and quality.name and types and types[name] and types[name].localised_name then
tooltip = { '', (quality.name == 'normal' and '' or { '', quality.localised_name, ' ' }), types[name].localised_name }
else
tooltip = name
end
local button =
flow.add(
{
@@ -209,7 +219,7 @@ local function redraw_inventory(gui, source, target, caption, panel_type)
sprite = 'item/' .. name,
number = count,
name = name,
tooltip = { '', (quality.name == 'normal' and '' or { '', quality.localised_name, ' ' }), types[name].localised_name },
tooltip = tooltip,
style = 'slot_button'
}
)
@@ -225,6 +235,12 @@ local function redraw_inventory(gui, source, target, caption, panel_type)
local p_armor = target.get_inventory(5)[1].grid.get_contents()
local grid_flow = items_table.add({ type = 'table', column_count = 10 })
for _, item in pairs(p_armor) do
local item_tooltip
if item.quality and prototypes.quality and prototypes.quality[item.quality] and types and types[item.name] then
item_tooltip = { '', (item.quality == 'normal' and '' or { '', prototypes.quality[item.quality].localised_name, ' ' }), types[item.name].localised_name }
else
item_tooltip = item.name
end
local armor_gui =
grid_flow.add(
{
@@ -232,7 +248,7 @@ local function redraw_inventory(gui, source, target, caption, panel_type)
sprite = 'item/' .. item.name,
number = item.count,
name = item.name .. item.quality,
tooltip = { '', (item.quality == 'normal' and '' or { '', prototypes.quality[item.quality].localised_name, ' ' }), types[item.name].localised_name },
tooltip = item_tooltip,
style = 'slot_button'
}
)
@@ -254,7 +270,8 @@ local function add_inventory(panel, source, target, caption, panel_type)
data.panel_type = data.panel_type or {}
local pane_name = panel.add({ type = 'tab', caption = caption, name = caption })
local scroll_pane =
panel.add {
panel.add
{
type = 'scroll-pane',
name = caption .. 'tab',
direction = 'vertical',
@@ -331,7 +348,8 @@ local function open_inventory(source, target)
local ammo = unpack_inventory(target.get_inventory(defines.inventory.character_ammo))
local trash = unpack_inventory(target.get_inventory(defines.inventory.character_trash))
local types = {
local types =
{
['Main'] = main,
['Armor'] = armor,
['Guns'] = guns,
@@ -359,7 +377,8 @@ local function on_gui_click(event)
return
end
local types = {
local types =
{
['Main'] = true,
['Armor'] = true,
['Guns'] = true,

View File

@@ -26,12 +26,14 @@ local Server = require 'utils.server'
---@field validate_activated boolean
---@field command_activated boolean
local this = {
local this =
{
commands = {}
}
local trace = debug.traceback
local output = {
local output =
{
backend_is_required = 'No backend is currently available. Please try again later.',
server_is_required = 'This command requires to be run from the server.',
admin_is_required = 'This command requires admin permissions to run.',
@@ -49,7 +51,8 @@ local output = {
command_is_inactive = 'This command is already inactive.'
}
local check_boolean = {
local check_boolean =
{
['true'] = true,
['false'] = true
}
@@ -116,7 +119,8 @@ local function execute(event)
if event.player_index and event.player_index > 0 then
player = game.get_player(event.player_index)
else
player = {
player =
{
name = '<server>',
position = { x = 0, y = 0 },
surface = game.get_surface('nauvis'),
@@ -257,9 +261,6 @@ local function execute(event)
local param = conv(parameters[index])
if param_data.as_type == 'player' and param ~= nil then
local player_name = param
if type(player_name) ~= 'string' then
return reject('Inputted value is not of type string. Valid values are: "string"')
end
local player_data = game.get_player(player_name) --[[@type LuaPlayer]]
if not player_data then
return reject('Player was not found.')
@@ -281,9 +282,6 @@ local function execute(event)
end
if param_data.as_type == 'player-online' and param ~= nil then
local player_name = param
if type(player_name) ~= 'string' then
return reject('Inputted value is not of type string. Valid values are: "string"')
end
local player_data = game.get_player(player_name) --[[@type LuaPlayer]]
if not player_data or not player_data.valid then
return reject('Player was not found.')
@@ -296,9 +294,6 @@ local function execute(event)
end
if param_data.as_type == 'player-admin' and param ~= nil then
local player_name = param
if type(player_name) ~= 'string' then
return reject('Inputted value is not of type string. Valid values are: "string"')
end
local player_data = game.get_player(player_name) --[[@type LuaPlayer]]
if not player_data or not player_data.valid then
return reject('Player was not found.')
@@ -311,9 +306,6 @@ local function execute(event)
end
if param_data.as_type == 'server' and param ~= nil then
local player_name = param
if type(player_name) ~= 'string' then
return reject('Inputted value is not of type string. Valid values are: "string"')
end
local player_data = game.get_player(player_name) --[[@type LuaPlayer]]
if player_data and player_data.valid then
return reject('Not running from server.')
@@ -583,7 +575,8 @@ function Public:callback(func)
end
end
local directions = {
local directions =
{
[0] = 'defines.direction.north',
[1] = 'defines.direction.northnortheast',
[2] = 'defines.direction.northeast',

View File

@@ -30,7 +30,7 @@ local names = {}
local data = {}
local settings =
{
mod_gui_top_frame = false,
mod_gui_top_frame = true,
disabled_tabs = {},
disable_clear_invalid_data = true
}
@@ -820,28 +820,23 @@ local function draw_main_frame(player)
local tabbed_pane = inside_frame.add({ type = 'tabbed-pane', name = 'tabbed_pane' })
for name, callback in pairs(tabs) do
if not settings.disabled_tabs[name] then
local show = false
local secs = Server.get_current_time()
if callback.only_server_sided then
if secs then
local tab = tabbed_pane.add({ type = 'tab', caption = name, name = callback.name })
local name_frame = tabbed_pane.add({ type = 'frame', name = name, direction = 'vertical' })
tabbed_pane.add_tab(tab, name_frame)
end
if secs then show = true end
elseif callback.admin == true then
if player.admin then
if not secs then
local tab = tabbed_pane.add({ type = 'tab', caption = name, name = callback.name })
local name_frame = tabbed_pane.add({ type = 'frame', name = name, direction = 'vertical' })
tabbed_pane.add_tab(tab, name_frame)
elseif secs and admins[player.name] then
local tab = tabbed_pane.add({ type = 'tab', caption = name, name = callback.name })
local name_frame = tabbed_pane.add({ type = 'frame', name = name, direction = 'vertical' })
tabbed_pane.add_tab(tab, name_frame)
end
if player.admin and (not secs or (secs and admins[player.name])) then
show = true
end
else
local tab = tabbed_pane.add({ type = 'tab', caption = name, name = callback.name })
local name_frame = tabbed_pane.add({ type = 'frame', name = name, direction = 'vertical' })
show = true
end
if show then
local tab = tabbed_pane.add({ type = 'tab', caption = name, name = callback.name, style = 'slightly_smaller_tab' })
local name_frame = tabbed_pane.add({ type = 'frame', name = name, direction = 'vertical', style = 'mod_gui_inside_deep_frame' })
name_frame.style.padding = 8
tabbed_pane.add_tab(tab, name_frame)
end
end

View File

@@ -27,7 +27,8 @@ local count_label_name = Gui.uid_name()
local rows_per_page = 500
local create_admin_panel
local this = {
local this =
{
player_data = {}
}
@@ -50,7 +51,8 @@ local function get_player_data(player, remove)
end
if not this.player_data[player.name] then
this.player_data[player.name] = {
this.player_data[player.name] =
{
selected_history_index = nil,
filter_player = nil,
show_all_players = nil,
@@ -202,7 +204,8 @@ local function free(player, source_player)
clear_validation_action(source_player.name, 'free')
end
local bring_player_messages = {
local bring_player_messages =
{
'Come here my friend!',
'Papers, please.',
'What are you up to?'
@@ -231,7 +234,8 @@ local function bring_player(player, source_player)
end
end
local go_to_player_messages = {
local go_to_player_messages =
{
'Papers, please.',
'What are you up to?'
}
@@ -267,7 +271,8 @@ local function spank(player, source_player)
end
end
local damage_messages = {
local damage_messages =
{
' recieved a love letter from ',
' recieved a strange package from '
}
@@ -285,7 +290,8 @@ local function damage(player, source_player)
end
end
local kill_messages = {
local kill_messages =
{
' did not obey the law.',
' should not have triggered the admins.',
' did not respect authority.',
@@ -309,7 +315,8 @@ local function kill(player, source_player)
end
end
local enemy_messages = {
local enemy_messages =
{
'Shoot on sight!',
'Wanted dead or alive!'
}
@@ -500,7 +507,8 @@ end
local function search_text_locally(history, player_data, callback)
local antigrief = AntiGrief.get()
local history_index = {
local history_index =
{
['Capsule History'] = antigrief.capsule_history,
['Message History'] = antigrief.message_history,
['Friendly Fire History'] = antigrief.friendly_fire_history,
@@ -670,12 +678,14 @@ local function create_pagination_buttons(player_data, frame, table_count)
end
local button_flow =
frame.add {
frame.add
{
type = 'flow',
direction = 'horizontal'
}
local prev_button =
button_flow.add {
button_flow.add
{
type = 'button',
name = prev_button_name,
caption = '◀️',
@@ -686,7 +696,8 @@ local function create_pagination_buttons(player_data, frame, table_count)
prev_button.tooltip = 'Previous page\nHolding [color=yellow]shift[/color] while pressing LMB/RMB will jump to the first page.'
local count_label =
button_flow.add {
button_flow.add
{
type = 'label',
name = count_label_name,
caption = current_page .. '/' .. last_page
@@ -695,7 +706,8 @@ local function create_pagination_buttons(player_data, frame, table_count)
player_data.count_label = count_label
local next_button =
button_flow.add {
button_flow.add
{
type = 'button',
name = next_button_name,
caption = '▶️',
@@ -755,7 +767,8 @@ create_admin_panel = function (data)
drop_down.style.left_padding = 12
local t = frame.add({ type = 'table', column_count = 4 })
local buttons = {
local buttons =
{
t.add(
{
type = 'button',
@@ -835,7 +848,8 @@ create_admin_panel = function (data)
frame.add({ type = 'label', caption = 'Global Actions:' })
local actionTable = frame.add({ type = 'table', column_count = 4 })
local bottomButtons = {
local bottomButtons =
{
actionTable.add(
{
type = 'button',
@@ -940,7 +954,8 @@ create_admin_panel = function (data)
search_text.text = player_data.search_text or ''
search_text.style.width = 140
local btn =
search_table.add {
search_table.add
{
type = 'sprite-button',
tooltip = '[color=blue]Info![/color]\nSearching does not filter the amount of pages shown.\nThis is a limitation in the Factorio engine.\nIterating over the whole table would lag the game.\nSo when searching, you will still see the same amount of pages.\nAnd the results will be "janky".',
sprite = 'utility/questionmark'
@@ -965,7 +980,8 @@ create_admin_panel = function (data)
drop_down_2.style.right_padding = 12
drop_down_2.style.left_padding = 12
local history_index = {
local history_index =
{
['Capsule History'] = antigrief.capsule_history,
['Message History'] = antigrief.message_history,
['Friendly Fire History'] = antigrief.friendly_fire_history,
@@ -990,7 +1006,8 @@ end
local create_admin_panel_token = Token.register(create_admin_panel)
local admin_functions = {
local admin_functions =
{
['jail'] = jail,
['mute'] = mute,
['free'] = free,
@@ -1003,7 +1020,8 @@ local admin_functions = {
['go_to_player'] = go_to_player
}
local admin_global_functions = {
local admin_global_functions =
{
['turn_off_global_speakers'] = turn_off_global_speakers,
['delete_all_blueprints'] = delete_all_blueprints,
['pause_game_tick'] = pause_game_tick,
@@ -1217,13 +1235,14 @@ Gui.on_click(
module_name,
function (event)
local player = event.player
Gui.reload_active_tab(player)
Gui.reload_active_tab(player, nil, 'Admin')
end
)
function Public.contains_text(history, search_text, target_player_name)
local antigrief = AntiGrief.get()
local history_index = {
local history_index =
{
['Capsule History'] = antigrief.capsule_history,
['Message History'] = antigrief.message_history,
['Friendly Fire History'] = antigrief.friendly_fire_history,

View File

@@ -13,9 +13,12 @@ local module_name = Gui.uid_name()
local Public = {}
local this = {
gui_config = {
spaghett = {
local this =
{
gui_config =
{
spaghett =
{
undo = {}
},
poll_trusted = false
@@ -29,7 +32,8 @@ Global.register(
end
)
local spaghett_entity_blacklist = {
local spaghett_entity_blacklist =
{
['requester-chest'] = true,
['buffer-chest'] = true,
['active-chest-provider'] = true
@@ -118,7 +122,8 @@ local function trust_connected_players()
end
end
local functions = {
local functions =
{
['spectator_switch'] = function (event)
if event.element.switch_state == 'left' then
game.get_player(event.player_index).spectator = true
@@ -243,7 +248,8 @@ local functions = {
end
}
local poll_function = {
local poll_function =
{
['poll_trusted_toggle'] = function (event)
if event.element.switch_state == 'left' then
this.gui_config.poll_trusted = true
@@ -264,7 +270,8 @@ local poll_function = {
end
}
local antigrief_functions = {
local antigrief_functions =
{
['disable_antigrief'] = function (event)
local AG = Antigrief.get()
if event.element.switch_state == 'left' then
@@ -278,7 +285,8 @@ local antigrief_functions = {
end
}
local fortress_functions = {
local fortress_functions =
{
['disable_fullness'] = function (event)
local Fullness = is_loaded('modules.check_fullness')
local Module = Fullness.get()
@@ -431,7 +439,8 @@ local fortress_functions = {
end
}
local pirates_functions = {
local pirates_functions =
{
['toggle_disband'] = function (event)
local players = game.players
local Memory = storage.tokens.maps_pirates_memory
@@ -501,7 +510,8 @@ local function build_config_gui(data)
frame.clear()
local scroll_pane =
frame.add {
frame.add
{
type = 'scroll-pane',
horizontal_scroll_policy = 'never'
}
@@ -892,7 +902,7 @@ Gui.on_click(
module_name,
function (event)
local player = event.player
Gui.reload_active_tab(player)
Gui.reload_active_tab(player, nil, 'Config')
end
)

View File

@@ -9,10 +9,12 @@ local Color = require 'utils.color_presets'
local module_name = Gui.uid_name()
local this = {
local this =
{
player_group = {},
join_spam_protection = {},
tag_groups = {
tag_groups =
{
['Miner'] = { name = 'Miner', founder = 'script', description = '[img=item/electric-mining-drill]', static = true },
['Smeltery'] = { name = 'Smeltery', founder = 'script', description = '[img=item/stone-furnace]', static = true },
['Power'] = { name = 'Power', founder = 'script', description = '[img=item/big-electric-pole]', static = true },
@@ -50,7 +52,8 @@ local function build_group_gui(data)
local t = frame.add({ type = 'table', column_count = 5 })
local headings = {
local headings =
{
{ { 'gui.title' }, group_name_width },
{ { 'gui.description' }, description_width },
{ { 'gui.members' }, members_width * member_columns },
@@ -123,7 +126,8 @@ local function build_group_gui(data)
for _, p in pairs(game.connected_players) do
if group.name == this.player_group[p.name] then
l = ttt.add({ type = 'label', caption = p.name })
color = {
color =
{
r = p.color.r * 0.6 + 0.4,
g = p.color.g * 0.6 + 0.4,
b = p.color.b * 0.6 + 0.4,
@@ -303,12 +307,14 @@ local function on_gui_click(event)
return
end
this.tag_groups[new_group_name] = {
this.tag_groups[new_group_name] =
{
name = new_group_name,
description = new_group_description,
founder = player.name
}
local color = {
local color =
{
r = player.color.r * 0.7 + 0.3,
g = player.color.g * 0.7 + 0.3,
b = player.color.b * 0.7 + 0.3,
@@ -345,7 +351,8 @@ local function on_gui_click(event)
str = str .. ']'
player.tag = str
if game.tick - this.join_spam_protection[player.name] > 600 then
local color = {
local color =
{
r = player.color.r * 0.7 + 0.3,
g = player.color.g * 0.7 + 0.3,
b = player.color.b * 0.7 + 0.3,
@@ -417,7 +424,7 @@ Gui.on_click(
module_name,
function (event)
local player = event.player
Gui.reload_active_tab(player)
Gui.reload_active_tab(player, nil, 'Groups')
end
)

View File

@@ -88,14 +88,16 @@ function Public.get_score(player)
end
function Public.reset_score()
storage.custom_highscore = {
storage.custom_highscore =
{
description = 'Won rounds:',
score_list = {}
}
end
local function on_init()
storage.custom_highscore = {
storage.custom_highscore =
{
description = 'Won rounds:',
score_list = {}
}
@@ -107,7 +109,7 @@ Gui.on_click(
module_name,
function (event)
local player = event.player
Gui.reload_active_tab(player)
Gui.reload_active_tab(player, nil, 'Map Scores')
end
)

View File

@@ -380,7 +380,7 @@ Gui.on_click(
module_name,
function (event)
local player = event.player
Gui.reload_active_tab(player)
Gui.reload_active_tab(player, nil, tag)
end
)

View File

@@ -9,7 +9,8 @@ local Token = require 'utils.token'
local format_number = require 'util'.format_number
local Public = {}
local this = {
local this =
{
score_table = {},
sort_by = {}
}
@@ -24,7 +25,8 @@ Global.register(
)
local sorting_symbol = { ascending = '', descending = '' }
local building_and_mining_blacklist = {
local building_and_mining_blacklist =
{
['tile-ghost'] = true,
['entity-ghost'] = true,
['item-entity'] = true
@@ -35,7 +37,8 @@ function Public.get_table()
end
function Public.reset_tbl()
this.score_table['player'] = {
this.score_table['player'] =
{
players = {}
}
end
@@ -50,7 +53,8 @@ function Public.init_player_table(player, reset)
local tbl_force = this.score_table[player.force.name]
if reset then
tbl_force.players[player.name] = {
tbl_force.players[player.name] =
{
built_entities = 0,
deaths = 0,
killscore = 0,
@@ -70,7 +74,8 @@ function Public.init_player_table(player, reset)
if not player.name then return end
if not tbl_force.players[player.name] then
tbl_force.players[player.name] = {
tbl_force.players[player.name] =
{
built_entities = 0,
deaths = 0,
killscore = 0,
@@ -103,7 +108,8 @@ local function get_score_list(force)
end
local function get_sorted_list(method, column_name, score_list)
local comparators = {
local comparators =
{
['ascending'] = function (a, b)
return a[column_name] < b[column_name]
end,
@@ -115,7 +121,8 @@ local function get_sorted_list(method, column_name, score_list)
return score_list
end
local biters = {
local biters =
{
'small-biter',
'medium-biter',
'big-biter',
@@ -178,7 +185,8 @@ local function show_score(data)
local t = frame.add { type = 'table', column_count = 6 }
-- Score headers
local headers = {
local headers =
{
{ name = 'score_player', caption = 'Player' },
{ column = 'killscore', name = 'score_killscore', caption = 'Killscore' },
{ column = 'deaths', name = 'score_deaths', caption = 'Deaths' },
@@ -199,7 +207,8 @@ local function show_score(data)
-- Header
local label =
t.add {
t.add
{
type = 'label',
caption = cap,
name = header.name
@@ -234,13 +243,15 @@ local function show_score(data)
-- Score entries
for _, entry in pairs(score_list) do
local p = game.players[entry.name or ''] or { color = { r = 0.6, g = 0.6, b = 0.6 } }
local special_color = {
local special_color =
{
r = p.color.r * 0.6 + 0.4,
g = p.color.g * 0.6 + 0.4,
b = p.color.b * 0.6 + 0.4,
a = 1
}
local lines = {
local lines =
{
{ caption = entry.name, color = special_color },
{ caption = format_number(tonumber(entry.killscore), true) },
{ caption = format_number(tonumber(entry.deaths), true) },
@@ -252,7 +263,8 @@ local function show_score(data)
for _, column in ipairs(lines) do
local label =
column_table.add {
column_table.add
{
type = 'label',
caption = column.caption,
color = column.color or default_color
@@ -304,7 +316,8 @@ local function on_gui_click(event)
end
-- Handles click on a score header
local element_to_column = {
local element_to_column =
{
['score_killscore'] = 'killscore',
['score_deaths'] = 'deaths',
['score_built_entities'] = 'built_entities',
@@ -335,7 +348,8 @@ local function on_rocket_launched()
refresh_score_full()
end
local entity_score_values = {
local entity_score_values =
{
['behemoth-biter'] = 100,
['behemoth-spitter'] = 100,
['behemoth-worm-turret'] = 300,
@@ -366,7 +380,8 @@ local function train_type_cause(event)
return players
end
local kill_causes = {
local kill_causes =
{
['character'] = function (event)
if not event.cause.player then
return
@@ -500,7 +515,7 @@ Gui.on_click(
module_name,
function (event)
local player = event.player
Gui.reload_active_tab(player)
Gui.reload_active_tab(player, nil, 'Scoreboard')
end
)

View File

@@ -10,7 +10,8 @@ local Public = {}
local module_name = Gui.uid_name()
local ignored_stats = {
local ignored_stats =
{
['name'] = true,
['tick'] = true
}
@@ -31,7 +32,8 @@ local function show_score(data)
end
local label =
t.add {
t.add
{
type = 'label',
caption = tooltip
}
@@ -66,7 +68,8 @@ local function show_score(data)
if stat and type(stat) == 'number' then
c = format_number(stat, true)
end
local lines = {
local lines =
{
{ caption = normalized_names[name] and normalized_names[name].name or name, tooltip = normalized_names[name].tooltip or '' },
{ caption = c }
}
@@ -74,7 +77,8 @@ local function show_score(data)
for _, column in ipairs(lines) do
local l =
column_table.add {
column_table.add
{
type = 'label',
caption = column.caption,
tooltip = column.tooltip,
@@ -97,7 +101,7 @@ Gui.on_click(
module_name,
function (event)
local player = event.player
Gui.reload_active_tab(player)
Gui.reload_active_tab(player, nil, 'Statistics')
end
)

View File

@@ -3,6 +3,7 @@
local Event = require 'utils.event'
local Global = require 'utils.global'
local Core = require 'utils.core'
local round = math.round
@@ -57,21 +58,6 @@ local modifiers =
[12] = 'character_running_speed_modifier'
}
local function check_inventory_size_limit(player, modifier, value)
if not player or not player.valid then
return
end
if player.character ~= nil then
local total = player.character.character_inventory_slots_bonus + player.force.character_inventory_slots_bonus
if total >= this.rpg_inventory_slot_limit then
player[modifier] = this.rpg_inventory_slot_limit
else
player[modifier] = round(value, 4)
end
end
end
function Public.update_player_modifiers(player)
local player_modifiers = this.modifiers[player.index]
if not player_modifiers then
@@ -91,39 +77,35 @@ function Public.update_player_modifiers(player)
if player.character then
if disabled_modifiers and disabled_modifiers[k] then
player[modifier] = 0
else
if modifiers[k] == 'character_inventory_slots_bonus' and not this.creative_enabled then
check_inventory_size_limit(player, modifier, sum_value)
else
player[modifier] = round(sum_value, 4)
end
end
end
end
end
function Public.update_single_modifier(player, modifier, category, value)
local player_modifiers = this.modifiers[player.index]
if not player_modifiers then
if not player_modifiers or not modifier then
return
end
if not modifier then
return
end
for k, _ in pairs(player_modifiers) do
if modifiers[k] == modifier and player_modifiers[k] then
for key, _ in pairs(player_modifiers) do
if modifiers[key] == modifier and player_modifiers[key] then
local current_modifier = player_modifiers[key]
if category then
if value then
if modifiers[k] == 'character_inventory_slots_bonus' and not this.creative_enabled then
check_inventory_size_limit(player, modifier, value)
if modifiers[key] == 'character_inventory_slots_bonus' and not this.creative_enabled then
current_modifier[category] = math.min(value, this.rpg_inventory_slot_limit)
else
player_modifiers[k][category] = value
current_modifier[category] = value
end
else
player_modifiers[k][category] = nil
current_modifier[category] = nil
end
else
player_modifiers[k] = value
player_modifiers[key] = value
end
end
end
@@ -235,4 +217,10 @@ Event.add(defines.events.on_player_joined_game, on_player_joined_game)
Event.add(defines.events.on_player_respawned, on_player_respawned)
Event.add(defines.events.on_player_removed, on_player_removed)
Event.on_nth_tick(60, function ()
Core.iter_connected_players(function (player)
Public.update_player_modifiers(player)
end)
end)
return Public