research changes (#430)

* Add event handlers for research reversed and queued

* Update roles.lua

* Remove bonus inventory settings from research.lua

Removed bonus inventory configuration for mining productivity.

* Update en.cfg

* Update zh-CN.cfg

* Update zh-TW.cfg

* Update research.lua

* Delete exp_scenario/module/commands/research.lua

* Update quick_actions.lua

* Update research.lua

* Update research.lua

* Update research.lua
This commit is contained in:
2026-06-26 11:56:24 +01:00
committed by GitHub
parent 21779988f0
commit 3a8d83f981
8 changed files with 4 additions and 125 deletions
@@ -206,7 +206,6 @@ Roles.new_role("Veteran", "Vet")
"command/clear-ground-items", "command/clear-ground-items",
"command/clear-blueprints-radius", "command/clear-blueprints-radius",
"command/set-trains-to-automatic", "command/set-trains-to-automatic",
"command/set-auto-research",
} }
:set_auto_assign_condition(function(player) :set_auto_assign_condition(function(player)
if player.online_time >= hours10 then if player.online_time >= hours10 then
-10
View File
@@ -12,16 +12,6 @@ return {
-- this enable 20 more inventory for each mining productivity level up to 4 -- this enable 20 more inventory for each mining productivity level up to 4
bonus_inventory = { bonus_inventory = {
enabled = true, enabled = true,
log = {
["base"] = {
["name"] = "mining-productivity-4",
["level"] = 4
},
["space-age"] = {
["name"] = "mining-productivity-3",
["level"] = 3
},
},
res = { res = {
-- Mining Productivity -- Mining Productivity
["mining-productivity"] = true, ["mining-productivity"] = true,
-90
View File
@@ -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,
},
}
+2
View File
@@ -41,6 +41,8 @@ local e = defines.events
return { return {
events = { events = {
[e.on_research_finished] = on_research_finished, [e.on_research_finished] = on_research_finished,
[e.on_research_reversed] = on_research_finished,
[e.on_research_started] = on_research_started, [e.on_research_started] = on_research_started,
[e.on_research_queued] = on_research_started,
} }
} }
+1 -5
View File
@@ -7,7 +7,6 @@ local Commands = require("modules/exp_commands")
local Roles = require("modules/exp_legacy/expcore/roles") local Roles = require("modules/exp_legacy/expcore/roles")
local addon_artillery = require("modules/exp_scenario/commands/artillery") 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_trains = require("modules/exp_scenario/commands/trains")
local addon_teleport = require("modules/exp_scenario/commands/teleport") local addon_teleport = require("modules/exp_scenario/commands/teleport")
local addon_waterfill = require("modules/exp_scenario/commands/waterfill") 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("artillery", addon_artillery.commands.artillery)
new_quick_action("trains", addon_trains.commands.set_trains_to_automatic) 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) addon_teleport.commands.spawn(player, player)
end) end)
new_quick_action("waterfill", addon_waterfill.commands.waterfill) new_quick_action("waterfill", addon_waterfill.commands.waterfill)
new_quick_action("lawnmower", addon_lawnmower.commands.lawnmower) new_quick_action("lawnmower", addon_lawnmower.commands.lawnmower)
new_quick_action("home", addon_home.commands.home) new_quick_action("home", addon_home.commands.home)
-6
View File
@@ -187,12 +187,6 @@ list-element=__1__: __2__
removed-all=__1__ has has all of their reports removed by __2__. removed-all=__1__ has has all of their reports removed by __2__.
removed=__1__ has a report 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] [exp-commands_roles]
description-assign=Assigns a role to a player. description-assign=Assigns a role to a player.
description-unassign=Unassigns a role from a player. description-unassign=Unassigns a role from a player.
-6
View File
@@ -182,12 +182,6 @@ list-element=__1__: __2__
removed-all=__1__ 被舉報的所有紀錄已被 __2__ 清除。 removed-all=__1__ 被舉報的所有紀錄已被 __2__ 清除。
removed=__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] [exp-commands_roles]
description-assign=為用戶指配用戶組 description-assign=為用戶指配用戶組
description-unassign=為用戶取消指配用戶組 description-unassign=為用戶取消指配用戶組
-6
View File
@@ -182,12 +182,6 @@ list-element=__1__: __2__
removed-all=__1__ 被舉報的所有紀錄已被 __2__ 清除。 removed-all=__1__ 被舉報的所有紀錄已被 __2__ 清除。
removed=__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] [exp-commands_roles]
description-assign=為用戶指配用戶組 description-assign=為用戶指配用戶組
description-unassign=為用戶取消指配用戶組 description-unassign=為用戶取消指配用戶組