forked from remijouannet/graftorio2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
research.lua
42 lines (37 loc) · 1.17 KB
/
research.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function on_research_finished(event)
local research = event.research
if not global.last_research then
global.last_research = {}
end
local level = research.level
-- Previous research is incorrect lvl if it has more than one research
if level > 1 then
level = level - 1
end
global.last_research[research.force.name] = {
researched = 1,
name = research.name,
level = level,
}
end
function on_research_tick(player, event)
if event.tick then
gauge_research_queue:reset()
local researched_queue = global.last_research and global.last_research["player.force.name"] or false
if researched_queue then
gauge_research_queue:set(
researched_queue.researched and 1 or 0,
{ player.force.name, researched_queue.name, researched_queue.level, -1 }
)
end
-- Levels dont get matched properly so store and save
local levels = {}
for idx, tech in pairs(player.force.research_queue or { player.force.current_research }) do
levels[tech.name] = levels[tech.name] and levels[tech.name] + 1 or tech.level
gauge_research_queue:set(
idx == 1 and player.force.research_progress or 0,
{ player.force.name, tech.name, levels[tech.name], idx }
)
end
end
end