mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-09 13:37:02 +02:00
Merge branch 'develop' into develop
This commit is contained in:
commit
ac28e269b2
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,5 @@
|
|||||||
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/danielmartin0/ComfyFactorio-Pirates.
|
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/danielmartin0/ComfyFactorio-Pirates.
|
||||||
|
|
||||||
|
|
||||||
local Global = require 'utils.global'
|
local Global = require 'utils.global'
|
||||||
-- local CoreData = require 'maps.pirates.coredata'
|
-- local CoreData = require 'maps.pirates.coredata'
|
||||||
local pirates_global_memory = {}
|
local pirates_global_memory = {}
|
||||||
@ -8,10 +7,10 @@ local Public = {}
|
|||||||
|
|
||||||
-- register only this
|
-- register only this
|
||||||
Global.register(
|
Global.register(
|
||||||
pirates_global_memory,
|
pirates_global_memory,
|
||||||
function(tbl)
|
function(tbl)
|
||||||
pirates_global_memory = tbl
|
pirates_global_memory = tbl
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
function Public.global_reset_memory()
|
function Public.global_reset_memory()
|
||||||
@ -19,121 +18,119 @@ function Public.global_reset_memory()
|
|||||||
pirates_global_memory[k] = nil
|
pirates_global_memory[k] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
pirates_global_memory.config = {}
|
pirates_global_memory.config = {}
|
||||||
pirates_global_memory.afk_player_indices = {}
|
pirates_global_memory.disband_crews = true
|
||||||
pirates_global_memory.playerindex_to_time_played_continuously = {}
|
pirates_global_memory.afk_player_indices = {}
|
||||||
pirates_global_memory.playerindex_to_captainhood_priority = {}
|
pirates_global_memory.playerindex_to_time_played_continuously = {}
|
||||||
pirates_global_memory.player_gui_memories = {}
|
pirates_global_memory.playerindex_to_captainhood_priority = {}
|
||||||
pirates_global_memory.crew_memories = {}
|
pirates_global_memory.player_gui_memories = {}
|
||||||
pirates_global_memory.crew_active_ids = {}
|
pirates_global_memory.crew_memories = {}
|
||||||
pirates_global_memory.working_id = nil --should only ever be nil, 1, 2 or 3
|
pirates_global_memory.crew_active_ids = {}
|
||||||
|
pirates_global_memory.working_id = nil --should only ever be nil, 1, 2 or 3
|
||||||
|
|
||||||
pirates_global_memory.lobby_boats = {}
|
pirates_global_memory.lobby_boats = {}
|
||||||
|
|
||||||
pirates_global_memory.active_crews_cap = nil
|
pirates_global_memory.active_crews_cap = nil
|
||||||
pirates_global_memory.crew_capacity_min = nil
|
pirates_global_memory.crew_capacity_min = nil
|
||||||
|
|
||||||
pirates_global_memory.crewproposals = {}
|
pirates_global_memory.crewproposals = {}
|
||||||
|
|
||||||
pirates_global_memory.global_delayed_tasks = {}
|
pirates_global_memory.global_delayed_tasks = {}
|
||||||
pirates_global_memory.global_buffered_tasks = {}
|
pirates_global_memory.global_buffered_tasks = {}
|
||||||
|
|
||||||
pirates_global_memory.last_players_health = {} --used to make damage reduction work somewhat properly
|
pirates_global_memory.last_players_health = {} --used to make damage reduction work somewhat properly
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Public.initialise_crew_memory(id) --mostly serves as a dev reference of memory entries
|
function Public.initialise_crew_memory(id) --mostly serves as a dev reference of memory entries
|
||||||
-- but not _everything_ is stored here, it's just a guide to the most important things
|
-- but not _everything_ is stored here, it's just a guide to the most important things
|
||||||
|
|
||||||
pirates_global_memory.crew_memories[id] = {}
|
pirates_global_memory.crew_memories[id] = {}
|
||||||
local memory = pirates_global_memory.crew_memories[id]
|
local memory = pirates_global_memory.crew_memories[id]
|
||||||
|
|
||||||
memory.secs_id = nil
|
memory.secs_id = nil
|
||||||
|
|
||||||
memory.id = nil
|
memory.id = nil
|
||||||
memory.age = nil
|
memory.age = nil
|
||||||
memory.real_age = nil
|
memory.real_age = nil
|
||||||
memory.completion_time = nil
|
memory.completion_time = nil
|
||||||
|
|
||||||
memory.force_name = nil
|
memory.force_name = nil
|
||||||
memory.enemy_force_name = nil
|
memory.enemy_force_name = nil
|
||||||
|
|
||||||
memory.original_proposal = nil
|
memory.original_proposal = nil
|
||||||
memory.name = nil
|
memory.name = nil
|
||||||
memory.difficulty_option = nil
|
memory.difficulty_option = nil
|
||||||
memory.capacity_option = nil
|
memory.capacity_option = nil
|
||||||
-- memory.mode_option = nil
|
-- memory.mode_option = nil
|
||||||
memory.difficulty = nil
|
memory.difficulty = nil
|
||||||
memory.capacity = nil
|
memory.capacity = nil
|
||||||
-- memory.mode = nil
|
-- memory.mode = nil
|
||||||
|
|
||||||
memory.destinations = nil
|
memory.destinations = nil
|
||||||
memory.currentdestination_index = nil
|
memory.currentdestination_index = nil
|
||||||
|
|
||||||
memory.hold_surface_count = nil
|
memory.hold_surface_count = nil
|
||||||
memory.merchant_ships_unlocked = nil
|
memory.merchant_ships_unlocked = nil
|
||||||
|
|
||||||
memory.boat = nil
|
memory.boat = nil
|
||||||
|
|
||||||
memory.available_classes_pool = nil
|
memory.available_classes_pool = nil
|
||||||
-- Duplicating unlocked classes data for consistency reasons (this way, entries will remain in the same order when unlocked class data changes)
|
-- Duplicating unlocked classes data for consistency reasons (this way, entries will remain in the same order when unlocked class data changes)
|
||||||
-- @TODO Might have to consider sacrificing consistency(or find a way to retain consistency) to reduce the chance of contradicting data which results in weird bugs (this happened once already)
|
-- @TODO Might have to consider sacrificing consistency(or find a way to retain consistency) to reduce the chance of contradicting data which results in weird bugs (this happened once already)
|
||||||
memory.unlocked_classes = nil
|
memory.unlocked_classes = nil
|
||||||
|
|
||||||
memory.seconds_until_alert_sound_can_be_played_again = 0
|
memory.seconds_until_alert_sound_can_be_played_again = 0
|
||||||
memory.crewplayerindices = nil
|
memory.crewplayerindices = nil
|
||||||
memory.spectatorplayerindices = nil
|
memory.spectatorplayerindices = nil
|
||||||
memory.tempbanned_from_joining_data = nil
|
memory.tempbanned_from_joining_data = nil
|
||||||
memory.playerindex_captain = nil
|
memory.playerindex_captain = nil
|
||||||
memory.captain_accrued_time_data = nil
|
memory.captain_accrued_time_data = nil
|
||||||
memory.max_players_recorded = nil
|
memory.max_players_recorded = nil
|
||||||
memory.temporarily_logged_off_characters = nil
|
memory.temporarily_logged_off_characters = nil
|
||||||
|
|
||||||
memory.speed_boost_characters = nil
|
memory.speed_boost_characters = nil
|
||||||
|
|
||||||
memory.enemyboats = nil
|
memory.enemyboats = nil
|
||||||
memory.overworld_krakens = nil
|
memory.overworld_krakens = nil
|
||||||
memory.active_sea_enemies = nil
|
memory.active_sea_enemies = nil
|
||||||
memory.kraken_stream_registrations = nil
|
memory.kraken_stream_registrations = nil
|
||||||
|
|
||||||
memory.mainshop_availability_bools = nil
|
memory.mainshop_availability_bools = nil
|
||||||
|
|
||||||
memory.delayed_tasks = nil
|
memory.delayed_tasks = nil
|
||||||
memory.buffered_tasks = nil
|
memory.buffered_tasks = nil
|
||||||
memory.game_lost = false
|
memory.game_lost = false
|
||||||
memory.game_won = false
|
memory.game_won = false
|
||||||
memory.crew_disband_tick = nil
|
memory.crew_disband_tick = nil
|
||||||
memory.destinationsvisited_indices = nil
|
memory.destinationsvisited_indices = nil
|
||||||
memory.overworldx = nil
|
memory.overworldx = nil
|
||||||
memory.overworldy = nil
|
memory.overworldy = nil
|
||||||
memory.mapbeingloadeddestination_index = nil
|
memory.mapbeingloadeddestination_index = nil
|
||||||
memory.loadingticks = nil
|
memory.loadingticks = nil
|
||||||
memory.stored_fuel = nil
|
memory.stored_fuel = nil
|
||||||
memory.spawnpoint = nil
|
memory.spawnpoint = nil
|
||||||
|
|
||||||
memory.evolution_factor = nil
|
memory.evolution_factor = nil
|
||||||
memory.scripted_biters = nil
|
memory.scripted_biters = nil
|
||||||
memory.scripted_unit_groups = nil
|
memory.scripted_unit_groups = nil
|
||||||
memory.floating_pollution = nil
|
memory.floating_pollution = nil
|
||||||
|
|
||||||
memory.playtesting_stats = nil
|
memory.playtesting_stats = nil
|
||||||
|
|
||||||
memory.cliff_explosives_acquired_once = false -- used to give tip by parrot what to do with them(only triggers from buying it in captain's cabin)
|
memory.cliff_explosives_acquired_once = false -- used to give tip by parrot what to do with them(only triggers from buying it in captain's cabin)
|
||||||
memory.hold_surface_destroyable_wooden_chests = nil
|
memory.hold_surface_destroyable_wooden_chests = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function Public.fallthrough_crew_memory() --could make this a metatable, but metatables and factorio global seem not to play nicely
|
function Public.fallthrough_crew_memory() --could make this a metatable, but metatables and factorio global seem not to play nicely
|
||||||
return {
|
return {
|
||||||
id = 0,
|
id = 0,
|
||||||
difficulty = 1,
|
difficulty = 1,
|
||||||
force_name = 'player',
|
force_name = 'player',
|
||||||
boat = {},
|
boat = {},
|
||||||
destinations = {},
|
destinations = {},
|
||||||
spectatorplayerindices = {},
|
spectatorplayerindices = {},
|
||||||
crewplayerindices = {},
|
crewplayerindices = {}
|
||||||
--[[boat = {
|
--[[boat = {
|
||||||
type = nil,
|
type = nil,
|
||||||
state = nil,
|
state = nil,
|
||||||
speed = nil,
|
speed = nil,
|
||||||
@ -151,24 +148,23 @@ function Public.fallthrough_crew_memory() --could make this a metatable, but met
|
|||||||
dockedposition = nil,
|
dockedposition = nil,
|
||||||
surface_name = nil,
|
surface_name = nil,
|
||||||
}]]
|
}]]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function Public.get_crew_memory()
|
function Public.get_crew_memory()
|
||||||
if pirates_global_memory.working_id and pirates_global_memory.working_id > 0 then
|
if pirates_global_memory.working_id and pirates_global_memory.working_id > 0 then
|
||||||
return pirates_global_memory.crew_memories[pirates_global_memory.working_id] or Public.fallthrough_crew_memory()
|
return pirates_global_memory.crew_memories[pirates_global_memory.working_id] or Public.fallthrough_crew_memory()
|
||||||
else
|
else
|
||||||
return Public.fallthrough_crew_memory()
|
return Public.fallthrough_crew_memory()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Public.get_global_memory()
|
function Public.get_global_memory()
|
||||||
return pirates_global_memory
|
return pirates_global_memory
|
||||||
end
|
end
|
||||||
|
|
||||||
function Public.set_working_id(id)
|
function Public.set_working_id(id)
|
||||||
pirates_global_memory.working_id = id
|
pirates_global_memory.working_id = id
|
||||||
end
|
end
|
||||||
|
|
||||||
return Public
|
return Public
|
||||||
|
@ -401,6 +401,32 @@ local fortress_functions = {
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local pirates_functions = {
|
||||||
|
['toggle_disband'] = function(event)
|
||||||
|
local players = game.players
|
||||||
|
local Memory = global.tokens.maps_pirates_memory
|
||||||
|
if event.element.switch_state == 'left' then
|
||||||
|
Memory.disband_crews = true
|
||||||
|
for _, player in pairs(players) do
|
||||||
|
local gui = player.gui.screen['crew_piratewindow']
|
||||||
|
if gui and gui.valid then
|
||||||
|
gui.destroy()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
get_actor(event, '[Pirates]', 'has enabled the ability to disband crews.')
|
||||||
|
else
|
||||||
|
Memory.disband_crews = false
|
||||||
|
for _, player in pairs(players) do
|
||||||
|
local gui = player.gui.screen['crew_piratewindow']
|
||||||
|
if gui and gui.valid then
|
||||||
|
gui.destroy()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
get_actor(event, '[Pirates]', 'has disabled the ability to disband crews.')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
local function add_switch(element, switch_state, name, description_main, description)
|
local function add_switch(element, switch_state, name, description_main, description)
|
||||||
local t = element.add({type = 'table', column_count = 5})
|
local t = element.add({type = 'table', column_count = 5})
|
||||||
local on_label = t.add({type = 'label', caption = 'ON'})
|
local on_label = t.add({type = 'label', caption = 'ON'})
|
||||||
@ -718,6 +744,24 @@ local function build_config_gui(data)
|
|||||||
add_switch(scroll_pane, switch_state, 'christmas_mode', 'Wintery Mode', 'On = Enables wintery mode.\nOff = Disables wintery mode.')
|
add_switch(scroll_pane, switch_state, 'christmas_mode', 'Wintery Mode', 'On = Enables wintery mode.\nOff = Disables wintery mode.')
|
||||||
scroll_pane.add({type = 'line'})
|
scroll_pane.add({type = 'line'})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if global.tokens.maps_pirates_memory then
|
||||||
|
label = scroll_pane.add({type = 'label', caption = 'Pirates Settings'})
|
||||||
|
label.style.font = 'default-bold'
|
||||||
|
label.style.padding = 0
|
||||||
|
label.style.left_padding = 10
|
||||||
|
label.style.top_padding = 10
|
||||||
|
label.style.horizontal_align = 'left'
|
||||||
|
label.style.vertical_align = 'bottom'
|
||||||
|
label.style.font_color = Color.green
|
||||||
|
|
||||||
|
local Memory = global.tokens.maps_pirates_memory
|
||||||
|
switch_state = 'right'
|
||||||
|
if Memory.disband_crews then
|
||||||
|
switch_state = 'left'
|
||||||
|
end
|
||||||
|
add_switch(scroll_pane, switch_state, 'toggle_disband', 'Disband Crews', 'On = Enables crew disband.\nOff = Disables crew disband.')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
for _, e in pairs(scroll_pane.children) do
|
for _, e in pairs(scroll_pane.children) do
|
||||||
if e.type == 'line' then
|
if e.type == 'line' then
|
||||||
@ -763,6 +807,13 @@ local function on_gui_switch_state_changed(event)
|
|||||||
end
|
end
|
||||||
fortress_functions[event.element.name](event)
|
fortress_functions[event.element.name](event)
|
||||||
return
|
return
|
||||||
|
elseif pirates_functions[event.element.name] then
|
||||||
|
local is_spamming = SpamProtection.is_spamming(player, nil, 'Config Pirates Elem')
|
||||||
|
if is_spamming then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
pirates_functions[event.element.name](event)
|
||||||
|
return
|
||||||
elseif is_loaded('utils.gui.poll') then
|
elseif is_loaded('utils.gui.poll') then
|
||||||
local is_spamming = SpamProtection.is_spamming(player, nil, 'Config Poll Elem')
|
local is_spamming = SpamProtection.is_spamming(player, nil, 'Config Poll Elem')
|
||||||
if is_spamming then
|
if is_spamming then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user