-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrobots.lua
178 lines (158 loc) · 4.17 KB
/
robots.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
utility = require("utility")
circuits = {
"electronic-circuit",
"advanced-circuit",
"processing-unit",
}
function get_fast_tiered_spec(tier)
return {
speed = 2 ^ tier,
cargo = tier,
battery = (2 ^ tier) ^ 0.8,
efficiency = (2 ^ tier) ^ 0.2,
}
end
function get_heavy_tiered_spec(tier)
return {
speed = tier,
cargo = 2 ^ tier,
battery = tier ^ 0.8,
efficiency = tier ^ 0.2,
}
end
function register(base_entity, base_item, name, spec, ingredients, icon)
local entity = table.deepcopy(base_entity)
entity.name = name
entity.minable.result = name
entity.speed = entity.speed * spec.speed
entity.max_payload_size = entity.max_payload_size * spec.cargo
entity.max_energy = utility.multiply_unit_value(entity.max_energy, spec.battery)
entity.energy_per_move = utility.multiply_unit_value(entity.energy_per_move, 1 / spec.efficiency)
local item = table.deepcopy(base_item)
item.name = name
item.place_result = name
item.icons = {
{
icon = item.icon,
},
{
icon = icon,
draw_background = true,
},
}
local recipe = {
type = "recipe",
name = name,
enabled = false,
energy_required = 1,
ingredients = table.deepcopy(ingredients),
results = { { type = "item", name = name, amount = 1 } },
}
if utility.any(ingredients, function(x)
return x.type == "fluid"
end) then
recipe.category = "crafting-with-fluid"
end
data:extend({ entity, item, recipe })
end
-- Fast construction robot MK1-3 --
for i = 1, 3 do
name = utility.get_tiered_robot_name("construction", "fast", i)
prev = utility.get_tiered_robot_name("construction", "fast", i - 1)
ingredients = {
{ type = "item", name = prev, amount = 2 },
{ type = "item", name = circuits[i], amount = 2 },
{ type = "item", name = "low-density-structure", amount = 2 },
}
if i == 3 then
table.insert(ingredients, {
type = "fluid",
name = "lubricant",
amount = 10,
})
end
register(
data.raw["construction-robot"]["construction-robot"],
data.raw["item"]["construction-robot"],
name,
get_fast_tiered_spec(i),
ingredients,
string.format("__advanced-robots__/graphics/F%d.png", i)
)
end
-- Heavy construction robot MK1-3 --
for i = 1, 3 do
name = utility.get_tiered_robot_name("construction", "heavy", i)
prev = utility.get_tiered_robot_name("construction", "heavy", i - 1)
ingredients = {
{ type = "item", name = prev, amount = 2 },
{ type = "item", name = circuits[i], amount = 2 },
{ type = "item", name = "low-density-structure", amount = 2 },
}
if i == 3 then
table.insert(ingredients, {
type = "fluid",
name = "lubricant",
amount = 10,
})
end
register(
data.raw["construction-robot"]["construction-robot"],
data.raw["item"]["construction-robot"],
name,
get_heavy_tiered_spec(i),
ingredients,
string.format("__advanced-robots__/graphics/H%d.png", i)
)
end
-- Fast logistic robot MK1-3 --
for i = 1, 3 do
name = utility.get_tiered_robot_name("logistic", "fast", i)
prev = utility.get_tiered_robot_name("logistic", "fast", i - 1)
ingredients = {
{ type = "item", name = prev, amount = 2 },
{ type = "item", name = circuits[i], amount = 2 },
{ type = "item", name = "low-density-structure", amount = 2 },
}
if i == 3 then
table.insert(ingredients, {
type = "fluid",
name = "lubricant",
amount = 10,
})
end
register(
data.raw["logistic-robot"]["logistic-robot"],
data.raw["item"]["logistic-robot"],
name,
get_fast_tiered_spec(i),
ingredients,
string.format("__advanced-robots__/graphics/F%d.png", i)
)
end
-- Heavy logistic robot MK1-3 --
for i = 1, 3 do
tmpl = "yokaze-heavy-logistic-robot-mk%d"
name = utility.get_tiered_robot_name("logistic", "heavy", i)
prev = utility.get_tiered_robot_name("logistic", "heavy", i - 1)
ingredients = {
{ type = "item", name = prev, amount = 2 },
{ type = "item", name = circuits[i], amount = 2 },
{ type = "item", name = "low-density-structure", amount = 2 },
}
if i == 3 then
table.insert(ingredients, {
type = "fluid",
name = "lubricant",
amount = 10,
})
end
register(
data.raw["logistic-robot"]["logistic-robot"],
data.raw["item"]["logistic-robot"],
name,
get_heavy_tiered_spec(i),
ingredients,
string.format("__advanced-robots__/graphics/H%d.png", i)
)
end