mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-07-26 18:36:23 +09:00
@@ -201,7 +201,6 @@ Roles.new_role("Veteran", "Vet")
|
||||
"command/clear-blueprints",
|
||||
"command/clear-blueprints-radius",
|
||||
"command/set-trains-to-automatic",
|
||||
"command/set-auto-research",
|
||||
"command/lawnmower",
|
||||
"command/waterfill",
|
||||
"command/artillery",
|
||||
|
||||
@@ -4,4 +4,5 @@
|
||||
return {
|
||||
fluid = true, --- @setting fluid When true, checks for for fluid pipes when removing miners
|
||||
chest = true, --- @setting chest When true, checks for for chest when removing miners
|
||||
beacon = true, --- @setting beacon When true, checks for for beacon when removing miners
|
||||
}
|
||||
|
||||
@@ -2,14 +2,6 @@
|
||||
-- @config Repair
|
||||
|
||||
return {
|
||||
disallow = { --- @setting disallow items in this list will never be repaired
|
||||
["loader"] = true,
|
||||
["fast-loader"] = true,
|
||||
["express-loader"] = true,
|
||||
["electric-energy-interface"] = true,
|
||||
["infinity-chest"] = true,
|
||||
},
|
||||
max_range = 50, --- @setting max_range the max range that can be used with the repair command
|
||||
allow_blueprint_repair = false, --- @setting allow_blueprint_repair when true will allow blueprints (things not destroyed by biters) to be build instantly using the repair command
|
||||
allow_ghost_revive = true, --- @setting allow_ghost_revive when true will allow ghosts (things destroyed by biters) to be build instantly using the repair command
|
||||
allow_heal_entities = true, --- @setting allow_heal_entities when true will heal entities to full health that are within range
|
||||
|
||||
@@ -12,16 +12,6 @@ return {
|
||||
-- this enable 20 more inventory for each mining productivity level up to 4
|
||||
bonus_inventory = {
|
||||
enabled = true,
|
||||
log = {
|
||||
["base"] = {
|
||||
["name"] = "mining-productivity-4",
|
||||
["level"] = 4
|
||||
},
|
||||
["space-age"] = {
|
||||
["name"] = "mining-productivity-3",
|
||||
["level"] = 3
|
||||
},
|
||||
},
|
||||
res = {
|
||||
-- Mining Productivity
|
||||
["mining-productivity"] = true,
|
||||
|
||||
@@ -2,32 +2,58 @@
|
||||
Adds a command that clean up biter corpse and nuclear hole
|
||||
]]
|
||||
|
||||
local AABB = require("modules/exp_util/aabb")
|
||||
local Commands = require("modules/exp_commands")
|
||||
local config = require("modules.exp_legacy.config.lawnmower") --- @dep config.lawnmower
|
||||
local Selection = require("modules/exp_util/selection")
|
||||
local SelectArea = Selection.connect("ExpCommand_Lawnmower")
|
||||
local config = require("modules.exp_legacy.config.lawnmower")
|
||||
|
||||
Commands.new("lawnmower", { "exp-commands_lawnmower.description" })
|
||||
:argument("range", { "exp-commands_lawnmower.arg-range" }, Commands.types.integer_range(1, 200))
|
||||
:register(function(player, range)
|
||||
--- @cast range number
|
||||
local surface = player.surface
|
||||
--- @class ExpCommand_Lawnmower.commands
|
||||
local commands = {}
|
||||
|
||||
-- Intentionally left as player.position to allow use in remote view
|
||||
local entities = surface.find_entities_filtered{ position = player.position, radius = range, type = "corpse" }
|
||||
for _, entity in pairs(entities) do
|
||||
if (entity.name ~= "transport-caution-corpse" and entity.name ~= "invisible-transport-caution-corpse") then
|
||||
entity.destroy()
|
||||
end
|
||||
--- Toggle player selection mode for lawnmower
|
||||
--- @class ExpCommands_Lawnmower.commands.lawnmower: ExpCommand
|
||||
--- @overload fun(player: LuaPlayer)
|
||||
commands.lawnmower = Commands.new("lawnmower", { "exp-commands_lawnmower.description" })
|
||||
:register(function(player)
|
||||
if SelectArea:stop(player) then
|
||||
return Commands.status.success{ "exp-commands_lawnmower.exit" }
|
||||
end
|
||||
|
||||
local replace_tiles = {}
|
||||
local tiles = surface.find_tiles_filtered{ position = player.position, radius = range, name = { "nuclear-ground" } }
|
||||
for i, tile in pairs(tiles) do
|
||||
replace_tiles[i] = { name = "grass-1", position = tile.position }
|
||||
end
|
||||
SelectArea:start(player)
|
||||
return Commands.status.success{ "exp-commands_lawnmower.enter" }
|
||||
end) --[[ @as any ]]
|
||||
|
||||
surface.set_tiles(replace_tiles)
|
||||
surface.destroy_decoratives{ position = player.position, radius = range }
|
||||
end)
|
||||
--- When an area is selected to be handled
|
||||
SelectArea:on_selection(function(event)
|
||||
local player = assert(game.get_player(event.player_index))
|
||||
local area = AABB.expand(event.area)
|
||||
local surface = event.surface
|
||||
local area_size = (area.right_bottom.x - area.left_top.x) * (area.right_bottom.y - area.left_top.y)
|
||||
|
||||
if area_size > 1000 then
|
||||
player.print({ "exp-commands_lawnmower.area-too-large", 1000, area_size }, Commands.print_settings.error)
|
||||
return
|
||||
end
|
||||
|
||||
local entities = surface.find_entities_filtered{ area = area, type = "corpse" }
|
||||
for _, entity in pairs(entities) do
|
||||
if (entity.name ~= "transport-caution-corpse" and entity.name ~= "invisible-transport-caution-corpse") then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
local replace_tiles = {}
|
||||
local tiles = surface.find_tiles_filtered{ area = area, name = { "nuclear-ground" } }
|
||||
for i, tile in pairs(tiles) do
|
||||
replace_tiles[i] = { name = "grass-1", position = tile.position }
|
||||
end
|
||||
|
||||
surface.set_tiles(replace_tiles)
|
||||
surface.destroy_decoratives{ area = area }
|
||||
|
||||
player.print({ "exp-commands_lawnmower.complete", #replace_tiles }, Commands.print_settings.default)
|
||||
end)
|
||||
|
||||
--- @param event EventData.on_built_entity | EventData.on_robot_built_entity | EventData.script_raised_built | EventData.script_raised_revive
|
||||
local function destroy_decoratives(event)
|
||||
@@ -48,5 +74,6 @@ if config.destroy_decoratives then
|
||||
end
|
||||
|
||||
return {
|
||||
events = events
|
||||
events = events,
|
||||
commands = commands,
|
||||
}
|
||||
|
||||
@@ -2,56 +2,73 @@
|
||||
Adds a command that allows an admin to repair and revive a large area
|
||||
]]
|
||||
|
||||
local AABB = require("modules/exp_util/aabb")
|
||||
local Commands = require("modules/exp_commands")
|
||||
local config = require("modules.exp_legacy.config.repair") --- @dep config.repair
|
||||
local Selection = require("modules/exp_util/selection")
|
||||
local SelectArea = Selection.connect("ExpCommand_Waterfill")
|
||||
|
||||
--- Repairs entities on your force around you
|
||||
Commands.new("repair", { "exp-commands_repair.description" })
|
||||
:argument("range", { "exp-commands_repair.arg-range" }, Commands.types.integer_range(1, config.max_range))
|
||||
:register(function(player, range)
|
||||
--- @cast range number
|
||||
local force = player.force
|
||||
local surface = player.surface -- Allow remote view
|
||||
local position = player.position -- Allow remote view
|
||||
local response = { "" } --- @type LocalisedString
|
||||
--- @class ExpCommands_Repair.commands
|
||||
local commands = {}
|
||||
|
||||
if config.allow_ghost_revive then
|
||||
local revive_count = 0
|
||||
local entities = surface.find_entities_filtered{
|
||||
type = "entity-ghost",
|
||||
position = position,
|
||||
radius = range,
|
||||
force = force,
|
||||
}
|
||||
|
||||
local param = { raise_revive = true } --- @type LuaEntity.silent_revive_param
|
||||
for _, entity in ipairs(entities) do
|
||||
if not config.disallow[entity.ghost_name] and (config.allow_blueprint_repair or entity.created_by_corpse) then
|
||||
revive_count = revive_count + 1
|
||||
entity.silent_revive(param)
|
||||
end
|
||||
end
|
||||
|
||||
response[#response + 1] = { "exp-commands_repair.response-revive", revive_count }
|
||||
--- Toggle player selection mode
|
||||
--- @class ExpCommands_Repair.commands.repair: ExpCommand
|
||||
commands.repair = Commands.new("repair", { "exp-commands_repair.description" })
|
||||
:register(function(player)
|
||||
if SelectArea:stop(player) then
|
||||
return Commands.status.success{ "exp-commands_repair.exit" }
|
||||
end
|
||||
|
||||
if config.allow_heal_entities then
|
||||
local healed_count = 0
|
||||
local entities = surface.find_entities_filtered{
|
||||
position = position,
|
||||
radius = range,
|
||||
force = force,
|
||||
}
|
||||
|
||||
for _, entity in ipairs(entities) do
|
||||
if entity.health and entity.max_health and entity.health ~= entity.max_health then
|
||||
healed_count = healed_count + 1
|
||||
entity.health = entity.max_health
|
||||
end
|
||||
end
|
||||
|
||||
response[#response + 1] = { "exp-commands_repair.response-heal", healed_count }
|
||||
end
|
||||
|
||||
return Commands.status.success(response)
|
||||
SelectArea:start(player)
|
||||
return Commands.status.success{ "exp-commands_repair.enter" }
|
||||
end)
|
||||
|
||||
--- When an area is selected to be converted to water
|
||||
SelectArea:on_selection(function(event)
|
||||
local player = assert(game.get_player(event.player_index))
|
||||
local area = AABB.expand(event.area)
|
||||
local surface = event.surface
|
||||
local force = player.force
|
||||
local response = { "" } --- @type LocalisedString
|
||||
|
||||
if config.allow_ghost_revive then
|
||||
local revive_count = 0
|
||||
local entities = surface.find_entities_filtered{
|
||||
type = "entity-ghost",
|
||||
area = area,
|
||||
force = force,
|
||||
}
|
||||
|
||||
local param = { raise_revive = true } --- @type LuaEntity.silent_revive_param
|
||||
for _, entity in ipairs(entities) do
|
||||
if not (entity.ghost_prototype and entity.ghost_prototype.hidden) and (config.allow_blueprint_repair or entity.created_by_corpse) then
|
||||
revive_count = revive_count + 1
|
||||
entity.silent_revive(param)
|
||||
end
|
||||
end
|
||||
|
||||
response[#response + 1] = { "exp-commands_repair.response-revive", revive_count }
|
||||
end
|
||||
|
||||
if config.allow_heal_entities then
|
||||
local healed_count = 0
|
||||
local entities = surface.find_entities_filtered{
|
||||
area = area,
|
||||
force = force,
|
||||
}
|
||||
|
||||
for _, entity in ipairs(entities) do
|
||||
if entity.health and entity.max_health and entity.health ~= entity.max_health then
|
||||
healed_count = healed_count + 1
|
||||
entity.health = entity.max_health
|
||||
end
|
||||
end
|
||||
|
||||
response[#response + 1] = { "exp-commands_repair.response-heal", healed_count }
|
||||
end
|
||||
|
||||
return player.print(response)
|
||||
end)
|
||||
|
||||
return {
|
||||
commands = commands,
|
||||
}
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
--[[-- Commands - Research
|
||||
Adds a command to enable automatic research queueing
|
||||
]]
|
||||
|
||||
local Storage = require("modules/exp_util/storage")
|
||||
local Commands = require("modules/exp_commands")
|
||||
local format_player_name = Commands.format_player_name_locale
|
||||
|
||||
local config = require("modules.exp_legacy.config.research") --- @dep config.research
|
||||
|
||||
--- @class ExpCommands_Research.commands
|
||||
local commands = {}
|
||||
|
||||
local research = {
|
||||
res_queue_enable = false
|
||||
}
|
||||
|
||||
Storage.register(research, function(tbl)
|
||||
research = tbl
|
||||
end)
|
||||
|
||||
--- @param force LuaForce
|
||||
--- @param silent boolean True when no message should be printed
|
||||
local function queue_research(force, silent)
|
||||
local res_q = force.research_queue
|
||||
local res = force.technologies[config.bonus_inventory.log[config.mod_set].name]
|
||||
|
||||
if #res_q < config.queue_amount then
|
||||
for i = #res_q, config.queue_amount - 1 do
|
||||
force.add_research(res)
|
||||
|
||||
if not silent then
|
||||
game.print{ "exp-commands_research.queue", res.name, res.level + i }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- @param state boolean? use nil to toggle current state
|
||||
--- @return boolean # New auto research state
|
||||
local function set_auto_research(state)
|
||||
local new_state
|
||||
if state == nil then
|
||||
new_state = not research.res_queue_enable
|
||||
else
|
||||
new_state = state ~= false
|
||||
end
|
||||
|
||||
research.res_queue_enable = new_state
|
||||
return new_state
|
||||
end
|
||||
|
||||
--- Sets the auto research state
|
||||
--- @class ExpCommand_Artillery.commands.artillery: ExpCommand
|
||||
--- @overload fun(player: LuaPlayer, state: boolean?)
|
||||
commands.set_auto_research = Commands.new("set-auto-research", { "exp-commands_research.description" })
|
||||
:optional("state", { "exp-commands_research.arg-state" }, Commands.types.boolean)
|
||||
:add_aliases{ "auto-research" }
|
||||
:register(function(player, state)
|
||||
--- @cast state boolean?
|
||||
local enabled = set_auto_research(state)
|
||||
|
||||
if enabled then
|
||||
queue_research(player.force --[[@as LuaForce]], true)
|
||||
end
|
||||
|
||||
local player_name = format_player_name(player)
|
||||
game.print{ "exp-commands_research.auto-research", player_name, enabled }
|
||||
end) --[[ @as any ]]
|
||||
|
||||
--- @param event EventData.on_research_finished
|
||||
local function on_research_finished(event)
|
||||
if not research.res_queue_enable then return end
|
||||
|
||||
local force = event.research.force
|
||||
local log_research = assert(config.bonus_inventory.log[config.mod_set], "Unknown mod set: " .. tostring(config.mod_set))
|
||||
local technology = assert(force.technologies[log_research.name], "Unknown technology: " .. tostring(log_research.name))
|
||||
if technology.level > log_research.level then
|
||||
queue_research(force, event.by_script)
|
||||
end
|
||||
end
|
||||
|
||||
local e = defines.events
|
||||
|
||||
return {
|
||||
commands = commands,
|
||||
events = {
|
||||
[e.on_research_finished] = on_research_finished,
|
||||
},
|
||||
}
|
||||
@@ -88,6 +88,37 @@ local function try_deconstruct_output_chest(entity)
|
||||
order_deconstruction_async:start_after(10, target)
|
||||
end
|
||||
|
||||
--- Check if beacon should be deconstructed
|
||||
--- @param entity LuaEntity
|
||||
local function try_deconstruct_nearby_beacon(entity)
|
||||
-- Get a valid chest as the target
|
||||
local beacons = entity.get_beacons()
|
||||
local beacon_in_use = false
|
||||
|
||||
-- if beacon is not supported
|
||||
if not beacons then
|
||||
return
|
||||
end
|
||||
|
||||
for _, b in pairs(beacons) do
|
||||
if not b.to_be_deconstructed() then
|
||||
for _, r in pairs(b.get_beacon_effect_receivers()) do
|
||||
if r ~= entity then
|
||||
if not r.to_be_deconstructed() then
|
||||
beacon_in_use = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Deconstruct the beacon
|
||||
if not beacon_in_use then
|
||||
order_deconstruction_async:start_after(10, { name = b.name, position = b.position })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Check if a miner should be deconstructed
|
||||
--- @param entity LuaEntity
|
||||
local function try_deconstruct_miner(entity)
|
||||
@@ -117,11 +148,13 @@ local function try_deconstruct_miner(entity)
|
||||
try_deconstruct_output_chest(entity)
|
||||
end
|
||||
|
||||
--[[
|
||||
TODO Fluidbox is changed to fluidbox_neighbours
|
||||
-- Try deconstruct the beacon
|
||||
if config.beacon then
|
||||
try_deconstruct_nearby_beacon(entity)
|
||||
end
|
||||
|
||||
-- Skip pipe build if not required
|
||||
if not config.fluid or #entity.fluidbox == 0 then
|
||||
if not config.fluid or entity.fluids_count > 1 then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -189,11 +222,19 @@ local function try_deconstruct_miner(entity)
|
||||
]]
|
||||
end
|
||||
|
||||
local max_quality = ""
|
||||
|
||||
for _, q in pairs(prototypes.quality) do
|
||||
if not q.next then
|
||||
max_quality = q.name
|
||||
end
|
||||
end
|
||||
|
||||
--- Get the max mining radius
|
||||
local max_mining_radius = 0
|
||||
for _, proto in pairs(prototypes.get_entity_filtered{ { filter = "type", type = "mining-drill" } }) do
|
||||
if proto.mining_drill_radius > max_mining_radius then
|
||||
max_mining_radius = proto.mining_drill_radius
|
||||
if proto.mining_drill_radius then
|
||||
max_mining_radius = math.max(proto.get_mining_drill_radius(max_quality), max_mining_radius)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -218,8 +259,8 @@ local function on_resource_depleted(event)
|
||||
-- Check which could have reached this resource
|
||||
for _, drill in pairs(drills) do
|
||||
local radius = drill.prototype.mining_drill_radius
|
||||
local dx = math.abs(drill.position.x - resource.position.x)
|
||||
local dy = math.abs(drill.position.y - resource.position.y)
|
||||
local dx = math.abs(drill.position.x - position.x)
|
||||
local dy = math.abs(drill.position.y - position.y)
|
||||
if dx <= radius and dy <= radius then
|
||||
try_deconstruct_miner(drill)
|
||||
end
|
||||
|
||||
@@ -41,6 +41,8 @@ local e = defines.events
|
||||
return {
|
||||
events = {
|
||||
[e.on_research_finished] = on_research_finished,
|
||||
[e.on_research_reversed] = on_research_finished,
|
||||
[e.on_research_started] = on_research_started,
|
||||
[e.on_research_queued] = on_research_started,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,13 @@ local Commands = require("modules/exp_commands")
|
||||
local Roles = require("modules/exp_legacy/expcore/roles")
|
||||
|
||||
local addon_artillery = require("modules/exp_scenario/commands/artillery")
|
||||
local addon_research = require("modules/exp_scenario/commands/research")
|
||||
local addon_trains = require("modules/exp_scenario/commands/trains")
|
||||
local addon_teleport = require("modules/exp_scenario/commands/teleport")
|
||||
local addon_waterfill = require("modules/exp_scenario/commands/waterfill")
|
||||
local addon_lawnmower = require("modules/exp_scenario/commands/lawnmower")
|
||||
local addon_home = require("modules/exp_scenario/commands/home")
|
||||
local addon_vlayer = require("modules/exp_scenario/commands/vlayer")
|
||||
local addon_repair = require("modules/exp_scenario/commands/repair")
|
||||
|
||||
--- @class ExpGui_QuickActions.elements
|
||||
local Elements = {}
|
||||
@@ -46,18 +47,17 @@ end
|
||||
|
||||
new_quick_action("artillery", addon_artillery.commands.artillery)
|
||||
new_quick_action("trains", addon_trains.commands.set_trains_to_automatic)
|
||||
new_quick_action("research", addon_research.commands.set_auto_research)
|
||||
|
||||
new_quick_action("spawn", addon_teleport.commands.spawn, function(def, player, element, event)
|
||||
new_quick_action("spawn", addon_teleport.commands.spawn, function(_def, player, _element, _event)
|
||||
addon_teleport.commands.spawn(player, player)
|
||||
end)
|
||||
|
||||
new_quick_action("waterfill", addon_waterfill.commands.waterfill)
|
||||
new_quick_action("lawnmower", addon_lawnmower.commands.lawnmower)
|
||||
new_quick_action("home", addon_home.commands.home)
|
||||
new_quick_action("return", addon_home.commands._return)
|
||||
new_quick_action("set-home", addon_home.commands.set_home)
|
||||
new_quick_action("get-home", addon_home.commands.get_home)
|
||||
new_quick_action("vlayer", addon_vlayer.commands.vlayer)
|
||||
new_quick_action("repair", addon_repair.commands.repair)
|
||||
|
||||
--- Container added to the left gui flow
|
||||
--- @class ExpGui_QuickActions.elements.container: ExpElement
|
||||
|
||||
@@ -103,6 +103,10 @@ lower-role=You must have a higher role than the target.
|
||||
[exp-commands_lawnmower]
|
||||
description=Clean up biter corpse, decoratives and nuclear hole.
|
||||
arg-range=Range to clean up.
|
||||
enter=Entered selection mode, select the area to fill with water.
|
||||
exit=Exited selection mode.
|
||||
area-too-large=Selected area is too large, must be less than __1__ tiles, selected __2__.
|
||||
complete=__1__ tiles were handled.
|
||||
|
||||
[exp-commands_locate]
|
||||
description=Opens remote view at the location of the player's last location.
|
||||
@@ -155,7 +159,8 @@ machine-count=And you will need __1__ machines (with the same speed as this one)
|
||||
|
||||
[exp-commands_repair]
|
||||
description=Repairs entities on your force around you.
|
||||
arg-range=Range to repair entities within.
|
||||
enter=Entered selection mode, select the area.
|
||||
exit=Exited selection mode.
|
||||
# Intentional space left on the two lines below so they can be joined together.
|
||||
response-revive=__1__ entities were revived.
|
||||
response-heal=__1__ entities were healed.
|
||||
@@ -182,12 +187,6 @@ list-element=__1__: __2__
|
||||
removed-all=__1__ has has all of their reports removed by __2__.
|
||||
removed=__1__ has a report removed by __2__.
|
||||
|
||||
[exp-commands_research]
|
||||
description=Sets research to be automatically queued.
|
||||
arg-state=State to set, default is to toggle.
|
||||
auto-research=__1__ set auto research to __2__
|
||||
queue=[color=255, 255, 255] Research added to queue - [technology=__1__] - __2__[/color]
|
||||
|
||||
[exp-commands_roles]
|
||||
description-assign=Assigns a role to a player.
|
||||
description-unassign=Unassigns a role from a player.
|
||||
|
||||
@@ -182,12 +182,6 @@ list-element=__1__: __2__
|
||||
removed-all=__1__ 被舉報的所有紀錄已被 __2__ 清除。
|
||||
removed=__1__ 被舉報的一個紀錄已被 __2__ 清除。
|
||||
|
||||
[exp-commands_research]
|
||||
description=啟用自動研究
|
||||
arg-state=狀態
|
||||
auto-research=__1__ 把自動研究設置為 __2__ 。
|
||||
queue=[color=255, 255, 255] 研究已加入隊列 - [technology=__1__] - __2__[/color]
|
||||
|
||||
[exp-commands_roles]
|
||||
description-assign=為用戶指配用戶組
|
||||
description-unassign=為用戶取消指配用戶組
|
||||
|
||||
@@ -182,12 +182,6 @@ list-element=__1__: __2__
|
||||
removed-all=__1__ 被舉報的所有紀錄已被 __2__ 清除。
|
||||
removed=__1__ 被舉報的一個紀錄已被 __2__ 清除。
|
||||
|
||||
[exp-commands_research]
|
||||
description=啟用自動研究
|
||||
arg-state=狀態
|
||||
auto-research=__1__ 把自動研究設置為 __2__ 。
|
||||
queue=[color=255, 255, 255] 研究已加入隊列 - [technology=__1__] - __2__[/color]
|
||||
|
||||
[exp-commands_roles]
|
||||
description-assign=為用戶指配用戶組
|
||||
description-unassign=為用戶取消指配用戶組
|
||||
|
||||
Reference in New Issue
Block a user