Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Research #293

Merged
merged 10 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -1080,8 +1080,10 @@ do -- Factorio Defines STDs--
'on_robot_built_entity',
'on_robot_pre_mined',
'on_robot_mined',
'on_research_started',
'on_research_cancelled',
'on_research_finished',
'on_research_reversed',
'on_research_started',
'on_player_rotated_entity',
'on_player_set_quickbar_slot',
'on_marked_for_deconstruction',
Expand Down
1 change: 1 addition & 0 deletions locale/en/commands.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ ff=Friendly fire is set to __1__
res=Auto Research is set to __1__
msg=[color=255, 255, 255] Research Completed at __1__ - [technology=__2__][/color]
inf=[color=255, 255, 255] Research Completed at __1__ - [technology=__2__] - __3__[/color]
inf-q=[color=255, 255, 255] Research Added to Queue - [technology=__1__] - __2__[/color]
main-tooltip=Research GUI

[expcom-waterfill]
Expand Down
1 change: 1 addition & 0 deletions locale/zh-CN/commands.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ ff=Friendly fire is set to __1__
res=Auto Research is set to __1__
msg=[color=255, 255, 255] Research Completed at __1__ - [technology=__2__][/color]
inf=[color=255, 255, 255] Research Completed at __1__ - [technology=__2__] - __3__[/color]
inf-q=[color=255, 255, 255] Research Added to Queue - [technology=__1__] - __2__[/color]
main-tooltip=Research GUI

[expcom-waterfill]
Expand Down
1 change: 1 addition & 0 deletions locale/zh-TW/commands.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ ff=Friendly fire is set to __1__
res=Auto Research is set to __1__
msg=[color=255, 255, 255] Research Completed at __1__ - [technology=__2__][/color]
inf=[color=255, 255, 255] Research Completed at __1__ - [technology=__2__] - __3__[/color]
inf-q=[color=255, 255, 255] Research Added to Queue - [technology=__1__] - __2__[/color]
main-tooltip=Research GUI

[expcom-waterfill]
Expand Down
25 changes: 17 additions & 8 deletions modules/commands/research.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ local function research_notification(event)
if (event.research.force.mining_drill_productivity_bonus * 10) <= (config.bonus_inventory.limit / config.bonus_inventory.rate) then
if event.research.force.technologies['toolbelt'].researched then
event.research.force[config.bonus_inventory.name] = (math.floor(event.research.force.mining_drill_productivity_bonus * 10) * config.bonus_inventory.rate) + 10

else
event.research.force[config.bonus_inventory.name] = math.floor(event.research.force.mining_drill_productivity_bonus * 10) * config.bonus_inventory.rate
end
Expand All @@ -56,34 +57,42 @@ local function research_notification(event)
if not (event.by_script) then
game.print{'expcom-res.inf', format_time(game.tick, research_time_format), event.research.name, event.research.level - 1}
end

else
if not (event.by_script) then
game.print{'expcom-res.msg', format_time(game.tick, research_time_format), event.research.name}
end
end
end

local function res_queue(force)
if force.rockets_launched == 0 or force.technologies['mining-productivity-4'].level <= 4 then
local function res_queue(event)
if event.research.force.rockets_launched == 0 or event.research.force.technologies['mining-productivity-4'].level <= 4 then
return
end

local res_q = force.research_queue
local res_q = event.research.research_queue

if #res_q < config.queue_amount then
for i=1, config.queue_amount - #res_q do
force.add_research(force.technologies['mining-productivity-4'])
event.research.force.add_research(event.research.force.technologies['mining-productivity-4'])

if not (event.by_script) then
game.print{'expcom-res.inf-q', event.research.name, event.research.level + i}
end
end
end
end

Event.add(defines.events.on_research_finished, function(event)
local function research_queue_logic(event)
research_notification(event)

if research.res_queue_enable then
res_queue(event.research.force)
res_queue(event)
end
end)
end

Event.add(defines.events.on_research_finished, research_queue_logic)
Event.add(defines.events.on_research_cancelled, research_queue_logic)

Commands.new_command('auto-research', 'Automatically queue up research')
:add_alias('ares')
Expand All @@ -94,5 +103,5 @@ Commands.new_command('auto-research', 'Automatically queue up research')
res_queue(player.force)
end

return Commands.success{'expcom-res.res', research.res_queue_enable}
return game.print{'expcom-res.res', research.res_queue_enable}
end)
Loading