1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-16 02:47:48 +02:00

minor tweaks

This commit is contained in:
Gerkiz 2020-12-31 18:43:49 +01:00
parent 0bcd113d1f
commit 5a49113958
10 changed files with 55 additions and 44 deletions

View File

@ -48,7 +48,7 @@ local STD_BASE_CONTROL = 'lua52c+factorio+factorio_control+factorio_defines+fact
--[Assume Factorio Control stage as default]-- --[Assume Factorio Control stage as default]--
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
std = STD_CONTROL std = STD_CONTROL
globals = {'print', '_DEBUG', '_CHEATS', '_DUMP_ENV', 'ServerCommands', 'Debug', '_LIFECYCLE', '_STAGE', 'get_game_version'} globals = {'print', '_DEBUG', '_CHEATS', '_DUMP_ENV', 'ServerCommands', 'Debug', '_LIFECYCLE', '_STAGE', 'get_game_version', 'is_loaded'}
max_line_length = LINE_LENGTH max_line_length = LINE_LENGTH
not_globals = NOT_GLOBALS not_globals = NOT_GLOBALS

View File

@ -160,7 +160,7 @@ local poll_function = {
end end
end, end,
['comfy_panel_poll_no_notify_toggle'] = function(event) ['comfy_panel_poll_no_notify_toggle'] = function(event)
local poll = package.loaded['comfy_panel.poll'] local poll = is_loaded('comfy_panel.poll')
local poll_table = poll.get_no_notify_players() local poll_table = poll.get_no_notify_players()
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
poll_table[event.player_index] = false poll_table[event.player_index] = false
@ -186,7 +186,7 @@ local antigrief_functions = {
local fortress_functions = { local fortress_functions = {
['comfy_panel_disable_fullness'] = function(event) ['comfy_panel_disable_fullness'] = function(event)
local Fullness = package.loaded['modules.check_fullness'] local Fullness = is_loaded('modules.check_fullness')
local this = Fullness.get() local this = Fullness.get()
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
this.fullness_enabled = true this.fullness_enabled = true
@ -197,7 +197,7 @@ local fortress_functions = {
end end
end, end,
['comfy_panel_offline_players'] = function(event) ['comfy_panel_offline_players'] = function(event)
local WPT = package.loaded['maps.mountain_fortress_v3.table'] local WPT = is_loaded('maps.mountain_fortress_v3.table')
local this = WPT.get() local this = WPT.get()
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
this.offline_players_enabled = true this.offline_players_enabled = true
@ -208,7 +208,7 @@ local fortress_functions = {
end end
end, end,
['comfy_panel_collapse_grace'] = function(event) ['comfy_panel_collapse_grace'] = function(event)
local WPT = package.loaded['maps.mountain_fortress_v3.table'] local WPT = is_loaded('maps.mountain_fortress_v3.table')
local this = WPT.get() local this = WPT.get()
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
this.collapse_grace = true this.collapse_grace = true
@ -219,7 +219,7 @@ local fortress_functions = {
end end
end, end,
['comfy_panel_spill_items_to_surface'] = function(event) ['comfy_panel_spill_items_to_surface'] = function(event)
local WPT = package.loaded['maps.mountain_fortress_v3.table'] local WPT = is_loaded('maps.mountain_fortress_v3.table')
local this = WPT.get() local this = WPT.get()
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
this.spill_items_to_surface = true this.spill_items_to_surface = true
@ -230,7 +230,7 @@ local fortress_functions = {
end end
end, end,
['comfy_panel_void_or_tile'] = function(event) ['comfy_panel_void_or_tile'] = function(event)
local WPT = package.loaded['maps.mountain_fortress_v3.table'] local WPT = is_loaded('maps.mountain_fortress_v3.table')
local this = WPT.get() local this = WPT.get()
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
this.void_or_tile = 'out-of-map' this.void_or_tile = 'out-of-map'
@ -241,7 +241,7 @@ local fortress_functions = {
end end
end, end,
['comfy_panel_trusted_only_car_tanks'] = function(event) ['comfy_panel_trusted_only_car_tanks'] = function(event)
local WPT = package.loaded['maps.mountain_fortress_v3.table'] local WPT = is_loaded('maps.mountain_fortress_v3.table')
local this = WPT.get() local this = WPT.get()
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
this.trusted_only_car_tanks = true this.trusted_only_car_tanks = true
@ -337,8 +337,8 @@ local build_config_gui = (function(player, frame)
scroll_pane.add({type = 'line'}) scroll_pane.add({type = 'line'})
end end
if package.loaded['comfy_panel.poll'] then local poll = is_loaded('comfy_panel.poll')
local poll = package.loaded['comfy_panel.poll'] if poll then
local poll_table = poll.get_no_notify_players() local poll_table = poll.get_no_notify_players()
switch_state = 'right' switch_state = 'right'
if not poll_table[player.index] then if not poll_table[player.index] then
@ -380,7 +380,7 @@ local build_config_gui = (function(player, frame)
'Disables the Logistic System research.\nRequester, buffer or active-provider containers can not be built.' 'Disables the Logistic System research.\nRequester, buffer or active-provider containers can not be built.'
) )
if package.loaded['comfy_panel.poll'] then if poll then
scroll_pane.add({type = 'line'}) scroll_pane.add({type = 'line'})
switch_state = 'right' switch_state = 'right'
if global.comfy_panel_config.poll_trusted then if global.comfy_panel_config.poll_trusted then
@ -407,7 +407,7 @@ local build_config_gui = (function(player, frame)
add_switch(scroll_pane, switch_state, 'comfy_panel_disable_antigrief', 'Antigrief', 'Left = Enables antigrief / Right = Disables antigrief') add_switch(scroll_pane, switch_state, 'comfy_panel_disable_antigrief', 'Antigrief', 'Left = Enables antigrief / Right = Disables antigrief')
scroll_pane.add({type = 'line'}) scroll_pane.add({type = 'line'})
if package.loaded['maps.biter_battles_v2.main'] then if is_loaded('maps.biter_battles_v2.main') then
label = scroll_pane.add({type = 'label', caption = 'Biter Battles Settings'}) label = scroll_pane.add({type = 'label', caption = 'Biter Battles Settings'})
label.style.font = 'default-bold' label.style.font = 'default-bold'
label.style.padding = 0 label.style.padding = 0
@ -450,7 +450,7 @@ local build_config_gui = (function(player, frame)
scroll_pane.add({type = 'line'}) scroll_pane.add({type = 'line'})
end end
if package.loaded['maps.mountain_fortress_v3.main'] then if is_loaded('maps.mountain_fortress_v3.main') then
label = scroll_pane.add({type = 'label', caption = 'Mountain Fortress Settings'}) label = scroll_pane.add({type = 'label', caption = 'Mountain Fortress Settings'})
label.style.font = 'default-bold' label.style.font = 'default-bold'
label.style.padding = 0 label.style.padding = 0
@ -460,7 +460,7 @@ local build_config_gui = (function(player, frame)
label.style.vertical_align = 'bottom' label.style.vertical_align = 'bottom'
label.style.font_color = Color.green label.style.font_color = Color.green
local Fullness = package.loaded['modules.check_fullness'] local Fullness = is_loaded('modules.check_fullness')
local full = Fullness.get() local full = Fullness.get()
switch_state = 'right' switch_state = 'right'
if full.fullness_enabled then if full.fullness_enabled then
@ -470,7 +470,7 @@ local build_config_gui = (function(player, frame)
scroll_pane.add({type = 'line'}) scroll_pane.add({type = 'line'})
local WPT = package.loaded['maps.mountain_fortress_v3.table'] local WPT = is_loaded('maps.mountain_fortress_v3.table')
local this = WPT.get() local this = WPT.get()
switch_state = 'right' switch_state = 'right'
if this.offline_players_enabled then if this.offline_players_enabled then
@ -576,7 +576,7 @@ 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 package.loaded['comfy_panel.poll'] then elseif is_loaded('comfy_panel.poll') then
local is_spamming = SpamProtection.is_spamming(player) local is_spamming = SpamProtection.is_spamming(player)
if is_spamming then if is_spamming then
return return

View File

@ -11,6 +11,7 @@ draw_map_scores would be a function with the player and the frame as arguments
]] ]]
local Event = require 'utils.event' local Event = require 'utils.event'
local Server = require 'utils.server' local Server = require 'utils.server'
local CommandFrame = require 'commands.misc'
local SpamProtection = require 'utils.spam_protection' local SpamProtection = require 'utils.spam_protection'
comfy_panel_tabs = {} comfy_panel_tabs = {}
@ -35,7 +36,9 @@ end
function Public.comfy_panel_clear_screen_gui(player) function Public.comfy_panel_clear_screen_gui(player)
for _, child in pairs(player.gui.screen.children) do for _, child in pairs(player.gui.screen.children) do
child.visible = false if child.name ~= CommandFrame.bottom_guis_frame then
child.visible = false
end
end end
end end

View File

@ -22,7 +22,7 @@ Global.register(
local Public = {} local Public = {}
local clear_corpse_main_button_name = Gui.uid_name() local bottom_guis_frame = Gui.uid_name()
local clear_corpse_button_name = Gui.uid_name() local clear_corpse_button_name = Gui.uid_name()
local bottom_quickbar_button_name = Gui.uid_name() local bottom_quickbar_button_name = Gui.uid_name()
@ -509,7 +509,7 @@ end
local function create_frame(player, rebuild) local function create_frame(player, rebuild)
local gui = player.gui local gui = player.gui
local frame = gui.screen[clear_corpse_main_button_name] local frame = gui.screen[bottom_guis_frame]
if frame and frame.valid then if frame and frame.valid then
if rebuild then if rebuild then
frame.destroy() frame.destroy()
@ -521,7 +521,7 @@ local function create_frame(player, rebuild)
frame = frame =
player.gui.screen.add { player.gui.screen.add {
type = 'frame', type = 'frame',
name = clear_corpse_main_button_name, name = bottom_guis_frame,
direction = 'vertical' direction = 'vertical'
} }
frame.style.padding = 3 frame.style.padding = 3
@ -650,7 +650,7 @@ Event.add(
function(event) function(event)
local player = game.get_player(event.player_index) local player = game.get_player(event.player_index)
if this.activate_custom_buttons then if this.activate_custom_buttons then
local frame = player.gui.screen[clear_corpse_main_button_name] local frame = player.gui.screen[bottom_guis_frame]
if frame and frame.valid then if frame and frame.valid then
frame.destroy() frame.destroy()
end end
@ -668,4 +668,6 @@ Event.add(
end end
) )
Public.bottom_guis_frame = bottom_guis_frame
return Public return Public

View File

@ -12,7 +12,7 @@ local entity_types = {
["unit-spawner"] = true, ["unit-spawner"] = true,
} }
if package.loaded['maps.biter_hatchery.terrain'] then entity_types["unit-spawner"] = nil end if is_loaded('maps.biter_hatchery.terrain') then entity_types["unit-spawner"] = nil end
local function clean_table() local function clean_table()
--Perform a table cleanup every 1000 boosts --Perform a table cleanup every 1000 boosts
@ -84,7 +84,7 @@ local function on_entity_damaged(event)
local biter = event.entity local biter = event.entity
if not (biter and biter.valid) then return end if not (biter and biter.valid) then return end
if not entity_types[biter.type] then return end if not entity_types[biter.type] then return end
local biter_health_boost_units = global.biter_health_boost_units local biter_health_boost_units = global.biter_health_boost_units
local unit_number = biter.unit_number local unit_number = biter.unit_number
@ -111,7 +111,7 @@ local function on_entity_damaged(event)
--Reduce health pool --Reduce health pool
health_pool[1] = health_pool[1] - event.final_damage_amount health_pool[1] = health_pool[1] - event.final_damage_amount
--Set entity health relative to health pool --Set entity health relative to health pool
biter.health = health_pool[1] * health_pool[2] biter.health = health_pool[1] * health_pool[2]

View File

@ -1,19 +1,19 @@
local event = require 'utils.event' local event = require 'utils.event'
local function on_console_chat(event) local function on_console_chat(event)
if not event.message then return end if not event.message then return end
if not event.player_index then return end if not event.player_index then return end
local player = game.players[event.player_index] local player = game.players[event.player_index]
if not player.character then return end if not player.character then return end
local y_offset = -4 local y_offset = -4
if package.loaded['modules.rpg'] then y_offset = -4.5 end if is_loaded('modules.rpg') then y_offset = -4.5 end
if global.player_floaty_chat[player.index] then if global.player_floaty_chat[player.index] then
rendering.destroy(global.player_floaty_chat[player.index]) rendering.destroy(global.player_floaty_chat[player.index])
global.player_floaty_chat[player.index] = nil global.player_floaty_chat[player.index] = nil
end end
local players = {} local players = {}
for _, p in pairs(game.connected_players) do for _, p in pairs(game.connected_players) do
if player.force.index == p.force.index then if player.force.index == p.force.index then
@ -21,7 +21,7 @@ local function on_console_chat(event)
end end
end end
if #players == 0 then return end if #players == 0 then return end
global.player_floaty_chat[player.index] = rendering.draw_text{ global.player_floaty_chat[player.index] = rendering.draw_text{
text = event.message, text = event.message,
surface = player.surface, surface = player.surface,
@ -47,4 +47,4 @@ local function on_init(event)
end end
event.on_init(on_init) event.on_init(on_init)
event.add(defines.events.on_console_chat, on_console_chat) event.add(defines.events.on_console_chat, on_console_chat)

View File

@ -100,7 +100,7 @@ end
local function level_up(player) local function level_up(player)
local rpg_t = RPG.get('rpg_t') local rpg_t = RPG.get('rpg_t')
local RPG_GUI = package.loaded['modules.rpg.gui'] local RPG_GUI = is_loaded('modules.rpg.gui')
local names = RPG.auto_allocate_nodes_func local names = RPG.auto_allocate_nodes_func
local distribute_points_gain = 0 local distribute_points_gain = 0
@ -476,7 +476,7 @@ function Public.rpg_reset_player(player, one_time_reset)
player.set_controller({type = defines.controllers.god}) player.set_controller({type = defines.controllers.god})
player.create_character() player.create_character()
end end
local RPG_GUI = package.loaded['modules.rpg.gui'] local RPG_GUI = is_loaded('modules.rpg.gui')
local rpg_t = RPG.get('rpg_t') local rpg_t = RPG.get('rpg_t')
local rpg_extra = RPG.get('rpg_extra') local rpg_extra = RPG.get('rpg_extra')
if one_time_reset then if one_time_reset then

View File

@ -485,10 +485,10 @@ end
local function increase_biter_damage() local function increase_biter_damage()
local Difficulty local Difficulty
if package.loaded['modules.difficulty_vote_by_amount'] then if is_loaded('modules.difficulty_vote_by_amount') then
Difficulty = require 'modules.difficulty_vote_by_amount' Difficulty = is_loaded('modules.difficulty_vote_by_amount')
elseif package.loaded['modules.difficulty_vote'] then elseif is_loaded('modules.difficulty_vote') then
Difficulty = require 'modules.difficulty_vote' Difficulty = is_loaded('modules.difficulty_vote')
end end
if not Difficulty then if not Difficulty then
return return

View File

@ -23,3 +23,12 @@ function get_game_version()
return false return false
end end
end end
function is_loaded(module)
local res = package.loaded[module]
if res then
return res
else
return false
end
end

View File

@ -41,8 +41,7 @@ function Public.show(container)
for name, file in pairs(loaded) do for name, file in pairs(loaded) do
if not ignore[name] then if not ignore[name] then
local file_label = local file_label = left_panel.add({type = 'flow'}).add {type = 'label', name = file_label_name, caption = name}
left_panel.add({type = 'flow'}).add {type = 'label', name = file_label_name, caption = name}
Gui.set_data(file_label, file) Gui.set_data(file_label, file)
end end
end end
@ -107,8 +106,7 @@ Gui.on_click(
if file_type == 'table' then if file_type == 'table' then
for k, v in pairs(file) do for k, v in pairs(file) do
local label = local label = top_panel.add({type = 'flow'}).add {type = 'label', name = variable_label_name, caption = k}
top_panel.add({type = 'flow'}).add {type = 'label', name = variable_label_name, caption = k}
Gui.set_data(label, v) Gui.set_data(label, v)
end end
elseif file_type == 'function' then elseif file_type == 'function' then
@ -134,8 +132,7 @@ Gui.on_click(
if variable_type == 'table' then if variable_type == 'table' then
Gui.clear(top_panel) Gui.clear(top_panel)
for k, v in pairs(variable) do for k, v in pairs(variable) do
local label = local label = top_panel.add({type = 'flow'}).add {type = 'label', name = variable_label_name, caption = k}
top_panel.add({type = 'flow'}).add {type = 'label', name = variable_label_name, caption = k}
Gui.set_data(label, v) Gui.set_data(label, v)
end end
return return