|
1 ---@class AqsScienceArgs |
|
2 ---@field count? int |
|
3 ---@field count_formula? string |
|
4 ---@field time int |
|
5 |
|
6 --- @param args AqsScienceArgs |
|
7 --- @return data.TechnologyUnit |
|
8 function red_science(args) |
|
9 return { |
|
10 count = args.count, |
|
11 count_formula = args.count_formula, |
|
12 time = args.time, |
|
13 ingredients = { |
|
14 {"automation-science-pack", 1}, |
|
15 }, |
|
16 } |
|
17 end |
|
18 |
|
19 --- @param args AqsScienceArgs |
|
20 function green_science(args) |
|
21 local x = red_science(args) |
|
22 table.insert(x.ingredients, {"logistic-science-pack", 1}) |
|
23 return x |
|
24 end |
|
25 |
|
26 --- @param args AqsScienceArgs |
|
27 function blue_science(args) |
|
28 local x = green_science(args) |
|
29 table.insert(x.ingredients, {"chemical-science-pack", 1}) |
|
30 return x |
|
31 end |
|
32 |
|
33 --- @param args AqsScienceArgs |
|
34 function cryo_science(args) |
|
35 local x = blue_science(args) |
|
36 table.insert(x.ingredients, {"cryogenic-science-pack", 1}) |
|
37 return x |
|
38 end |
|
39 |
|
40 ---@return data.ItemIngredientPrototype |
|
41 function item(name, amount) |
|
42 return {type="item", name=name, amount=amount or 1} |
|
43 end |
|
44 |
|
45 ---@return data.FluidIngredientPrototype |
|
46 function fluid(name, amount) |
|
47 return {type = "fluid", name = name, amount = amount} |
|
48 end |
|
49 |
|
50 ---@param technology data.TechnologyPrototype |
|
51 ---@param x string |
|
52 function remove_recipe_effect(technology, x) |
|
53 ---@type (data.Modifier)[] |
|
54 local list2 = {} |
|
55 for k, v in pairs(technology.effects) |
|
56 do |
|
57 if v.type ~= "unlock-recipe" or v.recipe ~= x |
|
58 then |
|
59 table.insert(list2, v) |
|
60 end |
|
61 end |
|
62 technology.effects = list2 |
|
63 end |
|
64 |
|
65 ---@param technology data.TechnologyPrototype |
|
66 ---@param x data.Modifier |
|
67 function remove_effect(technology, x) |
|
68 ---@type (data.Modifier)[] |
|
69 local list2 = {} |
|
70 for _, technology_effect in pairs(technology.effects or {}) |
|
71 do |
|
72 local match = true |
|
73 for key, value in pairs(x) |
|
74 do |
|
75 if technology_effect[key] ~= value |
|
76 then |
|
77 match = false |
|
78 break |
|
79 end |
|
80 end |
|
81 if not match |
|
82 then |
|
83 table.insert(list2, technology_effect) |
|
84 end |
|
85 end |
|
86 technology.effects = list2 |
|
87 end |
|
88 |
|
89 ---@param recipe_name string |
|
90 ---@return data.UnlockRecipeModifier |
|
91 function unlock_recipe(recipe_name) |
|
92 return {type = "unlock-recipe", recipe = recipe_name} |
|
93 end |
|
94 |
|
95 ---@param recipe_name string |
|
96 ---@return data.ChangeRecipeProductivityModifier |
|
97 function recipe_productivity(recipe_name) |
|
98 return { |
|
99 type = "change-recipe-productivity", |
|
100 recipe = recipe_name, |
|
101 change = 0.1, |
|
102 } |
|
103 end |
|
104 |
|
105 ---@alias SciencePack "automation-science-pack"|"logistic-science-pack"|"chemical-science-pack"|"production-science-pack"|"utility-science-pack"|"metallurgic-science-pack"|"nuclear-science-pack"|"electromagnetic-science-pack"|"cryogenic-science-pack"|"promethium-science-pack"|"agricultural-science-pack" |
|
106 |
|
107 ---@param technology data.TechnologyPrototype |
|
108 ---@param x SciencePack |
|
109 function is_in_unit(technology, x) |
|
110 print(technology.name) |
|
111 if technology.unit |
|
112 then |
|
113 for k,v in pairs(technology.unit.ingredients) |
|
114 do |
|
115 if v[1] == x |
|
116 then |
|
117 return true |
|
118 end |
|
119 end |
|
120 end |
|
121 return false |
|
122 end |
|
123 |
|
124 ---@param technology data.TechnologyPrototype |
|
125 ---@param x string |
|
126 ---@param y string |
|
127 function replace_in_prerequisites(technology, x, y) |
|
128 if technology.prerequisites ~= nil |
|
129 then |
|
130 for k, v in pairs(technology.prerequisites) |
|
131 do |
|
132 if technology.prerequisites[k] == x |
|
133 then |
|
134 technology.prerequisites[k] = y |
|
135 break |
|
136 end |
|
137 end |
|
138 end |
|
139 end |
|
140 |
|
141 ---@param technology data.TechnologyPrototype |
|
142 ---@param x SciencePack |
|
143 ---@param y SciencePack |
|
144 function replace_in_unit(technology, x, y) |
|
145 if technology.unit |
|
146 then |
|
147 technology.unit = table.deepcopy(technology.unit) |
|
148 for k,v in pairs(technology.unit.ingredients) |
|
149 do |
|
150 if v[1] == x |
|
151 then |
|
152 v[1] = y |
|
153 break |
|
154 end |
|
155 end |
|
156 end |
|
157 replace_in_prerequisites(technology, x, y) |
|
158 end |
|
159 |
|
160 ---@param technology data.TechnologyPrototype |
|
161 ---@param x SciencePack |
|
162 function delete_from_unit(technology, x) |
|
163 if technology.unit |
|
164 then |
|
165 local new_ingredients = {} |
|
166 for k,v in pairs(technology.unit.ingredients) |
|
167 do |
|
168 if v[1] ~= x |
|
169 then |
|
170 table.insert(new_ingredients, v) |
|
171 end |
|
172 end |
|
173 technology.unit.ingredients = new_ingredients |
|
174 end |
|
175 if technology.prerequisites ~= nil |
|
176 then |
|
177 local new_prerequisites = {} |
|
178 for k, v in pairs(technology.prerequisites) |
|
179 do |
|
180 if v ~= x |
|
181 then |
|
182 table.insert(new_prerequisites, v) |
|
183 end |
|
184 end |
|
185 technology.prerequisites = new_prerequisites |
|
186 end |
|
187 end |