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

Mass refactor

This PR changes generated events by util modules to bypass the need to require each file to utilize them.

Added new module that tracks undo of a player.

The config module for GUI has been refactored to add functions/events from the caller instead of having one massive blob inside of the file.

The debug module now prints each attribute of an object instead of plain <userdata>.
This commit is contained in:
Gerkiz
2025-10-19 21:20:03 +02:00
parent 772fb09a9c
commit 38ec1a9a72
50 changed files with 6734 additions and 542 deletions

View File

@@ -12,8 +12,10 @@ 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 this = {
local this =
{
enabled = true,
players = {},
bottom_button = false
@@ -121,7 +123,8 @@ Commands.new('remove_chunks', 'Iterates over a surface and removes chunks that a
for chunk in chunks do
if surface.is_chunk_generated(chunk) then
local area = {
local area =
{
left_top = { chunk.area.left_top.x - 64, chunk.area.left_top.y - 64 },
right_bottom = { chunk.area.right_bottom.x + 64, chunk.area.right_bottom.y + 64 }
}
@@ -287,8 +290,10 @@ Commands.new('generate_map', 'Pregenerates map.')
end
)
Commands.new('repair', 'Revives all ghost entities.')
Commands.new('repair', 'Revives all ghost entities and inserts all missing modules into the entities.')
:require_admin()
:add_alias('fix')
:add_alias('revive')
:require_validation()
:add_parameter('1-50', true, 'number')
:callback(
@@ -306,19 +311,38 @@ Commands.new('repair', 'Revives all ghost entities.')
local radius = { { x = (player.position.x + -args), y = (player.position.y + -args) }, { x = (player.position.x + args), y = (player.position.y + args) } }
local c = 0
local modules = 0
for _, v in pairs(player.surface.find_entities_filtered { type = 'entity-ghost', area = radius }) do
if v and v.valid then
c = c + 1
v.silent_revive()
local _, entity, item_proxy = v.silent_revive()
if entity and entity.valid then
if item_proxy and item_proxy.valid then
for _, plan in pairs(item_proxy.insert_plan) do
if entity.get_module_inventory().index == plan.items.in_inventory[1].inventory then
item_proxy.proxy_target.get_module_inventory().insert { name = plan.id.name, quality = plan.id.quality, count = 999 }
modules = modules + 1
end
end
item_proxy.destroy()
end
end
end
end
if c == 0 then
player.print('No entities to repair were found!')
return false
end
Discord.send_notification_raw(nil, player.name .. ' repaired ' .. c .. ' entities!')
if modules > 0 then
Discord.send_notification_raw(nil, player.name .. ' repaired ' .. c .. ' entities and inserted all missing modules into the entities.')
return 'Repaired ' .. c .. ' entities and inserted all missing modules into the entities.'
end
Discord.send_notification_raw(nil, player.name .. ' repaired ' .. c .. ' entities.')
return 'Repaired ' .. c .. ' entities!'
end
)
@@ -331,7 +355,8 @@ Commands.new('dump_layout', 'Dump the current map-layout.')
local surface = player.surface
game.write_file('layout.lua', '', false)
local area = {
local area =
{
left_top = { x = 0, y = 0 },
right_bottom = { x = 32, y = 32 }
}
@@ -707,7 +732,7 @@ Gui.on_click(
)
Event.add(
BottomFrame.events.bottom_quickbar_location_changed,
CreatedEvents.events.bottom_quickbar_location_changed,
function (event)
if not this.enabled then
return