You've already forked ComfyFactorio
mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-11-23 22:22:34 +02:00
Continue on refactor
Rename from CreatedEvents to CustomEvents
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,9 @@ local Task = require 'utils.task_token'
|
||||
local Scheduler = require 'utils.scheduler'
|
||||
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||
local Server = require 'utils.server'
|
||||
local Gui = require 'utils.gui'
|
||||
|
||||
local stage_gui_name = Gui.uid()
|
||||
|
||||
if not script.active_mods.quality then
|
||||
error('Quality mod is not enabled!')
|
||||
@@ -69,22 +72,52 @@ local reset_players_token =
|
||||
end
|
||||
)
|
||||
|
||||
local function get_top_frame(player, id)
|
||||
if Gui.get_mod_gui_top_frame() then
|
||||
return Gui.get_button_flow(player)[id]
|
||||
else
|
||||
return player.gui.top[id]
|
||||
end
|
||||
end
|
||||
|
||||
local function create_stage_gui(player)
|
||||
if player.gui.top.stage_gui then
|
||||
local button = get_top_frame(player, stage_gui_name)
|
||||
if button then
|
||||
return
|
||||
end
|
||||
local element = player.gui.top.add({ type = 'frame', name = 'stage_gui', caption = ' ' })
|
||||
local style = element.style
|
||||
style.minimal_height = 54
|
||||
style.maximal_height = 54
|
||||
style.minimal_width = 140
|
||||
style.maximal_width = 420
|
||||
style.top_padding = 12
|
||||
style.left_padding = 4
|
||||
style.right_padding = 4
|
||||
style.bottom_padding = 2
|
||||
style.font_color = { r = 155, g = 85, b = 25 }
|
||||
style.font = 'default-large-bold'
|
||||
|
||||
if Gui.get_mod_gui_top_frame() then
|
||||
local frame =
|
||||
Gui.add_mod_button(
|
||||
player,
|
||||
{
|
||||
type = 'frame',
|
||||
name = stage_gui_name,
|
||||
caption = ' '
|
||||
}
|
||||
)
|
||||
if frame then
|
||||
frame.style.minimal_height = 36
|
||||
frame.style.maximal_height = 36
|
||||
frame.style.minimal_width = 140
|
||||
frame.style.maximal_width = 420
|
||||
frame.style.font_color = { r = 155, g = 85, b = 25 }
|
||||
frame.style.font = 'heading-2'
|
||||
end
|
||||
else
|
||||
local element = player.gui.top.add({ type = 'frame', name = stage_gui_name, caption = ' ' })
|
||||
local style = element.style
|
||||
style.minimal_height = 54
|
||||
style.maximal_height = 54
|
||||
style.minimal_width = 140
|
||||
style.maximal_width = 420
|
||||
style.top_padding = 12
|
||||
style.left_padding = 4
|
||||
style.right_padding = 4
|
||||
style.bottom_padding = 2
|
||||
style.font_color = { r = 155, g = 85, b = 25 }
|
||||
style.font = 'default-large-bold'
|
||||
end
|
||||
end
|
||||
|
||||
local function update_stage_gui(caption_override)
|
||||
@@ -109,8 +142,9 @@ local function update_stage_gui(caption_override)
|
||||
end
|
||||
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if player.gui.top.stage_gui then
|
||||
player.gui.top.stage_gui.caption = caption_override or caption
|
||||
local frame = get_top_frame(player, stage_gui_name)
|
||||
if frame then
|
||||
frame.caption = caption_override or caption
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -321,10 +355,25 @@ local function on_tick()
|
||||
Func.check_alive_enemies()
|
||||
Func.set_multi_command()
|
||||
if not this.completed_levels[this.current_level] then
|
||||
Func.do_buried_biters()
|
||||
if not this.disable_multi_command_attack then
|
||||
Func.do_buried_biters()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if game.tick % 500 == 0 then
|
||||
if this.completed_levels[this.current_level] then
|
||||
if not this.disable_multi_command_attack then
|
||||
Func.do_buried_biters_on_completed_levels()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if this.delayed_messages[game.tick] then
|
||||
game.print(this.delayed_messages[game.tick])
|
||||
this.delayed_messages[game.tick] = nil
|
||||
end
|
||||
|
||||
if game.tick % 500 == 0 then
|
||||
Func.update_evolution_static()
|
||||
end
|
||||
|
||||
@@ -130,7 +130,7 @@ function Public.on_init()
|
||||
this.corpses_raffle = corpses_raffle
|
||||
|
||||
this.stages = {}
|
||||
this.last_level = 10
|
||||
this.last_level = 25
|
||||
local island_level = 12
|
||||
for _ = 1, this.last_level + 1 do
|
||||
this.stages[#this.stages + 1] =
|
||||
@@ -146,6 +146,13 @@ function Public.on_init()
|
||||
|
||||
this.player_options = {}
|
||||
|
||||
this.autogenerate_islands = false
|
||||
|
||||
this.calculated_snake_length = 0
|
||||
this.snake_length = 200
|
||||
|
||||
this.delayed_messages = {}
|
||||
|
||||
this.level_vectors = {}
|
||||
this.alive_boss_enemy_entities = {}
|
||||
this.current_level = 0
|
||||
@@ -235,6 +242,8 @@ function Public.on_init()
|
||||
|
||||
this.disable_multi_command_attack = false
|
||||
|
||||
this.market_target = nil
|
||||
|
||||
this.cooldown_complete_level = game.tick + 100
|
||||
this.voting_to_progress_enabled = true
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ local SpamProtection = require 'utils.spam_protection'
|
||||
local BottomFrame = require 'utils.gui.bottom_frame'
|
||||
local Gui = require 'utils.gui'
|
||||
local Color = require 'utils.color_presets'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local Public = {}
|
||||
local module_name = '[color=blue][Charging station][/color] '
|
||||
@@ -150,7 +150,7 @@ Gui.on_click(
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
|
||||
Event.add(
|
||||
CreatedEvents.events.bottom_quickbar_location_changed,
|
||||
CustomEvents.events.bottom_quickbar_location_changed,
|
||||
function (event)
|
||||
local player_index = event.player_index
|
||||
if not player_index then
|
||||
|
||||
@@ -21,7 +21,7 @@ local ICMinimap = require 'maps.mountain_fortress_v3.ic.minimap'
|
||||
local Score = require 'utils.gui.score'
|
||||
local Gui = require 'utils.gui'
|
||||
local FunctionColor = { r = 0.98, g = 0.66, b = 0.22 }
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local zone_settings = Public.zone_settings
|
||||
local remove_boost_movement_speed_on_respawn
|
||||
@@ -3583,7 +3583,7 @@ function Public.set_player_to_god(player)
|
||||
|
||||
|
||||
Event.raise(
|
||||
CreatedEvents.events.bottom_quickbar_respawn_raise,
|
||||
CustomEvents.events.bottom_quickbar_respawn_raise,
|
||||
{
|
||||
player_index = player.index
|
||||
}
|
||||
@@ -3836,7 +3836,7 @@ Event.on_nth_tick(35, do_clear_rocks_slowly)
|
||||
Event.on_nth_tick(35, do_replace_tiles_slowly)
|
||||
Event.on_nth_tick(200, do_custom_surface_funcs)
|
||||
Event.on_nth_tick(60, set_difficulty)
|
||||
Event.add(CreatedEvents.events.on_wave_created, on_wave_created)
|
||||
Event.add(CreatedEvents.events.on_primary_target_missing, on_primary_target_missing)
|
||||
Event.add(CustomEvents.events.on_wave_created, on_wave_created)
|
||||
Event.add(CustomEvents.events.on_primary_target_missing, on_primary_target_missing)
|
||||
|
||||
return Public
|
||||
|
||||
@@ -8,7 +8,7 @@ local Score = require 'utils.gui.score'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local Core = require 'utils.core'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local module_name = Gui.uid_name()
|
||||
local score_dataset = 'highscores'
|
||||
@@ -779,6 +779,6 @@ Event.on_init(on_init)
|
||||
Event.add(defines.events.on_player_left_game, on_player_left_game)
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
||||
Event.add(CreatedEvents.events.on_server_started, Public.get_scores)
|
||||
Event.add(CustomEvents.events.on_server_started, Public.get_scores)
|
||||
|
||||
return Public
|
||||
|
||||
@@ -7,7 +7,7 @@ local IC = require 'maps.mountain_fortress_v3.ic.table'
|
||||
local WPT = require 'maps.mountain_fortress_v3.table'
|
||||
local Event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local Public = {}
|
||||
local main_tile_name = 'black-refined-concrete'
|
||||
@@ -1618,7 +1618,7 @@ Public.kick_players_from_surface = kick_players_from_surface
|
||||
Public.kick_non_trusted_players_from_surface = kick_non_trusted_players_from_surface
|
||||
|
||||
Event.add(
|
||||
CreatedEvents.events.remove_surface,
|
||||
CustomEvents.events.remove_surface,
|
||||
function (event)
|
||||
local target = event.target
|
||||
if not target then
|
||||
|
||||
@@ -45,7 +45,7 @@ local OfflinePlayers = require 'modules.clear_vacant_players'
|
||||
local Beam = require 'modules.render_beam'
|
||||
local Commands = require 'utils.commands'
|
||||
local RobotLimits = require 'modules.robot_limits'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local send_ping_to_channel = Discord.channel_names.mtn_channel
|
||||
local role_to_mention = Discord.role_mentions.mtn_fortress
|
||||
@@ -642,7 +642,7 @@ function Public.reset_map(current_task)
|
||||
|
||||
|
||||
-- WD.set_es_unit_limit(400) -- moved to stateful
|
||||
Event.raise(CreatedEvents.events.on_game_reset, {})
|
||||
Event.raise(CustomEvents.events.on_game_reset, {})
|
||||
|
||||
Public.set_difficulty()
|
||||
Public.disable_creative()
|
||||
|
||||
@@ -2,7 +2,7 @@ local Public = require 'maps.mountain_fortress_v3.table'
|
||||
local RPG = require 'modules.rpg.main'
|
||||
local Event = require 'utils.event'
|
||||
local Misc = require 'utils.commands.misc'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
require 'modules.check_fullness'
|
||||
|
||||
local random = math.random
|
||||
@@ -502,7 +502,7 @@ Event.add(
|
||||
)
|
||||
|
||||
Event.add(
|
||||
CreatedEvents.events.on_entity_mined,
|
||||
CustomEvents.events.on_entity_mined,
|
||||
function (event)
|
||||
if not event then
|
||||
return
|
||||
|
||||
@@ -5,7 +5,7 @@ local Server = require 'utils.server'
|
||||
local Gui = require 'utils.gui'
|
||||
local Task = require 'utils.task_token'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local module_name = Gui.uid_name()
|
||||
local score_dataset = 'seasons'
|
||||
@@ -374,6 +374,6 @@ Gui.on_click(
|
||||
Event.add(defines.events.on_player_left_game, on_player_left_game)
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
||||
Event.add(CreatedEvents.events.on_server_started, Public.get_season_scores)
|
||||
Event.add(CustomEvents.events.on_server_started, Public.get_season_scores)
|
||||
|
||||
return Public
|
||||
|
||||
@@ -2,7 +2,7 @@ local Public = require 'maps.mountain_fortress_v3.stateful.table'
|
||||
local Event = require 'utils.event'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local Beam = require 'modules.render_beam'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
Public.stateful_gui = require 'maps.mountain_fortress_v3.stateful.gui'
|
||||
Public.stateful_blueprints = require 'maps.mountain_fortress_v3.stateful.blueprints'
|
||||
@@ -144,7 +144,7 @@ Event.on_nth_tick(
|
||||
WD.set_main_target()
|
||||
WD.build_worm_custom()
|
||||
-- WD.place_custom_nest(locomotive.surface, area[1], 'aggressors_frenzy')
|
||||
Event.raise(CreatedEvents.events.on_spawn_unit_group_simple, { fs = true, bypass = true, random_bosses = true, scale = 32, force = 'aggressors_frenzy' })
|
||||
Event.raise(CustomEvents.events.on_spawn_unit_group_simple, { fs = true, bypass = true, random_bosses = true, scale = 32, force = 'aggressors_frenzy' })
|
||||
Public.set_multi_command_final_battle()
|
||||
return
|
||||
end
|
||||
@@ -208,7 +208,7 @@ Event.add(
|
||||
)
|
||||
|
||||
Event.add(
|
||||
CreatedEvents.events.on_spell_cast_success,
|
||||
CustomEvents.events.on_spell_cast_success,
|
||||
function (event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if not player or not player.valid then
|
||||
@@ -271,7 +271,7 @@ Event.on_nth_tick(
|
||||
|
||||
Event.add(defines.events.on_pre_player_died, Public.on_pre_player_died)
|
||||
Event.add(Public.events.on_market_item_purchased, Public.on_market_item_purchased)
|
||||
Event.add(CreatedEvents.events.custom_on_entity_died, on_entity_died)
|
||||
Event.add(CustomEvents.events.custom_on_entity_died, on_entity_died)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
|
||||
return Public
|
||||
|
||||
@@ -16,7 +16,7 @@ local RPG = require 'modules.rpg.table'
|
||||
local Beam = require 'modules.render_beam'
|
||||
local Discord = require 'utils.discord'
|
||||
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local this =
|
||||
{
|
||||
@@ -2411,14 +2411,14 @@ function Public.increase_enemy_damage_and_health()
|
||||
this.enemies_boosted = true
|
||||
|
||||
if this.rounds_survived == 1 then
|
||||
Event.raise(CreatedEvents.events.on_biters_evolved, { force = game.forces.enemy, health_increase = true })
|
||||
Event.raise(CreatedEvents.events.on_biters_evolved, { force = game.forces.aggressors })
|
||||
Event.raise(CreatedEvents.events.on_biters_evolved, { force = game.forces.aggressors_frenzy })
|
||||
Event.raise(CustomEvents.events.on_biters_evolved, { force = game.forces.enemy, health_increase = true })
|
||||
Event.raise(CustomEvents.events.on_biters_evolved, { force = game.forces.aggressors })
|
||||
Event.raise(CustomEvents.events.on_biters_evolved, { force = game.forces.aggressors_frenzy })
|
||||
else
|
||||
for _ = 1, this.rounds_survived do
|
||||
Event.raise(CreatedEvents.events.on_biters_evolved, { force = game.forces.enemy, health_increase = true })
|
||||
Event.raise(CreatedEvents.events.on_biters_evolved, { force = game.forces.aggressors })
|
||||
Event.raise(CreatedEvents.events.on_biters_evolved, { force = game.forces.aggressors_frenzy })
|
||||
Event.raise(CustomEvents.events.on_biters_evolved, { force = game.forces.enemy, health_increase = true })
|
||||
Event.raise(CustomEvents.events.on_biters_evolved, { force = game.forces.aggressors })
|
||||
Event.raise(CustomEvents.events.on_biters_evolved, { force = game.forces.aggressors_frenzy })
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2484,7 +2484,7 @@ function Public.stateful_on_server_started()
|
||||
end
|
||||
|
||||
Event.add(
|
||||
CreatedEvents.events.on_server_started,
|
||||
CustomEvents.events.on_server_started,
|
||||
function ()
|
||||
if this.settings_applied then
|
||||
return
|
||||
|
||||
@@ -6,7 +6,7 @@ local Task = require 'utils.task_token'
|
||||
local Config = require 'utils.gui.config'
|
||||
local Fullness = require 'modules.check_fullness'
|
||||
local Color = require 'utils.color_presets'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local stateful_settings =
|
||||
{
|
||||
@@ -846,7 +846,7 @@ local apply_settings_token =
|
||||
)
|
||||
|
||||
Event.add(
|
||||
CreatedEvents.events.on_server_started,
|
||||
CustomEvents.events.on_server_started,
|
||||
function ()
|
||||
local start_data = Server.get_start_data()
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ local Classes = require('maps.pirates.roles.classes')
|
||||
local Token = require('utils.token')
|
||||
local Task = require('utils.task')
|
||||
local SurfacesCommon = require('maps.pirates.surfaces.common')
|
||||
local CreatedEvents = require('utils.created_events')
|
||||
local CustomEvents = require('utils.created_events')
|
||||
|
||||
local Public = {}
|
||||
local enum = {
|
||||
@@ -437,7 +437,7 @@ function Public.leave_crew(player, to_lobby, quiet)
|
||||
)
|
||||
player.force = Common.lobby_force_name
|
||||
player.create_character()
|
||||
Event.raise(CreatedEvents.events.bottom_quickbar_respawn_raise, { player_index = player.index })
|
||||
Event.raise(CustomEvents.events.bottom_quickbar_respawn_raise, { player_index = player.index })
|
||||
end
|
||||
|
||||
memory.crewplayerindices = Utils.ordered_table_with_values_removed(memory.crewplayerindices, player.index)
|
||||
|
||||
@@ -15,7 +15,7 @@ local SpamProtection = require('utils.spam_protection')
|
||||
local Utils = require('maps.pirates.utils_local')
|
||||
local CoreData = require('maps.pirates.coredata')
|
||||
local Common = require('maps.pirates.common')
|
||||
local CreatedEvents = require('utils.created_events')
|
||||
local CustomEvents = require('utils.created_events')
|
||||
|
||||
local module_name = Gui.uid_name()
|
||||
-- local module_name = 'Highscore'
|
||||
@@ -792,6 +792,6 @@ Event.on_init(on_init)
|
||||
Event.add(defines.events.on_player_left_game, on_player_left_game)
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
||||
Event.add(CreatedEvents.events.on_server_started, Public.load_in_scores)
|
||||
Event.add(CustomEvents.events.on_server_started, Public.load_in_scores)
|
||||
|
||||
return Public
|
||||
|
||||
@@ -3,7 +3,7 @@ local Server = require 'utils.server'
|
||||
local ScenarioTable = require 'maps.scrap_towny_ffa.table'
|
||||
local SoftReset = require 'utils.functions.soft_reset'
|
||||
local Token = require 'utils.token'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local math_random = math.random
|
||||
local table_shuffle = table.shuffle_table
|
||||
@@ -286,7 +286,7 @@ end
|
||||
Event.add(defines.events.on_tick, on_tick)
|
||||
|
||||
Event.add(
|
||||
CreatedEvents.events.on_server_started,
|
||||
CustomEvents.events.on_server_started,
|
||||
function ()
|
||||
local this = ScenarioTable.get_table()
|
||||
if this.settings_applied then
|
||||
|
||||
@@ -5,7 +5,7 @@ local Utils = require 'utils.common'
|
||||
local Global = require 'utils.global'
|
||||
local Token = require 'utils.token'
|
||||
local Task = require 'utils.task'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local this =
|
||||
{
|
||||
@@ -291,7 +291,7 @@ local function check_progress_and_raise_event(data)
|
||||
if not data.raised_event then
|
||||
data.raised_event = true
|
||||
Event.raise(
|
||||
CreatedEvents.events.on_entity_mined,
|
||||
CustomEvents.events.on_entity_mined,
|
||||
{
|
||||
player_index = data.player_index,
|
||||
entity = data.entity.selected,
|
||||
|
||||
@@ -9,7 +9,7 @@ local Event = require 'utils.event'
|
||||
local BottomFrame = require 'utils.gui.bottom_frame'
|
||||
local Gui = require 'utils.gui'
|
||||
local Task = require 'utils.task_token'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local auto_stash_button_name = Gui.uid_name()
|
||||
local floor = math.floor
|
||||
@@ -983,7 +983,7 @@ Event.on_init(do_whitelist)
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
|
||||
Event.add(
|
||||
CreatedEvents.events.bottom_quickbar_location_changed,
|
||||
CustomEvents.events.bottom_quickbar_location_changed,
|
||||
function (event)
|
||||
if not this.enabled then
|
||||
return
|
||||
|
||||
@@ -11,7 +11,7 @@ local Global = require 'utils.global'
|
||||
local Task = require 'utils.task'
|
||||
local Token = require 'utils.token'
|
||||
local Server = require 'utils.server'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local floor = math.floor
|
||||
local insert = table.insert
|
||||
@@ -365,13 +365,13 @@ local function on_entity_damaged(event)
|
||||
|
||||
if cause then
|
||||
if cause.valid then
|
||||
Event.raise(CreatedEvents.events.custom_on_entity_died, event)
|
||||
Event.raise(CustomEvents.events.custom_on_entity_died, event)
|
||||
biter.die(cause.force, cause)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
Event.raise(CreatedEvents.events.custom_on_entity_died, event)
|
||||
Event.raise(CustomEvents.events.custom_on_entity_died, event)
|
||||
biter.die(biter.force)
|
||||
end
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ local Alert = require 'utils.alert'
|
||||
local Event = require 'utils.event'
|
||||
local Task = require 'utils.task_token'
|
||||
local Config = require 'utils.gui.config'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local this =
|
||||
{
|
||||
@@ -163,7 +163,7 @@ function Public.dump_expired_players()
|
||||
player_inv[4] = target.get_inventory(defines.inventory.character_ammo)
|
||||
player_inv[5] = target.get_inventory(defines.inventory.character_trash)
|
||||
if this.offline_players_surface_removal then
|
||||
Event.raise(CreatedEvents.events.remove_surface, { target = target })
|
||||
Event.raise(CustomEvents.events.remove_surface, { target = target })
|
||||
end
|
||||
|
||||
local found_items = false
|
||||
|
||||
@@ -79,6 +79,14 @@ Global.register(
|
||||
end
|
||||
)
|
||||
|
||||
local function get_top_frame(player, id)
|
||||
if Gui.get_mod_gui_top_frame() then
|
||||
return Gui.get_button_flow(player)[id]
|
||||
else
|
||||
return player.gui.top[id]
|
||||
end
|
||||
end
|
||||
|
||||
local function clear_main_frame(player)
|
||||
local screen = player.gui.center
|
||||
if screen[main_frame_name] and screen[main_frame_name].valid then
|
||||
@@ -87,9 +95,9 @@ local function clear_main_frame(player)
|
||||
end
|
||||
|
||||
local function clear_top_frame(player)
|
||||
local top = player.gui.top
|
||||
if top[top_button_name] and top[top_button_name].valid then
|
||||
top[top_button_name].destroy()
|
||||
local top = get_top_frame(player, top_button_name)
|
||||
if top and top.valid then
|
||||
top.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -101,25 +109,45 @@ function Public.difficulty_gui()
|
||||
local tooltip = 'Current difficulty of the map is ' .. this.difficulties[this.index].name .. '.'
|
||||
|
||||
for _, player in pairs(game.connected_players) do
|
||||
local top = player.gui.top
|
||||
if top[top_button_name] then
|
||||
top[top_button_name].caption = this.difficulties[this.index].name
|
||||
top[top_button_name].tooltip = this.button_tooltip or tooltip
|
||||
top[top_button_name].style.font_color = this.difficulties[this.index].print_color
|
||||
else
|
||||
local b =
|
||||
top.add
|
||||
local top = get_top_frame(player, top_button_name)
|
||||
if Gui.get_mod_gui_top_frame() then
|
||||
local button = Gui.add_mod_button(
|
||||
player,
|
||||
{
|
||||
type = 'button',
|
||||
name = top_button_name,
|
||||
caption = this.difficulties[this.index].name,
|
||||
tooltip = tooltip,
|
||||
name = top_button_name
|
||||
style = Gui.button_style
|
||||
}
|
||||
b.style.font = 'heading-2'
|
||||
b.style.font_color = this.difficulties[this.index].print_color
|
||||
b.style.minimal_height = this.button_height
|
||||
b.style.maximal_height = this.button_height
|
||||
b.style.minimal_width = this.gui_width
|
||||
)
|
||||
if button then
|
||||
button.style.font_color = this.difficulties[this.index].print_color
|
||||
button.style.font = 'heading-2'
|
||||
button.style.minimal_height = 36
|
||||
button.style.maximal_height = 36
|
||||
button.style.minimal_width = this.gui_width
|
||||
end
|
||||
else
|
||||
if top then
|
||||
top.caption = this.difficulties[this.index].name
|
||||
top.tooltip = this.button_tooltip or tooltip
|
||||
top.style.font_color = this.difficulties[this.index].print_color
|
||||
else
|
||||
local b =
|
||||
player.gui.top.add
|
||||
{
|
||||
type = 'button',
|
||||
caption = this.difficulties[this.index].name,
|
||||
tooltip = tooltip,
|
||||
name = top_button_name
|
||||
}
|
||||
b.style.font = 'heading-2'
|
||||
b.style.font_color = this.difficulties[this.index].print_color
|
||||
b.style.minimal_height = this.button_height
|
||||
b.style.maximal_height = this.button_height
|
||||
b.style.minimal_width = this.gui_width
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--luacheck: ignore
|
||||
local Event = require 'utils.event'
|
||||
local HDT = require 'modules.hidden_dimension.table'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local Public = {}
|
||||
|
||||
@@ -691,7 +691,7 @@ Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_tick, on_tick)
|
||||
Event.add(defines.events.on_research_finished, on_research_finished)
|
||||
Event.add(defines.events.on_entity_cloned, on_entity_cloned)
|
||||
Event.add(CreatedEvents.events.reset_game, reset_surface)
|
||||
Event.add(CreatedEvents.events.init_surfaces, create_underground_surfaces)
|
||||
Event.add(CustomEvents.events.reset_game, reset_surface)
|
||||
Event.add(CustomEvents.events.init_surfaces, create_underground_surfaces)
|
||||
|
||||
return Public
|
||||
|
||||
@@ -10,7 +10,7 @@ local StatData = require 'utils.datastore.statistics'
|
||||
local WD = require 'modules.wave_defense.table'
|
||||
local Math2D = require 'math2d'
|
||||
local Color = require 'utils.color_presets'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
StatData.add_normalize('spells', 'Spells casted')
|
||||
|
||||
@@ -1044,7 +1044,7 @@ local function on_player_used_capsule_custom(event)
|
||||
rpg_t.amount = 1
|
||||
end
|
||||
|
||||
Event.raise(CreatedEvents.events.on_spell_cast_success, { player_index = player.index, spell_name = spell.entityName, amount = rpg_t.amount })
|
||||
Event.raise(CustomEvents.events.on_spell_cast_success, { player_index = player.index, spell_name = spell.entityName, amount = rpg_t.amount })
|
||||
|
||||
StatData.get_data(player):increase('spells')
|
||||
|
||||
@@ -1224,7 +1224,7 @@ local function on_player_used_capsule(event)
|
||||
rpg_t.amount = 1
|
||||
end
|
||||
|
||||
Event.raise(CreatedEvents.events.on_spell_cast_success, { player_index = player.index, spell_name = spell.entityName, amount = rpg_t.amount })
|
||||
Event.raise(CustomEvents.events.on_spell_cast_success, { player_index = player.index, spell_name = spell.entityName, amount = rpg_t.amount })
|
||||
|
||||
StatData.get_data(player):increase('spells')
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ local Global = require 'utils.global'
|
||||
local Task = require 'utils.task_token'
|
||||
local Event = require 'utils.event'
|
||||
local Gui = require 'utils.gui'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local this =
|
||||
{
|
||||
@@ -98,6 +99,31 @@ Public.auto_allocate_nodes_func =
|
||||
'Vitality'
|
||||
}
|
||||
|
||||
local get_value_from_player_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 key = event.key
|
||||
if not key then
|
||||
return
|
||||
end
|
||||
|
||||
return Public.get_value_from_player(player.index, key)
|
||||
end
|
||||
)
|
||||
|
||||
local delay_register_token =
|
||||
Task.register(
|
||||
function ()
|
||||
Event.raise(CustomEvents.events.on_rpg_callback_added, { token = get_value_from_player_token })
|
||||
end
|
||||
)
|
||||
|
||||
function Public.reset_table(migrate)
|
||||
this.rpg_extra.debug = false
|
||||
this.rpg_extra.breached_walls = 1
|
||||
@@ -653,8 +679,6 @@ function Public.get_vitality_custom_callback()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function Public.migrate_to_new_version()
|
||||
-- Public.reset_table(true)
|
||||
if this.rpg_spells then
|
||||
@@ -687,6 +711,8 @@ Public.cooldown_indicator_name = cooldown_indicator_name
|
||||
|
||||
local on_init = function ()
|
||||
Public.reset_table()
|
||||
-- Apparently this does not work immediately, so we need to wait for 1 tick.
|
||||
Task.set_timeout_in_ticks(1, delay_register_token)
|
||||
end
|
||||
|
||||
Event.on_init(on_init)
|
||||
|
||||
@@ -2,7 +2,7 @@ local Public = require 'modules.wave_defense.table'
|
||||
local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local BiterHealthBooster = require 'modules.biter_health_booster_v2'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local this = {}
|
||||
|
||||
@@ -101,7 +101,7 @@ local function spawn_biters(data)
|
||||
BiterHealthBooster.add_unit(unit, final_health)
|
||||
end
|
||||
|
||||
Event.raise(CreatedEvents.events.on_entity_created, { entity = unit, boss_unit = false })
|
||||
Event.raise(CustomEvents.events.on_entity_created, { entity = unit, boss_unit = false })
|
||||
end
|
||||
|
||||
local function spawn_worms(data)
|
||||
|
||||
@@ -6,7 +6,7 @@ local Public = require 'modules.wave_defense.table'
|
||||
local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||
local Beams = require 'modules.render_beam'
|
||||
local Server = require 'utils.server'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local random = math.random
|
||||
local abs = math.abs
|
||||
@@ -1162,7 +1162,7 @@ function Public._esp:work(tick)
|
||||
self.last_command = tick + 500
|
||||
|
||||
if this.target_settings.main_target and this.target_settings.main_target.valid and this.target_settings.main_target.name == 'character' then
|
||||
Event.raise(CreatedEvents.events.on_primary_target_missing)
|
||||
Event.raise(CustomEvents.events.on_primary_target_missing)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1216,12 +1216,12 @@ end
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
||||
Event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
||||
Event.add(CreatedEvents.events.on_wave_created, on_wave_created)
|
||||
Event.add(CreatedEvents.events.on_unit_group_created, on_unit_group_created)
|
||||
Event.add(CreatedEvents.events.on_entity_created, on_entity_created)
|
||||
Event.add(CreatedEvents.events.on_target_aquired, on_target_aquired)
|
||||
Event.add(CreatedEvents.events.on_evolution_factor_changed, on_evolution_factor_changed)
|
||||
Event.add(CreatedEvents.events.on_game_reset, on_init)
|
||||
Event.add(CustomEvents.events.on_wave_created, on_wave_created)
|
||||
Event.add(CustomEvents.events.on_unit_group_created, on_unit_group_created)
|
||||
Event.add(CustomEvents.events.on_entity_created, on_entity_created)
|
||||
Event.add(CustomEvents.events.on_target_aquired, on_target_aquired)
|
||||
Event.add(CustomEvents.events.on_evolution_factor_changed, on_evolution_factor_changed)
|
||||
Event.add(CustomEvents.events.on_game_reset, on_init)
|
||||
Event.on_nth_tick(100, check_states)
|
||||
|
||||
--- This gets values from our table
|
||||
|
||||
@@ -5,7 +5,7 @@ local Difficulty = require 'modules.difficulty_vote_by_amount'
|
||||
local Alert = require 'utils.alert'
|
||||
local Server = require 'utils.server'
|
||||
local Collapse = require 'modules.collapse'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
Collapse.read_tables_only = true
|
||||
|
||||
@@ -383,7 +383,7 @@ local function set_main_target()
|
||||
end
|
||||
|
||||
Public.set('target', sec_target)
|
||||
raise(CreatedEvents.events.on_target_aquired, { target = target })
|
||||
raise(CustomEvents.events.on_target_aquired, { target = target })
|
||||
Public.debug_print('set_main_target -- New main target ' .. sec_target.name .. ' at position x' .. sec_target.position.x .. ' y' .. sec_target.position.y .. ' selected.')
|
||||
end
|
||||
|
||||
@@ -434,7 +434,7 @@ local function set_enemy_evolution()
|
||||
|
||||
enemy.set_evolution_factor(evolution_factor, surface_index)
|
||||
|
||||
raise(CreatedEvents.events.on_evolution_factor_changed, { evolution_factor = evolution_factor })
|
||||
raise(CustomEvents.events.on_evolution_factor_changed, { evolution_factor = evolution_factor })
|
||||
end
|
||||
|
||||
local function can_units_spawn()
|
||||
@@ -769,7 +769,7 @@ local function set_multi_command()
|
||||
|
||||
local target = Public.get('target')
|
||||
if not valid(target) then
|
||||
Event.raise(CreatedEvents.events.on_primary_target_missing)
|
||||
Event.raise(CustomEvents.events.on_primary_target_missing)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -876,7 +876,7 @@ local function set_next_wave()
|
||||
Public.set('next_wave', game.tick + wave_interval)
|
||||
end
|
||||
|
||||
raise(CreatedEvents.events.on_wave_created, event_data)
|
||||
raise(CustomEvents.events.on_wave_created, event_data)
|
||||
end
|
||||
|
||||
local function reform_group(group)
|
||||
@@ -976,7 +976,7 @@ local function get_main_command(group)
|
||||
|
||||
local target = Public.get('target')
|
||||
if not valid(target) then
|
||||
Event.raise(CreatedEvents.events.on_primary_target_missing)
|
||||
Event.raise(CustomEvents.events.on_primary_target_missing)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -1148,7 +1148,7 @@ local function give_side_commands_to_group()
|
||||
|
||||
local target = Public.get('target')
|
||||
if not valid(target) then
|
||||
Event.raise(CreatedEvents.events.on_primary_target_missing)
|
||||
Event.raise(CustomEvents.events.on_primary_target_missing)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -1167,12 +1167,12 @@ end
|
||||
local function give_main_command_to_group()
|
||||
local target = Public.get('target')
|
||||
if not valid(target) then
|
||||
Event.raise(CreatedEvents.events.on_primary_target_missing)
|
||||
Event.raise(CustomEvents.events.on_primary_target_missing)
|
||||
return
|
||||
end
|
||||
|
||||
-- This is called even if the target is valid
|
||||
Event.raise(CreatedEvents.events.on_primary_target_missing)
|
||||
Event.raise(CustomEvents.events.on_primary_target_missing)
|
||||
|
||||
local generated_units = Public.get('generated_units')
|
||||
for _, group in pairs(generated_units.unit_groups) do
|
||||
@@ -1200,7 +1200,7 @@ local function spawn_unit_group(fs, only_bosses)
|
||||
local target = Public.get('target')
|
||||
if not valid(target) then
|
||||
Public.debug_print('spawn_unit_group - Target was not valid?')
|
||||
Event.raise(CreatedEvents.events.on_primary_target_missing)
|
||||
Event.raise(CustomEvents.events.on_primary_target_missing)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -1294,7 +1294,7 @@ local function spawn_unit_group(fs, only_bosses)
|
||||
end
|
||||
unit_group.add_member(biter)
|
||||
|
||||
raise(CreatedEvents.events.on_entity_created, { entity = biter, boss_unit = false })
|
||||
raise(CustomEvents.events.on_entity_created, { entity = biter, boss_unit = false })
|
||||
-- command_to_side_target(unit_group)
|
||||
end
|
||||
end
|
||||
@@ -1324,7 +1324,7 @@ local function spawn_unit_group(fs, only_bosses)
|
||||
break
|
||||
end
|
||||
unit_group.add_member(biter)
|
||||
raise(CreatedEvents.events.on_entity_created, { entity = biter, boss_unit = true })
|
||||
raise(CustomEvents.events.on_entity_created, { entity = biter, boss_unit = true })
|
||||
end
|
||||
Public.set('boss_wave', false)
|
||||
end
|
||||
@@ -1345,7 +1345,7 @@ local function spawn_unit_group(fs, only_bosses)
|
||||
break
|
||||
end
|
||||
unit_group.add_member(biter)
|
||||
raise(CreatedEvents.events.on_entity_created, { entity = biter, boss_unit = true })
|
||||
raise(CustomEvents.events.on_entity_created, { entity = biter, boss_unit = true })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1356,7 +1356,7 @@ local function spawn_unit_group(fs, only_bosses)
|
||||
Public.set('random_group', unit_group)
|
||||
end
|
||||
Public.set('spot', 'nil')
|
||||
raise(CreatedEvents.events.on_unit_group_created, event_data)
|
||||
raise(CustomEvents.events.on_unit_group_created, event_data)
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -1364,7 +1364,7 @@ local function spawn_unit_group_simple(fs)
|
||||
local target = Public.get('target')
|
||||
if not valid(target) then
|
||||
Public.debug_print('spawn_unit_group_simple - Target was not valid?')
|
||||
Event.raise(CreatedEvents.events.on_primary_target_missing)
|
||||
Event.raise(CustomEvents.events.on_primary_target_missing)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -1411,7 +1411,7 @@ local function spawn_unit_group_simple(fs)
|
||||
if biter then
|
||||
s = s + 1
|
||||
unit_group.add_member(biter)
|
||||
raise(CreatedEvents.events.on_entity_created, { entity = biter, boss_unit = is_boss })
|
||||
raise(CustomEvents.events.on_entity_created, { entity = biter, boss_unit = is_boss })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1438,7 +1438,7 @@ local function check_group_positions()
|
||||
local generated_units = Public.get('generated_units')
|
||||
local target = Public.get('target')
|
||||
if not valid(target) then
|
||||
Event.raise(CreatedEvents.events.on_primary_target_missing)
|
||||
Event.raise(CustomEvents.events.on_primary_target_missing)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -1586,7 +1586,7 @@ Event.on_nth_tick(30,
|
||||
)
|
||||
|
||||
Event.add(
|
||||
CreatedEvents.events.on_biters_evolved,
|
||||
CustomEvents.events.on_biters_evolved,
|
||||
function (event)
|
||||
if not event then
|
||||
event = { force = game.forces.enemy }
|
||||
@@ -1600,8 +1600,8 @@ Event.add(
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(CreatedEvents.events.on_spawn_unit_group, spawn_unit_group)
|
||||
Event.add(CreatedEvents.events.on_spawn_unit_group_simple, spawn_unit_group_simple)
|
||||
Event.add(CustomEvents.events.on_spawn_unit_group, spawn_unit_group)
|
||||
Event.add(CustomEvents.events.on_spawn_unit_group_simple, spawn_unit_group_simple)
|
||||
|
||||
Event.on_nth_tick(
|
||||
100,
|
||||
|
||||
@@ -4,7 +4,7 @@ local BiterHealthBooster = require 'modules.biter_health_booster_v2'
|
||||
local Token = require 'utils.token'
|
||||
local Task = require 'utils.task_token'
|
||||
local Misc = require 'utils.commands.misc'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local raise = Event.raise
|
||||
local round = math.round
|
||||
@@ -445,7 +445,7 @@ local function spawn_unit_spawner_inhabitants(entity)
|
||||
)
|
||||
end
|
||||
if biter and biter.valid then
|
||||
raise(CreatedEvents.events.on_entity_created, { entity = biter, boss_unit = false })
|
||||
raise(CustomEvents.events.on_entity_created, { entity = biter, boss_unit = false })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,8 @@ local Event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
local Discord = require 'utils.discord_handler'
|
||||
|
||||
local commands = {
|
||||
local commands =
|
||||
{
|
||||
['editor'] = true,
|
||||
['open'] = true,
|
||||
['cheat'] = true,
|
||||
@@ -15,7 +16,8 @@ local commands = {
|
||||
['debug'] = true
|
||||
}
|
||||
|
||||
local title_to_command = {
|
||||
local title_to_command =
|
||||
{
|
||||
['editor'] = 'Editor',
|
||||
['open'] = 'Open',
|
||||
['cheat'] = 'Cheat',
|
||||
@@ -54,7 +56,8 @@ local function on_console_command(event)
|
||||
title = title_to_command[cmd],
|
||||
description = '/' .. cmd .. ' was used',
|
||||
color = 'warning',
|
||||
fields = {
|
||||
fields =
|
||||
{
|
||||
{
|
||||
title = 'Server',
|
||||
description = server_name,
|
||||
@@ -79,7 +82,7 @@ Event.add(defines.events.on_console_command, on_console_command)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_promoted,
|
||||
function(event)
|
||||
function (event)
|
||||
local admins = Server.get_admins_data()
|
||||
local player = game.get_player(event.player_index)
|
||||
local server_name = Server.get_server_name() or 'CommandHandler'
|
||||
@@ -89,7 +92,8 @@ Event.add(
|
||||
title = 'Admin promotion',
|
||||
description = player.name .. ' was promoted.',
|
||||
color = 'success',
|
||||
fields = {
|
||||
fields =
|
||||
{
|
||||
{
|
||||
title = 'Server',
|
||||
description = server_name,
|
||||
@@ -111,7 +115,7 @@ Event.add(
|
||||
)
|
||||
Event.add(
|
||||
defines.events.on_player_demoted,
|
||||
function(event)
|
||||
function (event)
|
||||
local player = game.get_player(event.player_index)
|
||||
local server_name = Server.get_server_name() or 'CommandHandler'
|
||||
|
||||
@@ -120,7 +124,8 @@ Event.add(
|
||||
title = 'Admin demotion',
|
||||
description = player.name .. ' was demoted.',
|
||||
color = 'warning',
|
||||
fields = {
|
||||
fields =
|
||||
{
|
||||
{
|
||||
title = 'Server',
|
||||
description = server_name,
|
||||
@@ -134,7 +139,7 @@ Event.add(
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_kicked,
|
||||
function(event)
|
||||
function (event)
|
||||
local player = game.get_player(event.player_index)
|
||||
local server_name = Server.get_server_name() or 'CommandHandler'
|
||||
|
||||
@@ -143,7 +148,8 @@ Event.add(
|
||||
title = 'Player kicked',
|
||||
description = player.name .. ' was kicked.',
|
||||
color = 'danger',
|
||||
fields = {
|
||||
fields =
|
||||
{
|
||||
{
|
||||
title = 'Server',
|
||||
description = server_name,
|
||||
|
||||
@@ -1076,6 +1076,8 @@ local function on_player_deconstructed_area(event)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
|
||||
local area = event.area
|
||||
local count = surface.count_entities_filtered({ area = area, type = 'resource', invert = true })
|
||||
local max_count = 0
|
||||
@@ -1101,9 +1103,6 @@ local function on_player_deconstructed_area(event)
|
||||
area = area,
|
||||
force = player.force
|
||||
}
|
||||
if not is_trusted then
|
||||
return
|
||||
end
|
||||
|
||||
local msg = '[Deconstruct] ' .. player.name .. ' tried to deconstruct: ' .. count .. ' entities!'
|
||||
Utils.print_to(nil, msg)
|
||||
|
||||
@@ -3,8 +3,10 @@ local Server = require 'utils.server'
|
||||
local Color = require 'utils.color_presets'
|
||||
local Global = require 'utils.global'
|
||||
|
||||
local this = {
|
||||
settings = {
|
||||
local this =
|
||||
{
|
||||
settings =
|
||||
{
|
||||
enable_classic_print = false
|
||||
}
|
||||
}
|
||||
@@ -18,50 +20,101 @@ Global.register(
|
||||
|
||||
local Public = {}
|
||||
|
||||
local brain = {
|
||||
local brain =
|
||||
{
|
||||
[1] = { 'Our Discord server is at: https://getcomfy.eu/discord' },
|
||||
[2] = {
|
||||
[2] =
|
||||
{
|
||||
'Need an admin? Join our discord at: https://getcomfy.eu/discord,',
|
||||
'and report it in #i-need-halp',
|
||||
'If you have played for more than 5h in our maps then,',
|
||||
'you are eligible to run the command /jail and /free'
|
||||
'If you have played for some time in our maps then,',
|
||||
'you are eligible to run the command /jail, /free and /undo_player_actions'
|
||||
},
|
||||
[3] = { 'Scenario repository for download:', 'https://github.com/ComfyFactory/ComfyFactorio' },
|
||||
[4] = {
|
||||
[4] =
|
||||
{
|
||||
'If you feel like the server is lagging, run the following command:',
|
||||
'/server-ups',
|
||||
'This will display the server UPS on your top right screen.'
|
||||
},
|
||||
[5] = {
|
||||
[5] =
|
||||
{
|
||||
"If you're not trusted - ask an admin to trust you."
|
||||
}
|
||||
}
|
||||
|
||||
local links = {
|
||||
local links =
|
||||
{
|
||||
['admin'] = brain[2],
|
||||
['admins'] = brain[2],
|
||||
['administrator'] = brain[2],
|
||||
['discord'] = brain[1],
|
||||
['download'] = brain[3],
|
||||
['github'] = brain[3],
|
||||
['greifer'] = brain[2],
|
||||
['moderator'] = brain[2],
|
||||
['mod'] = brain[2],
|
||||
['mods'] = brain[2],
|
||||
['staff'] = brain[2],
|
||||
['grief'] = brain[2],
|
||||
['griefer'] = brain[2],
|
||||
['griefing'] = brain[2],
|
||||
['mod'] = brain[2],
|
||||
['moderator'] = brain[2],
|
||||
['scenario'] = brain[3],
|
||||
['stealing'] = brain[2],
|
||||
['greifer'] = brain[2],
|
||||
['steal'] = brain[2],
|
||||
['stole'] = brain[2],
|
||||
['stealing'] = brain[2],
|
||||
['troll'] = brain[2],
|
||||
['stutter'] = brain[4],
|
||||
['freeze'] = brain[4],
|
||||
['trolling'] = brain[2],
|
||||
['report'] = brain[2],
|
||||
['abuse'] = brain[2],
|
||||
['cheat'] = brain[2],
|
||||
['cheater'] = brain[2],
|
||||
['cheating'] = brain[2],
|
||||
['hack'] = brain[2],
|
||||
['hacker'] = brain[2],
|
||||
['help'] = brain[2],
|
||||
['need help'] = brain[2],
|
||||
['jail'] = brain[2],
|
||||
['undo'] = brain[2],
|
||||
['undo_player_actions'] = brain[2],
|
||||
|
||||
['discord'] = brain[1],
|
||||
['comfy'] = brain[1],
|
||||
['server'] = brain[1],
|
||||
['chat'] = brain[1],
|
||||
['voice'] = brain[1],
|
||||
['link'] = brain[1],
|
||||
|
||||
['download'] = brain[3],
|
||||
['downloads'] = brain[3],
|
||||
['github'] = brain[3],
|
||||
['repo'] = brain[3],
|
||||
['repository'] = brain[3],
|
||||
['scenario'] = brain[3],
|
||||
['map'] = brain[3],
|
||||
['maps'] = brain[3],
|
||||
['files'] = brain[3],
|
||||
|
||||
['lag'] = brain[4],
|
||||
['lagging'] = brain[4],
|
||||
['stutter'] = brain[4],
|
||||
['freeze'] = brain[4],
|
||||
['freezing'] = brain[4],
|
||||
['fps'] = brain[4],
|
||||
['ups'] = brain[4],
|
||||
['desync'] = brain[4],
|
||||
['latency'] = brain[4],
|
||||
['delay'] = brain[4],
|
||||
['slow'] = brain[4],
|
||||
['performance'] = brain[4],
|
||||
|
||||
['trust'] = brain[5],
|
||||
['trusted'] = brain[5],
|
||||
['untrusted'] = brain[5]
|
||||
['untrusted'] = brain[5],
|
||||
['not trusted'] = brain[5],
|
||||
['permission'] = brain[5],
|
||||
['permissions'] = brain[5],
|
||||
['build'] = brain[5],
|
||||
['can’t build'] = brain[5],
|
||||
['cant build'] = brain[5],
|
||||
}
|
||||
|
||||
|
||||
local function on_player_created(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
if this.settings.enable_classic_print then
|
||||
|
||||
@@ -39,7 +39,7 @@ local output =
|
||||
admin_is_required = 'This command requires admin permissions to run.',
|
||||
supporter_is_required = 'This command requires supporter permissions to run.',
|
||||
trusted_is_required = 'This command requires trusted permissions to run.',
|
||||
playtime_is_required = 'This command requires a minimum playtime to run.',
|
||||
playtime_is_required = 'This command requires a minimum playtime of %s to run.',
|
||||
param_is_required = 'This command requires a parameter to run.',
|
||||
command_failed = 'Command failed to run.',
|
||||
command_success = 'Command ran successfully.',
|
||||
@@ -198,12 +198,12 @@ local function execute(event)
|
||||
if (check_playtime and not is_server) and Core.validate_player(player) then
|
||||
local playtime = Session.get_session_player(player)
|
||||
if not playtime then
|
||||
reject(output.trusted_is_required)
|
||||
reject(string.format(output.playtime_is_required, Core.get_formatted_playtime(check_playtime)))
|
||||
return
|
||||
end
|
||||
|
||||
if playtime < check_playtime then
|
||||
reject(output.playtime_is_required)
|
||||
reject(string.format(output.playtime_is_required, Core.get_formatted_playtime(check_playtime)))
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -458,7 +458,6 @@ function Public:require_admin()
|
||||
return self
|
||||
end
|
||||
|
||||
--- Requires that the command is not run from a player.
|
||||
---@return MetaCommand
|
||||
function Public:require_server()
|
||||
self.check_server = true
|
||||
|
||||
@@ -12,7 +12,7 @@ local Discord = require 'utils.discord_handler'
|
||||
local Commands = require 'utils.commands'
|
||||
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
|
||||
local Task = require 'utils.task_token'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local this =
|
||||
{
|
||||
@@ -732,7 +732,7 @@ Gui.on_click(
|
||||
)
|
||||
|
||||
Event.add(
|
||||
CreatedEvents.events.bottom_quickbar_location_changed,
|
||||
CustomEvents.events.bottom_quickbar_location_changed,
|
||||
function (event)
|
||||
if not this.enabled then
|
||||
return
|
||||
|
||||
@@ -27,6 +27,9 @@ local Public =
|
||||
on_gui_closed_main_frame = Event.generate_event_name('on_gui_closed_main_frame'),
|
||||
on_player_removed = Event.generate_event_name('on_player_removed'),
|
||||
|
||||
-- rpg
|
||||
on_rpg_callback_added = Event.generate_event_name('on_rpg_callback_added'),
|
||||
|
||||
-- config events
|
||||
on_config_changed = Event.generate_event_name('on_config_changed'),
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ local table = require 'utils.table'
|
||||
local Gui = require 'utils.gui'
|
||||
local StatData = require 'utils.datastore.statistics'
|
||||
local Commands = require 'utils.commands'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
local UndoActions = require 'utils.undo_actions'
|
||||
|
||||
StatData.add_normalize('jailed', 'Jailed')
|
||||
@@ -661,7 +661,7 @@ local function jail(player, offender, msg, raised, mute)
|
||||
set_data(jailed_data_set, offender, { jailed = true, actor = player, reason = msg, date = date })
|
||||
end
|
||||
|
||||
Event.raise(CreatedEvents.events.on_player_jailed, { player_index = offender.index })
|
||||
Event.raise(CustomEvents.events.on_player_jailed, { player_index = offender.index })
|
||||
|
||||
StatData.get_data(to_jail_player.index):increase('jailed')
|
||||
|
||||
@@ -732,7 +732,7 @@ local function jail_temporary(player, offender, msg, mute)
|
||||
|
||||
set_data(jailed_data_set, offender.name, { jailed = true, temporary = true, actor = player.name, reason = msg, date = date })
|
||||
|
||||
Event.raise(CreatedEvents.events.on_player_jailed, { player_index = offender.index })
|
||||
Event.raise(CustomEvents.events.on_player_jailed, { player_index = offender.index })
|
||||
|
||||
StatData.get_data(offender.index):increase('jailed')
|
||||
|
||||
@@ -761,7 +761,7 @@ local function free(player, offender)
|
||||
|
||||
set_data(jailed_data_set, offender, nil)
|
||||
|
||||
Event.raise(CreatedEvents.events.on_player_unjailed, { player_index = offender.index })
|
||||
Event.raise(CustomEvents.events.on_player_unjailed, { player_index = offender.index })
|
||||
|
||||
Utils.print_to(nil, message)
|
||||
local data = Server.build_embed_data()
|
||||
@@ -1196,7 +1196,7 @@ Event.on_init(
|
||||
)
|
||||
|
||||
Event.add(
|
||||
CreatedEvents.events.on_server_started,
|
||||
CustomEvents.events.on_server_started,
|
||||
function ()
|
||||
Public.sync_revoked_permissions()
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ local Event = require 'utils.event'
|
||||
local table = require 'utils.table'
|
||||
local RPG = require 'modules.rpg.table'
|
||||
local Color = require 'utils.color_presets'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local Public = {}
|
||||
|
||||
@@ -350,7 +350,7 @@ function Public.toggle_module(state)
|
||||
end
|
||||
|
||||
Event.add(
|
||||
CreatedEvents.events.on_server_started,
|
||||
CustomEvents.events.on_server_started,
|
||||
function ()
|
||||
Public.try_dl_resets()
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ local Task = require 'utils.task'
|
||||
local Server = require 'utils.server'
|
||||
local Event = require 'utils.event'
|
||||
local table = require 'utils.table'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local set_timeout_in_ticks = Task.set_timeout_in_ticks
|
||||
|
||||
@@ -346,7 +346,7 @@ end
|
||||
--- It's vital that we reset the online_track so we
|
||||
--- don't calculate the values wrong.
|
||||
Event.add(
|
||||
CreatedEvents.events.on_player_removed,
|
||||
CustomEvents.events.on_player_removed,
|
||||
function ()
|
||||
for name, _ in pairs(online_track) do
|
||||
local player = game.get_player(name)
|
||||
|
||||
@@ -4,7 +4,7 @@ local Token = require 'utils.token'
|
||||
local Task = require 'utils.task'
|
||||
local Server = require 'utils.server'
|
||||
local Event = require 'utils.event'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local set_timeout_in_ticks = Task.set_timeout_in_ticks
|
||||
local statistics_dataset = 'statistics'
|
||||
@@ -310,7 +310,7 @@ Event.add(
|
||||
)
|
||||
|
||||
Event.add(
|
||||
CreatedEvents.events.on_player_removed,
|
||||
CustomEvents.events.on_player_removed,
|
||||
function (event)
|
||||
local player_index = event.player_index
|
||||
statistics[player_index] = nil
|
||||
|
||||
@@ -4,7 +4,7 @@ local Global = require 'utils.global'
|
||||
local Server = require 'utils.server'
|
||||
local Event = require 'utils.event'
|
||||
local table = require 'utils.table'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local supporters_dataset = 'supporters'
|
||||
|
||||
@@ -59,7 +59,7 @@ Server.on_data_set_changed(
|
||||
)
|
||||
|
||||
Event.add(
|
||||
CreatedEvents.events.on_server_started,
|
||||
CustomEvents.events.on_server_started,
|
||||
function ()
|
||||
Public.sync_supporters()
|
||||
end
|
||||
|
||||
@@ -12,7 +12,8 @@ local events = defines.events
|
||||
local events_to_keep = 10
|
||||
|
||||
-- Local vars
|
||||
local Public = {
|
||||
local Public =
|
||||
{
|
||||
name = 'Events'
|
||||
}
|
||||
local name_lookup = {}
|
||||
@@ -27,7 +28,8 @@ local clear_filter_name = Gui.uid_name()
|
||||
local enabled = {}
|
||||
local enabled_for_all = false
|
||||
local last_events = {}
|
||||
storage.debug_event_view = {
|
||||
storage.debug_event_view =
|
||||
{
|
||||
enabled = enabled,
|
||||
enabled_for_all = enabled_for_all,
|
||||
last_events = last_events,
|
||||
@@ -43,7 +45,8 @@ function Public.on_open_debug()
|
||||
enabled = {}
|
||||
last_events = {}
|
||||
|
||||
storage.debug_event_view = {
|
||||
storage.debug_event_view =
|
||||
{
|
||||
enabled = enabled,
|
||||
last_events = last_events
|
||||
}
|
||||
@@ -119,7 +122,8 @@ local function redraw_event_table(gui_table, filter)
|
||||
for _, event_name in pairs(grid_builder) do
|
||||
if filter == '' or event_name:find(filter) then
|
||||
local index = events[event_name]
|
||||
gui_table.add({ type = 'flow' }).add {
|
||||
gui_table.add({ type = 'flow' }).add
|
||||
{
|
||||
name = checkbox_name,
|
||||
type = 'checkbox',
|
||||
state = enabled[index] or false,
|
||||
@@ -138,7 +142,8 @@ function Public.show(container)
|
||||
filter_flow.add({ type = 'label', caption = 'filter' })
|
||||
local filter_textfield = filter_flow.add({ type = 'textfield', name = filter_name, text = filter })
|
||||
local clear_button = filter_flow.add({ type = 'button', name = clear_filter_name, caption = 'clear' })
|
||||
filter_flow.add({ type = 'flow' }).add {
|
||||
filter_flow.add({ type = 'flow' }).add
|
||||
{
|
||||
name = checkbox_all_name,
|
||||
type = 'checkbox',
|
||||
state = enabled_for_all or false,
|
||||
|
||||
@@ -57,7 +57,8 @@ function Public.show(container)
|
||||
right_panel_style.maximal_width = 1000
|
||||
right_panel_style.maximal_height = 1000
|
||||
|
||||
local data = {
|
||||
local data =
|
||||
{
|
||||
right_panel = right_panel,
|
||||
input_text_box = input_text_box,
|
||||
selected_header = nil,
|
||||
@@ -131,7 +132,7 @@ Gui.on_click(
|
||||
|
||||
local input_text_box = data.input_text_box
|
||||
|
||||
update_dump(input_text_box, data, event.player)
|
||||
update_dump(input_text_box, data)
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
@@ -301,7 +301,7 @@ Gui.on_click(
|
||||
data.selected_element_header = selected_element_header
|
||||
if selected_element_header then
|
||||
selected_element_header.style.font_color = Color.orange
|
||||
update_dump(input_text_box, data, event.player)
|
||||
update_dump(input_text_box, data)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
@@ -13,10 +13,10 @@ local classes = api.classes
|
||||
|
||||
local Public = {}
|
||||
|
||||
local luaObject = {'{', nil, ", name = '", nil, "'}"}
|
||||
local luaPlayer = {"{LuaPlayer, name = '", nil, "', index = ", nil, '}'}
|
||||
local luaEntity = {"{LuaEntity, name = '", nil, "', unit_number = ", nil, '}'}
|
||||
local luaGuiElement = {"{LuaGuiElement, name = '", nil, "'}"}
|
||||
local luaObject = { '{', nil, ", name = '", nil, "'}" }
|
||||
local luaPlayer = { "{LuaPlayer, name = '", nil, "', index = ", nil, '}' }
|
||||
local luaEntity = { "{LuaEntity, name = '", nil, "', unit_number = ", nil, '}' }
|
||||
local luaGuiElement = { "{LuaGuiElement, name = '", nil, "'}" }
|
||||
|
||||
local function get(obj, prop)
|
||||
return obj[prop]
|
||||
@@ -46,21 +46,21 @@ local function inspect_process(item)
|
||||
if object_name and classes[object_name] then
|
||||
local class = classes[object_name]
|
||||
local attrs = class.attributes
|
||||
local info = {__type = object_name}
|
||||
local info = { __type = object_name }
|
||||
local shown = 0
|
||||
for key in pairs(attrs) do
|
||||
local ok, val =
|
||||
pcall(
|
||||
function()
|
||||
return item[key]
|
||||
end
|
||||
)
|
||||
function ()
|
||||
return item[key]
|
||||
end
|
||||
)
|
||||
if ok and (type(val) ~= 'table' and type(val) ~= 'userdata') then
|
||||
info[key] = val
|
||||
shown = shown + 1
|
||||
end
|
||||
end
|
||||
return serpent.line(info, {comment = false, numformat = '%g'})
|
||||
return serpent.line(info, { comment = false, numformat = '%g' })
|
||||
end
|
||||
|
||||
if type(item) ~= 'table' or type(item.__self) ~= 'userdata' then
|
||||
@@ -99,7 +99,7 @@ local function inspect_process(item)
|
||||
end
|
||||
end
|
||||
|
||||
local inspect_options = {process = inspect_process}
|
||||
local inspect_options = { process = inspect_process }
|
||||
function Public.dump(data)
|
||||
return inspect(data, inspect_options)
|
||||
end
|
||||
@@ -115,21 +115,23 @@ function Public.dump_ignore_builder(ignore)
|
||||
return inspect_process(item)
|
||||
end
|
||||
|
||||
local options = {process = process}
|
||||
return function(data)
|
||||
local options = { process = process }
|
||||
return function (data)
|
||||
return inspect(data, options)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.dump_function(func)
|
||||
local res = {'upvalues:\n'}
|
||||
local res = { 'upvalues:\n' }
|
||||
|
||||
---@diagnostic disable-next-line: deprecated
|
||||
if debug.getupvalue == nil then
|
||||
return concat(res)
|
||||
end
|
||||
|
||||
local i = 1
|
||||
while true do
|
||||
---@diagnostic disable-next-line: deprecated
|
||||
local n, v = debug.getupvalue(func, i)
|
||||
|
||||
if n == nil then
|
||||
|
||||
@@ -3,7 +3,7 @@ local Event = require 'utils.event'
|
||||
local Global = require 'utils.global'
|
||||
local Server = require 'utils.server'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local insert = table.insert
|
||||
local tostring = tostring
|
||||
@@ -669,7 +669,7 @@ function Public.clear_all_screen_frames(player)
|
||||
end
|
||||
|
||||
function Public.clear_all_active_frames(player)
|
||||
Event.raise(CreatedEvents.events.on_gui_closed_main_frame, { player_index = player.index })
|
||||
Event.raise(CustomEvents.events.on_gui_closed_main_frame, { player_index = player.index })
|
||||
for _, child in pairs(player.gui.left.children) do
|
||||
if child.name:find(gui_prefix) then
|
||||
remove_data_recursively(child)
|
||||
@@ -942,7 +942,7 @@ function Public.refresh(player)
|
||||
for _, tab in pairs(tabbed_pane.tabs) do
|
||||
if tab.content.name ~= frame.name then
|
||||
tab.content.clear()
|
||||
Event.raise(CreatedEvents.events.on_gui_removal, { player_index = player.index })
|
||||
Event.raise(CustomEvents.events.on_gui_removal, { player_index = player.index })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1026,9 +1026,9 @@ Public.on_click(
|
||||
if frame then
|
||||
remove_data_recursively(frame)
|
||||
frame.destroy()
|
||||
Event.raise(CreatedEvents.events.on_gui_removal, { player_index = player.index })
|
||||
Event.raise(CustomEvents.events.on_gui_removal, { player_index = player.index })
|
||||
local active_frame = Public.get_player_active_frame(player)
|
||||
Event.raise(CreatedEvents.events.on_gui_closed_main_frame,
|
||||
Event.raise(CustomEvents.events.on_gui_closed_main_frame,
|
||||
{ player_index = player.index, element = active_frame or nil })
|
||||
else
|
||||
draw_main_frame(player)
|
||||
@@ -1042,7 +1042,7 @@ Public.on_click(
|
||||
local player = event.player
|
||||
local frame = Public.get_parent_frame(player)
|
||||
local active_frame = Public.get_player_active_frame(player)
|
||||
Event.raise(CreatedEvents.events.on_gui_closed_main_frame, { player_index = player.index, element = active_frame or nil })
|
||||
Event.raise(CustomEvents.events.on_gui_closed_main_frame, { player_index = player.index, element = active_frame or nil })
|
||||
if frame then
|
||||
remove_data_recursively(frame)
|
||||
frame.destroy()
|
||||
@@ -1055,7 +1055,7 @@ Public.on_custom_close(
|
||||
function (event)
|
||||
local player = event.player
|
||||
local active_frame = Public.get_player_active_frame(player)
|
||||
Event.raise(CreatedEvents.events.on_gui_closed_main_frame, { player_index = player.index, element = active_frame or nil })
|
||||
Event.raise(CustomEvents.events.on_gui_closed_main_frame, { player_index = player.index, element = active_frame or nil })
|
||||
local frame = Public.get_parent_frame(player)
|
||||
if frame then
|
||||
remove_data_recursively(frame)
|
||||
|
||||
@@ -11,7 +11,7 @@ local Task = require 'utils.task_token'
|
||||
local Token = require 'utils.token'
|
||||
local Global = require 'utils.global'
|
||||
local Discord = require 'utils.discord_handler'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local Public = {}
|
||||
|
||||
@@ -1013,7 +1013,7 @@ create_admin_panel = function (data)
|
||||
local search_table = frame.add({ type = 'table', column_count = 3 })
|
||||
search_table.add({ type = 'label', caption = 'Search: ' })
|
||||
local search_text = search_table.add({ type = 'textfield' })
|
||||
search_text.focus()
|
||||
-- search_text.focus()
|
||||
search_text.text = player_data.search_text or ''
|
||||
search_text.style.width = 140
|
||||
|
||||
@@ -1505,6 +1505,6 @@ Gui.on_checked_state_changed(
|
||||
Event.add(defines.events.on_gui_text_changed, text_changed)
|
||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
||||
Event.add(defines.events.on_gui_selection_state_changed, on_gui_selection_state_changed)
|
||||
Event.add(CreatedEvents.events.on_gui_closed_main_frame, on_gui_closed)
|
||||
Event.add(CustomEvents.events.on_gui_closed_main_frame, on_gui_closed)
|
||||
|
||||
return Public
|
||||
|
||||
@@ -3,7 +3,7 @@ local Global = require 'utils.global'
|
||||
local Gui = require 'utils.gui'
|
||||
local Task = require 'utils.task_token'
|
||||
local Config = require 'utils.gui.config'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local this =
|
||||
{
|
||||
@@ -464,7 +464,7 @@ set_location = function (player, state)
|
||||
}
|
||||
end
|
||||
|
||||
Event.raise(CreatedEvents.events.bottom_quickbar_location_changed, { player_index = player.index, data = data })
|
||||
Event.raise(CustomEvents.events.bottom_quickbar_location_changed, { player_index = player.index, data = data })
|
||||
|
||||
data.state = state
|
||||
create_frame(player, alignment, location, data)
|
||||
@@ -665,7 +665,7 @@ Event.add(
|
||||
)
|
||||
|
||||
Event.add(
|
||||
CreatedEvents.events.bottom_quickbar_respawn_raise,
|
||||
CustomEvents.events.bottom_quickbar_respawn_raise,
|
||||
function (event)
|
||||
if not event or not event.player_index then
|
||||
return
|
||||
@@ -680,7 +680,7 @@ Event.add(
|
||||
)
|
||||
|
||||
Event.add(
|
||||
CreatedEvents.events.bottom_quickbar_location_changed,
|
||||
CustomEvents.events.bottom_quickbar_location_changed,
|
||||
function (event)
|
||||
if not event or not event.player_index then
|
||||
return
|
||||
|
||||
@@ -7,13 +7,13 @@ local Session = require 'utils.datastore.session_data'
|
||||
local Gui = require 'utils.gui'
|
||||
local Global = require 'utils.global'
|
||||
local SpamProtection = require 'utils.spam_protection'
|
||||
local RPG = require 'modules.rpg.table'
|
||||
local Token = require 'utils.token'
|
||||
local Vars = require 'utils.player_list_vars'
|
||||
local Utils = require 'utils.utils'
|
||||
local Core = require 'utils.core'
|
||||
local Inventory = require 'modules.show_inventory'
|
||||
local Color = require 'utils.color_presets'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local Public =
|
||||
{
|
||||
@@ -153,7 +153,11 @@ local function get_sorted_list(sort_by)
|
||||
end
|
||||
|
||||
if this.rpg_enabled then
|
||||
local char = RPG.get_value_from_player(player.index, 'level')
|
||||
local rpg_callback = this.rpg_callback_token and Token.get(this.rpg_callback_token)
|
||||
local char
|
||||
if rpg_callback then
|
||||
char = rpg_callback({ player_index = player.index, key = 'level' })
|
||||
end
|
||||
if not char then
|
||||
char = 1
|
||||
end
|
||||
@@ -365,6 +369,12 @@ local function on_player_left_game()
|
||||
refresh()
|
||||
end
|
||||
|
||||
local function on_rpg_callback_added(event)
|
||||
if event.token then
|
||||
this.rpg_callback_token = event.token
|
||||
end
|
||||
end
|
||||
|
||||
--- If the different roles should be shown in the player_list.
|
||||
---@param value boolean
|
||||
function Public.show_roles_in_list(value)
|
||||
@@ -427,5 +437,6 @@ Gui.on_click(
|
||||
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
Event.add(defines.events.on_player_left_game, on_player_left_game)
|
||||
Event.add(CustomEvents.events.on_rpg_callback_added, on_rpg_callback_added)
|
||||
|
||||
return Public
|
||||
|
||||
@@ -9,7 +9,7 @@ local SpamProtection = require 'utils.spam_protection'
|
||||
local Math = require 'utils.math.math'
|
||||
local Discord = require 'utils.discord_handler'
|
||||
local Color = require 'utils.color_presets'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
local Public = {}
|
||||
|
||||
@@ -956,7 +956,7 @@ local function tick()
|
||||
|
||||
local poll_result, winning_answer = Public.poll_result(poll.id)
|
||||
|
||||
Event.raise(CreatedEvents.events.on_poll_complete, { player_index = poll.player_index, poll_id = poll.id, custom_data = poll.custom_data, poll_result = poll_result, winning_answer = winning_answer })
|
||||
Event.raise(CustomEvents.events.on_poll_complete, { player_index = poll.player_index, poll_id = poll.id, custom_data = poll.custom_data, poll_result = poll_result, winning_answer = winning_answer })
|
||||
|
||||
local message = table.concat { 'Poll finished: Poll #', poll.id, ': ', poll.question }
|
||||
for _, p in pairs(game.connected_players) do
|
||||
@@ -968,7 +968,7 @@ local function tick()
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(CreatedEvents.events.on_poll_created, function (event)
|
||||
Event.add(CustomEvents.events.on_poll_created, function (event)
|
||||
Public.poll(event)
|
||||
end)
|
||||
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
local Event = require 'utils.event'
|
||||
local Server = require 'utils.server'
|
||||
local Global = require 'utils.global'
|
||||
local Public = {}
|
||||
local loaded = {}
|
||||
local count = 1
|
||||
local limit = 30
|
||||
|
||||
local this = {}
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function (tbl)
|
||||
this = tbl
|
||||
end
|
||||
)
|
||||
|
||||
function Public.set(var)
|
||||
if game then
|
||||
return
|
||||
@@ -17,25 +27,25 @@ function Public.set(var)
|
||||
end
|
||||
|
||||
function Public.get_handlers()
|
||||
local handlers = storage.tick_handler
|
||||
local handlers = this.tick_handler
|
||||
|
||||
if not handlers then
|
||||
storage.tick_handler = {}
|
||||
handlers = storage.tick_handler
|
||||
this.tick_handler = {}
|
||||
handlers = this.tick_handler
|
||||
end
|
||||
|
||||
return handlers
|
||||
end
|
||||
|
||||
function Public.can_run_scheduler(condition)
|
||||
storage.can_run_scheduler = condition or false
|
||||
this.can_run_scheduler = condition or false
|
||||
end
|
||||
|
||||
function Public.search(id)
|
||||
local handlers = storage.tick_handler
|
||||
local handlers = this.tick_handler
|
||||
|
||||
for _, data in pairs(handlers) do
|
||||
if data and (data.parent_id == id or (data.custom_name and data.custom_name == id)) then
|
||||
if data and (data.child_id == id or (data.custom_name and data.custom_name == id)) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -51,7 +61,8 @@ function Public.return_callback(callback)
|
||||
return
|
||||
end
|
||||
|
||||
local data = {
|
||||
local data =
|
||||
{
|
||||
iterator_index = 1,
|
||||
tick_index = 1,
|
||||
point_index = 1,
|
||||
@@ -77,7 +88,7 @@ function Public.timeout(tick, id, data, custom_name)
|
||||
|
||||
tick = game.tick + tick
|
||||
|
||||
local handlers = storage.tick_handler
|
||||
local handlers = this.tick_handler
|
||||
if not handlers then
|
||||
handlers = Public.get_handlers()
|
||||
end
|
||||
@@ -90,17 +101,19 @@ function Public.timeout(tick, id, data, custom_name)
|
||||
goto retry
|
||||
end
|
||||
|
||||
handlers[tick] = {
|
||||
handlers[tick] =
|
||||
{
|
||||
id = id,
|
||||
parent_id = id,
|
||||
child_id = id,
|
||||
data = data,
|
||||
execute_tick = tick,
|
||||
custom_name = custom_name or nil
|
||||
}
|
||||
else
|
||||
handlers[tick] = {
|
||||
handlers[tick] =
|
||||
{
|
||||
id = id,
|
||||
parent_id = id,
|
||||
child_id = id,
|
||||
data = data,
|
||||
execute_tick = tick,
|
||||
custom_name = custom_name or nil
|
||||
@@ -109,7 +122,7 @@ function Public.timeout(tick, id, data, custom_name)
|
||||
end
|
||||
|
||||
local function increment_handler(tick, handler)
|
||||
local handlers = storage.tick_handler
|
||||
local handlers = this.tick_handler
|
||||
|
||||
::retry::
|
||||
tick = tick + 1
|
||||
@@ -126,14 +139,14 @@ end
|
||||
|
||||
local function on_tick()
|
||||
local tick = game.tick
|
||||
local can_run_scheduler = storage.can_run_scheduler
|
||||
local can_run_scheduler = this.can_run_scheduler
|
||||
if not can_run_scheduler then
|
||||
storage.tick_handler = {}
|
||||
this.tick_handler = {}
|
||||
Server.output_script_data('Scheduler task has been cleared and stopped!')
|
||||
return
|
||||
end
|
||||
|
||||
local handlers = storage.tick_handler
|
||||
local handlers = this.tick_handler
|
||||
|
||||
if not handlers then
|
||||
handlers = Public.get_handlers()
|
||||
|
||||
@@ -3,7 +3,7 @@ local Task = require 'utils.task'
|
||||
local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
local Print = require('utils.print_override')
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
-- local constants
|
||||
local floor = math.floor
|
||||
@@ -185,15 +185,15 @@ end
|
||||
-- local Server = require 'utils.server'
|
||||
-- local Event = require 'utils.event'
|
||||
--
|
||||
-- Event.add(CreatedEvents.events.on_server_started,
|
||||
-- Event.add(CustomEvents.events.on_server_started,
|
||||
-- function()
|
||||
-- Server.try_get_all_data('regulars', callback)
|
||||
-- end)
|
||||
-- Event.add(CreatedEvents.events.on_changes_detected,
|
||||
-- Event.add(CustomEvents.events.on_changes_detected,
|
||||
-- function()
|
||||
-- Trigger some sort of automated restart whenever the game ends.
|
||||
-- end)
|
||||
-- Defined in CreatedEvents.lua
|
||||
-- Defined in CustomEvents.lua
|
||||
|
||||
-- Starts a new game with the given scenario. Note that this will stop the current game and reset it.
|
||||
---@param scenario_data string|table
|
||||
@@ -1595,7 +1595,7 @@ function Public.ban_handler(event)
|
||||
|
||||
if cmd == 'ban' then
|
||||
Public.set_data(jailed_data_set, target, nil) -- this is added here since we don't want to clutter the jail dataset.
|
||||
Event.raise(CreatedEvents.events.on_player_banned, { player_name = target })
|
||||
Event.raise(CustomEvents.events.on_player_banned, { player_name = target })
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ local Poll =
|
||||
}
|
||||
local Token = require 'utils.token'
|
||||
local Server = require 'utils.server'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
|
||||
--- This module is for the web server to call functions and raise events.
|
||||
-- Not intended to be called by scripts.
|
||||
@@ -28,11 +28,11 @@ ServerCommands.raise_scenario_changed = Server.raise_scenario_changed
|
||||
ServerCommands.get_tracked_scenario = Server.get_tracked_scenario
|
||||
|
||||
function ServerCommands.server_started()
|
||||
script.raise_event(CreatedEvents.events.on_server_started, {})
|
||||
script.raise_event(CustomEvents.events.on_server_started, {})
|
||||
end
|
||||
|
||||
function ServerCommands.changes_detected()
|
||||
script.raise_event(CreatedEvents.events.on_changes_detected, {})
|
||||
script.raise_event(CustomEvents.events.on_changes_detected, {})
|
||||
end
|
||||
|
||||
ServerCommands.set_time = Server.set_time
|
||||
|
||||
@@ -238,7 +238,7 @@ end
|
||||
|
||||
--- Clears all existing entries in a table
|
||||
---@param t table to clear
|
||||
---@param array boolean to indicate whether the table is an array or not
|
||||
---@param array boolean|nil to indicate whether the table is an array or not
|
||||
function table.clear_table(t, array)
|
||||
if array then
|
||||
for i = 1, #t do
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
local Server = require 'utils.server'
|
||||
local Event = require 'utils.event'
|
||||
local CreatedEvents = require 'utils.created_events'
|
||||
local CustomEvents = require 'utils.created_events'
|
||||
local Global = require 'utils.global'
|
||||
local Commands = require 'utils.commands'
|
||||
local Task = require 'utils.task_token'
|
||||
local Discord = require 'utils.discord_handler'
|
||||
|
||||
local module_name = '[Undo actions] '
|
||||
local undo_polls = {}
|
||||
@@ -62,7 +63,7 @@ local function do_action_poll(player)
|
||||
game.print(module_name .. player.name .. ' has ' .. undo_count .. ' entities in the undo queue. Creating poll before restoring them.')
|
||||
local unique_id = player.name .. '_' .. 'undo_poll'
|
||||
|
||||
Event.raise(CreatedEvents.events.on_poll_created,
|
||||
Event.raise(CustomEvents.events.on_poll_created,
|
||||
{
|
||||
question = player.name .. ' removed ' .. undo_count .. ' entities before getting dealt with. Proceed with restoration?',
|
||||
answers = { 'Yes, restore the entities!', 'No, do not restore the entities!' },
|
||||
@@ -184,7 +185,7 @@ local function check_undo_redo_stack(player)
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(CreatedEvents.events.on_poll_complete, function (event)
|
||||
Event.add(CustomEvents.events.on_poll_complete, function (event)
|
||||
if not event.winning_answer or not event.winning_answer.text then
|
||||
return
|
||||
end
|
||||
@@ -250,7 +251,7 @@ Event.add(CreatedEvents.events.on_poll_complete, function (event)
|
||||
end
|
||||
end)
|
||||
|
||||
Event.add(CreatedEvents.events.on_player_banned, function (event)
|
||||
Event.add(CustomEvents.events.on_player_banned, function (event)
|
||||
if not event.player_name then
|
||||
return
|
||||
end
|
||||
@@ -271,7 +272,39 @@ Event.add(CreatedEvents.events.on_player_banned, function (event)
|
||||
Server.output_script_data(module_name .. 'Undo redo stack checked for ' .. player.name)
|
||||
end)
|
||||
|
||||
Commands.new('undo_player_actions', 'Undoes the actions of a player.')
|
||||
Commands.new('undo_player_actions', 'Undoes the actions of a player as a player by creating a poll.')
|
||||
:add_parameter('player', false, 'player')
|
||||
:require_validation('Only utilize this command if the player is jailed and has entities in the undo queue.')
|
||||
:require_playtime(60 * 60 * 60 * 24 * 40) -- 30 days
|
||||
:callback(function (player, target_player)
|
||||
if not target_player or not target_player.valid then
|
||||
return player.print('Player is not valid.')
|
||||
end
|
||||
|
||||
local undo_count = check_undo_queue(target_player)
|
||||
if not undo_count or undo_count <= 0 then
|
||||
return player.print('No undo count found for ' .. target_player.name .. '.')
|
||||
end
|
||||
|
||||
do_action_poll(target_player)
|
||||
player.print('Logging your actions to discord.')
|
||||
Discord.send_notification(
|
||||
{
|
||||
title = 'Undo actions',
|
||||
description = 'Undone ' .. undo_count .. ' actions for ' .. target_player.name .. ' by ' .. player.name .. '.',
|
||||
color = 'success',
|
||||
fields =
|
||||
{
|
||||
{
|
||||
title = "Server",
|
||||
description = Server.get_server_name() or 'CommandHandler',
|
||||
inline = "false"
|
||||
}
|
||||
}
|
||||
})
|
||||
end)
|
||||
|
||||
Commands.new('undo_player_actions_admin', 'Undoes the actions of a player as an admin.')
|
||||
:add_parameter('player', false, 'player')
|
||||
:require_validation('Only utilize this command if the player is jailed and has entities in the undo queue.')
|
||||
:require_admin()
|
||||
@@ -286,7 +319,22 @@ Commands.new('undo_player_actions', 'Undoes the actions of a player.')
|
||||
end
|
||||
|
||||
check_undo_redo_stack(target_player)
|
||||
player.print('Logging your actions to discord.')
|
||||
player.print('Undone ' .. undo_count .. ' actions for ' .. target_player.name .. '.')
|
||||
Discord.send_notification(
|
||||
{
|
||||
title = 'Undo actions',
|
||||
description = 'Undone ' .. undo_count .. ' actions for ' .. target_player.name .. ' by ' .. player.name .. '.',
|
||||
color = 'success',
|
||||
fields =
|
||||
{
|
||||
{
|
||||
title = "Server",
|
||||
description = Server.get_server_name() or 'CommandHandler',
|
||||
inline = "false"
|
||||
}
|
||||
}
|
||||
})
|
||||
end)
|
||||
|
||||
Public.check_undo_redo_stack = check_undo_redo_stack
|
||||
|
||||
Reference in New Issue
Block a user