You've already forked ComfyFactorio
mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-09-16 09:06:21 +02:00
Fixes and tweaks
This commit is contained in:
@@ -12,8 +12,6 @@ require 'maps.mountain_fortress_v3.ic.main'
|
|||||||
require 'modules.wave_defense.main'
|
require 'modules.wave_defense.main'
|
||||||
|
|
||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Color = require 'utils.color_presets'
|
|
||||||
local Core = require 'utils.core'
|
|
||||||
local Gui = require 'utils.gui'
|
local Gui = require 'utils.gui'
|
||||||
local Public = require 'maps.mountain_fortress_v3.core'
|
local Public = require 'maps.mountain_fortress_v3.core'
|
||||||
local Discord = require 'utils.discord'
|
local Discord = require 'utils.discord'
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
local Event = require 'utils.event'
|
local Event = require 'utils.event'
|
||||||
local Global = require 'utils.global'
|
local Global = require 'utils.global'
|
||||||
local Gui = require 'utils.gui'
|
local Gui = require 'utils.gui'
|
||||||
local Token = require 'utils.token'
|
local Task = require 'utils.task_token'
|
||||||
|
|
||||||
local module_name = Gui.uid_name()
|
local module_name = Gui.uid_name()
|
||||||
|
|
||||||
@@ -21,6 +21,18 @@ Global.register(
|
|||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
|
local call_active_tab_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
|
||||||
|
Gui.call_existing_tab(player, 'Map Info')
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
local Public = {}
|
local Public = {}
|
||||||
|
|
||||||
function Public.Pop_info()
|
function Public.Pop_info()
|
||||||
@@ -39,6 +51,10 @@ local function create_map_intro(data)
|
|||||||
line.style.top_margin = 4
|
line.style.top_margin = 4
|
||||||
line.style.bottom_margin = 4
|
line.style.bottom_margin = 4
|
||||||
|
|
||||||
|
if not map_info.localised_category then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local caption = map_info.main_caption or {map_info.localised_category .. '.map_info_main_caption'}
|
local caption = map_info.main_caption or {map_info.localised_category .. '.map_info_main_caption'}
|
||||||
local sub_caption = map_info.sub_caption or {map_info.localised_category .. '.map_info_sub_caption'}
|
local sub_caption = map_info.sub_caption or {map_info.localised_category .. '.map_info_sub_caption'}
|
||||||
local text = map_info.text or {map_info.localised_category .. '.map_info_text'}
|
local text = map_info.text or {map_info.localised_category .. '.map_info_text'}
|
||||||
@@ -86,12 +102,13 @@ local function create_map_intro(data)
|
|||||||
l_3.style.vertical_align = 'center'
|
l_3.style.vertical_align = 'center'
|
||||||
end
|
end
|
||||||
|
|
||||||
local create_map_intro_token = Token.register(create_map_intro)
|
local create_map_intro_token = Task.register(create_map_intro)
|
||||||
|
|
||||||
local function on_player_joined_game(event)
|
local function on_player_joined_game(event)
|
||||||
local player = game.players[event.player_index]
|
local player = game.players[event.player_index]
|
||||||
if player.online_time == 0 then
|
if player.online_time == 0 then
|
||||||
Gui.call_existing_tab(player, 'Map Info')
|
Gui.call_existing_tab(player, 'Map Info')
|
||||||
|
Task.set_timeout_in_ticks(5, call_active_tab_token, {player_index = player.index})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||||
|
@@ -18,7 +18,8 @@ commands.add_command(
|
|||||||
end
|
end
|
||||||
|
|
||||||
local param = tostring(cmd.parameter)
|
local param = tostring(cmd.parameter)
|
||||||
if param == nil then
|
if param == 'nil' then
|
||||||
|
p('[ERROR] Arguments are:\nskip\toggle_es\toggle_es_boss\nspawn\nnext\nnext_50\nnext_1500\nlog_all\ndebug_health')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -21,15 +21,6 @@ local function valid(userdata)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local function shuffle(tbl)
|
|
||||||
local size = #tbl
|
|
||||||
for i = size, 1, -1 do
|
|
||||||
local rand = math.random(size)
|
|
||||||
tbl[i], tbl[rand] = tbl[rand], tbl[i]
|
|
||||||
end
|
|
||||||
return tbl
|
|
||||||
end
|
|
||||||
|
|
||||||
local function normalize_spawn_position()
|
local function normalize_spawn_position()
|
||||||
local collapse_spawn_position = Collapse.get_position()
|
local collapse_spawn_position = Collapse.get_position()
|
||||||
local inverted = Public.get('inverted')
|
local inverted = Public.get('inverted')
|
||||||
@@ -45,43 +36,26 @@ local function normalize_spawn_position()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function find_initial_spot(surface, position)
|
local function find_initial_spot(surface, position)
|
||||||
local spot = Public.get('spot')
|
local pos = surface.find_non_colliding_position('boiler', position, 128, 1)
|
||||||
if not spot then
|
if not pos then
|
||||||
local pos = surface.find_non_colliding_position('rocket-silo', position, 128, 1)
|
pos = surface.find_non_colliding_position('boiler', position, 148, 1)
|
||||||
if not pos then
|
|
||||||
pos = surface.find_non_colliding_position('rocket-silo', position, 148, 1)
|
|
||||||
end
|
|
||||||
if not pos then
|
|
||||||
pos = surface.find_non_colliding_position('rocket-silo', position, 164, 1)
|
|
||||||
end
|
|
||||||
if not pos then
|
|
||||||
pos = surface.find_non_colliding_position('rocket-silo', position, 200, 1)
|
|
||||||
end
|
|
||||||
if not pos then
|
|
||||||
pos = position
|
|
||||||
end
|
|
||||||
|
|
||||||
if random(1, 2) == 1 then
|
|
||||||
local random_pos = {
|
|
||||||
{x = pos.x - 10, y = pos.y - 5},
|
|
||||||
{x = pos.x + 10, y = pos.y - 5},
|
|
||||||
{x = pos.x - 10, y = pos.y - 5},
|
|
||||||
{x = pos.x + 10, y = pos.y - 5}
|
|
||||||
}
|
|
||||||
local actual_pos = shuffle(random_pos)
|
|
||||||
pos = {x = actual_pos[1].x, y = actual_pos[1].y}
|
|
||||||
end
|
|
||||||
|
|
||||||
if not pos then
|
|
||||||
pos = position
|
|
||||||
end
|
|
||||||
|
|
||||||
Public.set('spot', pos)
|
|
||||||
return pos
|
|
||||||
else
|
|
||||||
spot = Public.get('spot')
|
|
||||||
return spot
|
|
||||||
end
|
end
|
||||||
|
if not pos then
|
||||||
|
pos = surface.find_non_colliding_position('boiler', position, 164, 1)
|
||||||
|
end
|
||||||
|
if not pos then
|
||||||
|
pos = surface.find_non_colliding_position('boiler', position, 200, 1)
|
||||||
|
end
|
||||||
|
if not pos then
|
||||||
|
pos = position
|
||||||
|
end
|
||||||
|
|
||||||
|
if not pos then
|
||||||
|
pos = position
|
||||||
|
end
|
||||||
|
|
||||||
|
Public.set('spot', pos)
|
||||||
|
return pos
|
||||||
end
|
end
|
||||||
|
|
||||||
local function is_closer(pos1, pos2, pos)
|
local function is_closer(pos1, pos2, pos)
|
||||||
@@ -186,20 +160,14 @@ local function get_spawn_pos()
|
|||||||
local initial_position = Public.get('spawn_position')
|
local initial_position = Public.get('spawn_position')
|
||||||
local target = Public.get('target')
|
local target = Public.get('target')
|
||||||
|
|
||||||
if initial_position.y - target.position.y > 10 then
|
local inverted = Public.get('inverted')
|
||||||
local inverted = Public.get('inverted')
|
if inverted then
|
||||||
if inverted then
|
if initial_position.y - target.position.y < -10 then
|
||||||
if random(1, 2) == 1 then
|
initial_position = {x = initial_position.x, y = initial_position.y + 50}
|
||||||
initial_position = {x = initial_position.x, y = initial_position.y + 30}
|
end
|
||||||
else
|
else
|
||||||
initial_position = {x = initial_position.x, y = initial_position.y + 20}
|
if initial_position.y - target.position.y > 10 then
|
||||||
end
|
initial_position = {x = initial_position.x, y = initial_position.y - 50}
|
||||||
else
|
|
||||||
if random(1, 2) == 1 then
|
|
||||||
initial_position = {x = initial_position.x, y = initial_position.y - 30}
|
|
||||||
else
|
|
||||||
initial_position = {x = initial_position.x, y = initial_position.y - 20}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -46,7 +46,7 @@ local this = {
|
|||||||
enable_autokick = false,
|
enable_autokick = false,
|
||||||
enable_autoban = false,
|
enable_autoban = false,
|
||||||
enable_jail = true,
|
enable_jail = true,
|
||||||
enable_capsule_warning = true,
|
enable_capsule_warning = false,
|
||||||
enable_capsule_cursor_warning = true,
|
enable_capsule_cursor_warning = true,
|
||||||
required_playtime = 2592000,
|
required_playtime = 2592000,
|
||||||
capsule_bomb_threshold = 8,
|
capsule_bomb_threshold = 8,
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
local DebugView = require 'utils.debug.main_view'
|
local DebugView = require 'utils.debug.main_view'
|
||||||
|
local Server = require 'utils.server'
|
||||||
|
|
||||||
commands.add_command(
|
commands.add_command(
|
||||||
'debug',
|
'debug',
|
||||||
@@ -14,9 +15,13 @@ commands.add_command(
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if (player.name ~= 'Gerkiz' and not _DEBUG) then
|
local secs = Server.get_current_time()
|
||||||
-- return
|
local admins = Server.get_admins_data()
|
||||||
-- end
|
|
||||||
|
if secs and not admins[player.name] then
|
||||||
|
player.print('Only admins can use this command.')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
DebugView.open_debug(player)
|
DebugView.open_debug(player)
|
||||||
end
|
end
|
||||||
|
@@ -112,7 +112,7 @@ end
|
|||||||
---@param message string
|
---@param message string
|
||||||
function Public.send_notification_raw(scenario_name, message)
|
function Public.send_notification_raw(scenario_name, message)
|
||||||
if not scenario_name then
|
if not scenario_name then
|
||||||
return error('A scenario name is required.', 2)
|
scenario_name = Server.get_server_name() or 'CommandHandler'
|
||||||
end
|
end
|
||||||
|
|
||||||
if not message then
|
if not message then
|
||||||
|
@@ -807,13 +807,14 @@ local function draw_main_frame(player)
|
|||||||
Public.get_main_frame(player).destroy()
|
Public.get_main_frame(player).destroy()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local admins = Server.get_admins_data()
|
||||||
|
|
||||||
local frame, inside_frame = Public.add_main_frame_with_toolbar(player, 'left', main_frame_name, nil, close_button_name, 'Comfy Factorio')
|
local frame, inside_frame = Public.add_main_frame_with_toolbar(player, 'left', main_frame_name, nil, close_button_name, 'Comfy Factorio')
|
||||||
local tabbed_pane = inside_frame.add({type = 'tabbed-pane', name = 'tabbed_pane'})
|
local tabbed_pane = inside_frame.add({type = 'tabbed-pane', name = 'tabbed_pane'})
|
||||||
|
|
||||||
for name, callback in pairs(tabs) do
|
for name, callback in pairs(tabs) do
|
||||||
if not settings.disabled_tabs[name] then
|
if not settings.disabled_tabs[name] then
|
||||||
|
local secs = Server.get_current_time()
|
||||||
if callback.only_server_sided then
|
if callback.only_server_sided then
|
||||||
local secs = Server.get_current_time()
|
|
||||||
if secs then
|
if secs then
|
||||||
local tab = tabbed_pane.add({type = 'tab', caption = name, name = callback.name})
|
local tab = tabbed_pane.add({type = 'tab', caption = name, name = callback.name})
|
||||||
local name_frame = tabbed_pane.add({type = 'frame', name = name, direction = 'vertical'})
|
local name_frame = tabbed_pane.add({type = 'frame', name = name, direction = 'vertical'})
|
||||||
@@ -821,9 +822,15 @@ local function draw_main_frame(player)
|
|||||||
end
|
end
|
||||||
elseif callback.admin == true then
|
elseif callback.admin == true then
|
||||||
if player.admin then
|
if player.admin then
|
||||||
local tab = tabbed_pane.add({type = 'tab', caption = name, name = callback.name})
|
if not secs then
|
||||||
local name_frame = tabbed_pane.add({type = 'frame', name = name, direction = 'vertical'})
|
local tab = tabbed_pane.add({type = 'tab', caption = name, name = callback.name})
|
||||||
tabbed_pane.add_tab(tab, name_frame)
|
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
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local tab = tabbed_pane.add({type = 'tab', caption = name, name = callback.name})
|
local tab = tabbed_pane.add({type = 'tab', caption = name, name = callback.name})
|
||||||
|
@@ -32,6 +32,7 @@ local start_data = {server_id = nil, server_name = nil, start_time = nil}
|
|||||||
local instances = {
|
local instances = {
|
||||||
data = {}
|
data = {}
|
||||||
}
|
}
|
||||||
|
local admins = {}
|
||||||
local requests = {}
|
local requests = {}
|
||||||
local jailed_data_set = 'jailed'
|
local jailed_data_set = 'jailed'
|
||||||
local data_set_handlers = {}
|
local data_set_handlers = {}
|
||||||
@@ -43,7 +44,8 @@ Global.register(
|
|||||||
server_ups = server_ups,
|
server_ups = server_ups,
|
||||||
start_data = start_data,
|
start_data = start_data,
|
||||||
requests = requests,
|
requests = requests,
|
||||||
instances = instances
|
instances = instances,
|
||||||
|
admins = admins
|
||||||
},
|
},
|
||||||
function(tbl)
|
function(tbl)
|
||||||
server_time = tbl.server_time
|
server_time = tbl.server_time
|
||||||
@@ -51,6 +53,7 @@ Global.register(
|
|||||||
start_data = tbl.start_data
|
start_data = tbl.start_data
|
||||||
requests = tbl.requests
|
requests = tbl.requests
|
||||||
instances = tbl.instances
|
instances = tbl.instances
|
||||||
|
admins = tbl.admins
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -921,6 +924,22 @@ function Public.try_get_all_data(data_set, callback_token)
|
|||||||
output_data(message)
|
output_data(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function raise_admins(data)
|
||||||
|
if not data or not next(data) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if admins and next(admins) then
|
||||||
|
for _, admin in pairs(admins) do
|
||||||
|
admins[admin] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, admin in pairs(data) do
|
||||||
|
admins[admin] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function data_set_changed(data)
|
local function data_set_changed(data)
|
||||||
local handlers = data_set_handlers[data.data_set]
|
local handlers = data_set_handlers[data.data_set]
|
||||||
if handlers == nil then
|
if handlers == nil then
|
||||||
@@ -1037,6 +1056,9 @@ end
|
|||||||
--- Called by the web server to notify the client that a data_set has changed.
|
--- Called by the web server to notify the client that a data_set has changed.
|
||||||
Public.raise_data_set = data_set_changed
|
Public.raise_data_set = data_set_changed
|
||||||
|
|
||||||
|
--- Called by the web server to notify the client that a data_set has changed.
|
||||||
|
Public.raise_admins = raise_admins
|
||||||
|
|
||||||
--- Called by the web server to notify the client that the subscribed scenario has changed.
|
--- Called by the web server to notify the client that the subscribed scenario has changed.
|
||||||
Public.raise_scenario_changed = scenario_changed
|
Public.raise_scenario_changed = scenario_changed
|
||||||
|
|
||||||
@@ -1178,6 +1200,12 @@ function Public.get_start_data()
|
|||||||
return start_data
|
return start_data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Gets the server's admin list. nil if not known.
|
||||||
|
-- @return table?
|
||||||
|
function Public.get_admins_data()
|
||||||
|
return admins
|
||||||
|
end
|
||||||
|
|
||||||
--- If the player exists bans the player.
|
--- If the player exists bans the player.
|
||||||
-- Regardless of whether or not the player exists the name is synchronized with other servers
|
-- Regardless of whether or not the player exists the name is synchronized with other servers
|
||||||
-- and stored in the database.
|
-- and stored in the database.
|
||||||
|
@@ -18,6 +18,7 @@ function ServerCommands.raise_callback(func_token, data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
ServerCommands.raise_data_set = Server.raise_data_set
|
ServerCommands.raise_data_set = Server.raise_data_set
|
||||||
|
ServerCommands.raise_admins = Server.raise_admins
|
||||||
ServerCommands.get_tracked_data_sets = Server.get_tracked_data_sets
|
ServerCommands.get_tracked_data_sets = Server.get_tracked_data_sets
|
||||||
|
|
||||||
ServerCommands.raise_scenario_changed = Server.raise_scenario_changed
|
ServerCommands.raise_scenario_changed = Server.raise_scenario_changed
|
||||||
|
Reference in New Issue
Block a user