-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutility.lua
56 lines (51 loc) · 1.26 KB
/
utility.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
function any(arr, pred)
for _, value in ipairs(arr) do
if pred(value) then
return true
end
end
return false
end
function multiply_unit_value(unit_value, ratio)
local value = string.match(unit_value, "([%d%.]+)")
return string.gsub(unit_value, value, tonumber(value) * ratio)
end
function get_tiered_roboport_name(tier)
if tier == 0 then
return "roboport"
else
return string.format("yokaze-wide-roboport-mk%d", tier)
end
end
-- category: construction or logistic
-- sub: fast or heavy
function get_tiered_robot_name(category, sub, tier)
if tier == 0 then
if category == "construction" then
return "construction-robot"
else
return "logistic-robot"
end
else
local tmpl = "yokaze-%s-%s-robot-mk%d"
return string.format(tmpl, sub, category, tier)
end
end
function get_tiered_robot_research_name(category, sub, tier)
if tier == 0 then
if category == "construction" then
return "construction-robotics"
else
return "logistic-robotics"
end
else
return get_tiered_robot_name(category, sub, tier)
end
end
return {
any = any,
get_tiered_roboport_name = get_tiered_roboport_name,
get_tiered_robot_name = get_tiered_robot_name,
get_tiered_robot_research_name = get_tiered_robot_research_name,
multiply_unit_value = multiply_unit_value,
}