-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroboports.lua
100 lines (89 loc) · 2.36 KB
/
roboports.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
utility = require("utility")
circuits = {
"electronic-circuit",
"advanced-circuit",
"processing-unit",
}
if mods["aai-industry"] then
parts = {
"copper-cable",
"electric-motor",
"electric-engine-unit",
}
else
parts = {
"copper-cable",
"engine-unit",
"electric-engine-unit",
}
end
parallels = { 6, 8, 12 }
function register(base_entity, base_item, name, spec, ingredients, icon)
local entity = table.deepcopy(base_entity)
entity.name = name
entity.construction_radius = entity.construction_radius * spec.range
entity.logistics_radius = entity.logistics_radius * spec.range
entity.minable.result = name
entity.energy_source.buffer_capacity =
utility.multiply_unit_value(entity.energy_source.buffer_capacity, spec.battery)
entity.energy_source.input_flow_limit =
utility.multiply_unit_value(entity.energy_source.input_flow_limit, spec.battery)
entity.energy_usage = utility.multiply_unit_value(entity.energy_usage, spec.usage)
width = entity.charging_offsets[1][1]
height = entity.charging_offsets[1][2]
entity.charging_energy = utility.multiply_unit_value(entity.charging_energy, spec.charge)
if spec.parallel ~= 4 then
offsets = {}
for i = 1, spec.parallel do
rad = (2 * math.pi * i) / spec.parallel
table.insert(offsets, { math.cos(rad) * width, math.sin(rad) * height })
end
entity.charging_offsets = offsets
end
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 = 10,
ingredients = table.deepcopy(ingredients),
results = { { type = "item", name = name, amount = 1 } },
}
data:extend({ entity, item, recipe })
end
-- Wide roboport MK1-3 --
for i = 1, 3 do
name = utility.get_tiered_roboport_name(i)
prev = utility.get_tiered_roboport_name(i - 1)
spec = {
range = 2 ^ i,
charge = 2 ^ i,
parallel = parallels[i],
battery = (2 ^ i) * parallels[i] / 4,
usage = 4 ^ i,
}
ingredients = {
{ type = "item", name = prev, amount = 1 },
{ type = "item", name = circuits[i], amount = 50 },
{ type = "item", name = parts[i], amount = 50 },
}
register(
data.raw["roboport"]["roboport"],
data.raw["item"]["roboport"],
name,
spec,
ingredients,
string.format("__advanced-robots__/graphics/W%d.png", i)
)
end