diff --git a/exp_legacy/module/config/expcore/roles.lua b/exp_legacy/module/config/expcore/roles.lua index a392953f..3b1b8023 100644 --- a/exp_legacy/module/config/expcore/roles.lua +++ b/exp_legacy/module/config/expcore/roles.lua @@ -206,7 +206,6 @@ Roles.new_role("Veteran", "Vet") "command/clear-ground-items", "command/clear-blueprints-radius", "command/set-trains-to-automatic", - "command/set-auto-research", } :set_auto_assign_condition(function(player) if player.online_time >= hours10 then diff --git a/exp_legacy/module/config/research.lua b/exp_legacy/module/config/research.lua index e9e53f63..c6316b6e 100644 --- a/exp_legacy/module/config/research.lua +++ b/exp_legacy/module/config/research.lua @@ -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, diff --git a/exp_scenario/module/commands/research.lua b/exp_scenario/module/commands/research.lua deleted file mode 100644 index 3d00d122..00000000 --- a/exp_scenario/module/commands/research.lua +++ /dev/null @@ -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, - }, -} diff --git a/exp_scenario/module/control/research.lua b/exp_scenario/module/control/research.lua index 7b8dcf77..4d885740 100644 --- a/exp_scenario/module/control/research.lua +++ b/exp_scenario/module/control/research.lua @@ -12,7 +12,7 @@ local function on_research_finished(event) if config.bonus_inventory.enabled and config.bonus_inventory.res[research_name] then event.research.force[config.bonus_inventory.name] = math.min((event.research.level - 1) * config.bonus_inventory.rate, config.bonus_inventory.limit) end - + if config.pollution_ageing_by_research and config.bonus_inventory.res[research_name] then game.map_settings.pollution.ageing = math.min(10, event.research.level / 5) 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, } } diff --git a/exp_scenario/module/gui/quick_actions.lua b/exp_scenario/module/gui/quick_actions.lua index 17847a8f..3bead1e8 100644 --- a/exp_scenario/module/gui/quick_actions.lua +++ b/exp_scenario/module/gui/quick_actions.lua @@ -7,7 +7,6 @@ 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") @@ -48,12 +47,9 @@ 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) diff --git a/exp_scenario/module/locale/en.cfg b/exp_scenario/module/locale/en.cfg index 70572e03..51f105f5 100644 --- a/exp_scenario/module/locale/en.cfg +++ b/exp_scenario/module/locale/en.cfg @@ -187,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. diff --git a/exp_scenario/module/locale/zh-CN.cfg b/exp_scenario/module/locale/zh-CN.cfg index b08f6ba1..625f2394 100644 --- a/exp_scenario/module/locale/zh-CN.cfg +++ b/exp_scenario/module/locale/zh-CN.cfg @@ -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=為用戶取消指配用戶組 diff --git a/exp_scenario/module/locale/zh-TW.cfg b/exp_scenario/module/locale/zh-TW.cfg index b08f6ba1..625f2394 100644 --- a/exp_scenario/module/locale/zh-TW.cfg +++ b/exp_scenario/module/locale/zh-TW.cfg @@ -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=為用戶取消指配用戶組