-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtechnologies.lua
More file actions
66 lines (53 loc) · 2.23 KB
/
Copy pathtechnologies.lua
File metadata and controls
66 lines (53 loc) · 2.23 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
local state = require("state")
local technologies = {}
function prerequisites(technology)
local result = {}
for name, prereq in pairs(technology.prerequisites) do
table.insert(result, "technology-" .. name)
end
return next(result) and result or nil
end
function technologies.technology(technology)
local result = {prerequisites = prerequisites(technology)}
for _, effect in ipairs(technology.effects) do
if effect.type == "belt-stack-size-bonus" then
result.beltStack = (result.beltStack or 0) + effect.modifier
state.flags["beltStack"] = true
elseif effect.type == "bulk-inserter-stack-size-bonus" then
if not result.inserterStack then
result.inserterStack = {}
end
table.insert(result.inserterStack, {value = effect.modifier, category = "bulk"})
elseif effect.type == "change-recipe-productivity" then
if not result.recipeProductivity then
result.recipeProductivity = {}
end
table.insert(result.recipeProductivity, {id = effect.recipe, value = effect.change})
elseif effect.type == "inserter-stack-size-bonus" then
if not result.inserterStack then
result.inserterStack = {}
end
table.insert(result.inserterStack, {value = effect.modifier})
elseif effect.type == "laboratory-productivity" then
result.researchProductivity = (result.researchProductivity or 0) + effect.modifier
state.flags["researchProductivity"] = true
elseif effect.type == "laboratory-speed" then
result.researchSpeed = (result.researchSpeed or 0) + effect.modifier
elseif effect.type == "mining-drill-productivity-bonus" then
result.miningProductivity = (result.miningProductivity or 0) + effect.modifier
elseif effect.type == "unlock-quality" then
if not result.qualityUnlock then
result.qualityUnlock = {}
end
table.insert(result.qualityUnlock, effect.quality)
elseif effect.type == "unlock-recipe" then
if not result.recipeUnlock then
result.recipeUnlock = {}
end
table.insert(result.recipeUnlock, effect.recipe)
state.recipes_locked[effect.recipe] = true
end
end
return result
end
return technologies