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

Mtn: fix various bugs

This commit is contained in:
Gerkiz
2024-11-08 21:56:53 +01:00
parent 41a56873d2
commit dca343b775
7 changed files with 74 additions and 7 deletions

View File

@@ -255,6 +255,7 @@ local function on_player_created(event)
local player = game.players[event.player_index]
player.gui.top.style = 'packed_horizontal_flow'
player.gui.left.style = 'vertical_flow'
player.show_on_map = false -- hide selection on minimap
end
local Event = require 'utils.event'

View File

@@ -46,6 +46,12 @@ local chests = {
'crash-site-spaceship-wreck-medium-3'
}
local valid_forces = {
[2] = true,
[4] = true,
[5] = true
}
local size_chests = #chests
local treasure_chest_messages = {
@@ -368,7 +374,7 @@ local function biters_chew_rocks_faster(data)
if not cause.valid then
return
end
if cause.force.index ~= 2 then
if not valid_forces[cause.force.index] then
return
end --Enemy Force

View File

@@ -2349,6 +2349,17 @@ function Public.on_player_changed_position(event)
end
if player.controller_type == defines.controllers.remote then
local loco_surface = Public.get('loco_surface')
if not loco_surface or not loco_surface.valid then
return
end
if player.surface.index == loco_surface.index then
local map_gen = loco_surface.map_gen_settings
if player.position.y > map_gen.height then player.set_controller { type = 1, character = player.character } end
if player.position.y < (-map_gen.height / 2) then player.set_controller { type = 1, character = player.character } end
if player.position.x > map_gen.width then player.set_controller { type = 1, character = player.character } end
if player.position.x < -map_gen.width then player.set_controller { type = 1, character = player.character } end
end
return
end

View File

@@ -110,6 +110,35 @@ function Public.add_player_to_permission_group(player, group, forced)
not_trusted.set_allows_action(defines.input_action.set_trains_limit, false)
not_trusted.set_allows_action(defines.input_action.set_train_stopped, false)
not_trusted.set_allows_action(defines.input_action.deconstruct, false)
not_trusted.set_allows_action(defines.input_action.upgrade_opened_blueprint_by_record, false)
not_trusted.set_allows_action(defines.input_action.upgrade_opened_blueprint_by_item, false)
not_trusted.set_allows_action(defines.input_action.setup_single_blueprint_record, false)
not_trusted.set_allows_action(defines.input_action.select_blueprint_entities, false)
not_trusted.set_allows_action(defines.input_action.setup_blueprint, false)
not_trusted.set_allows_action(defines.input_action.reassign_blueprint, false)
not_trusted.set_allows_action(defines.input_action.parametrise_blueprint, false)
not_trusted.set_allows_action(defines.input_action.open_blueprint_record, false)
not_trusted.set_allows_action(defines.input_action.open_blueprint_library_gui, false)
not_trusted.set_allows_action(defines.input_action.import_blueprints_filtered, false)
not_trusted.set_allows_action(defines.input_action.import_blueprint_string, false)
not_trusted.set_allows_action(defines.input_action.import_blueprint, false)
not_trusted.set_allows_action(defines.input_action.grab_blueprint_record, false)
not_trusted.set_allows_action(defines.input_action.export_blueprint, false)
not_trusted.set_allows_action(defines.input_action.edit_blueprint_tool_preview, false)
not_trusted.set_allows_action(defines.input_action.drop_blueprint_record, false)
not_trusted.set_allows_action(defines.input_action.delete_blueprint_record, false)
not_trusted.set_allows_action(defines.input_action.delete_blueprint_library, false)
not_trusted.set_allows_action(defines.input_action.cycle_blueprint_book_forwards, false)
not_trusted.set_allows_action(defines.input_action.cycle_blueprint_book_forwards, false)
not_trusted.set_allows_action(defines.input_action.cycle_blueprint_book_backwards, false)
not_trusted.set_allows_action(defines.input_action.copy_opened_blueprint, false)
not_trusted.set_allows_action(defines.input_action.cycle_blueprint_book_forwards, false)
not_trusted.set_allows_action(defines.input_action.copy_large_opened_blueprint, false)
not_trusted.set_allows_action(defines.input_action.alt_select_blueprint_entities, false)
not_trusted.set_allows_action(defines.input_action.alt_select_blueprint_entities, false)
not_trusted.set_allows_action(defines.input_action.cancel_new_blueprint, false)
not_trusted.set_allows_action(defines.input_action.alt_select_blueprint_entities, false)
not_trusted.set_allows_action(defines.input_action.adjust_blueprint_snapping, false)
if not AG.enabled then
default_group.add_player(player)

View File

@@ -93,11 +93,19 @@ local function remove_trees(entity)
local radius = 10
local pos = entity.position
local area = { { pos.x - radius, pos.y - radius }, { pos.x + radius, pos.y + radius } }
-- Find all trees within the bounding rectangle
local trees = surface.find_entities_filtered { area = area, type = 'tree' }
if #trees > 0 then
for _, tree in pairs(trees) do
if tree and tree.valid then
tree.destroy()
local dx = tree.position.x - pos.x
local dy = tree.position.y - pos.y
local distance_squared = dx * dx + dy * dy
if distance_squared <= radius * radius then
tree.destroy()
end
end
end
end
@@ -115,7 +123,13 @@ local function remove_rocks(entity)
if #rocks > 0 then
for _, rock in pairs(rocks) do
if rock and rock.valid then
rock.destroy()
local dx = rock.position.x - pos.x
local dy = rock.position.y - pos.y
local distance_squared = dx * dx + dy * dy
if distance_squared <= radius * radius then
rock.destroy()
end
end
end
end
@@ -140,7 +154,13 @@ local function fill_tiles(entity, size)
local tiles = surface.find_tiles_filtered { area = area, name = t }
if #tiles > 0 then
for _, tile in pairs(tiles) do
surface.set_tiles({ { name = 'sand-1', position = tile.position } }, true)
local dx = tile.position.x - pos.x
local dy = tile.position.y - pos.y
local distance_squared = dx * dx + dy * dy
if distance_squared <= radius * radius then
surface.set_tiles({ { name = 'sand-1', position = tile.position } }, true)
end
end
end
Public.debug_print('fill_tiles - filled tiles cause we found non-placable tiles.')

View File

@@ -2,6 +2,8 @@ local Global = require 'utils.global'
local Core = require 'utils.core'
local Gui = require 'utils.gui'
local Event = require 'utils.event'
local Server = require 'utils.server'
local log = Server.output_data
local this = {
pause_waves_custom_callback = nil,
@@ -284,7 +286,7 @@ function Public.set_spawn_position(tbl)
if type(tbl) == 'table' then
this.spawn_position = tbl
else
error('Tbl must be of type table.')
error('Tbl must be of type table.', 2)
end
return this.spawn_position
end

View File

@@ -682,8 +682,6 @@ Event.add(
return
end
print('Player joined game.')
local player = game.players[event.player_index]
on_player_joined_game(player)
create_clear_corpse_frame(player)