-
Notifications
You must be signed in to change notification settings - Fork 20
/
constructron_pathing_proxy.lua
60 lines (53 loc) · 1.79 KB
/
constructron_pathing_proxy.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
local collision_mask_util_extended = require("data/collision-mask-util-extended")
local pathing_collision_mask = {
"water-tile",
"colliding-with-tiles-only",
"not-colliding-with-itself"
}
if mods["space-exploration"] then
local spaceship_collision_layer = collision_mask_util_extended.get_named_collision_mask("moving-tile")
table.insert(pathing_collision_mask, spaceship_collision_layer)
if not settings.startup["enable_rocket_powered_constructron"].value then
local empty_space_collision_layer = collision_mask_util_extended.get_named_collision_mask("empty-space-tile")
table.insert(pathing_collision_mask, empty_space_collision_layer)
end
end
local template_entity = {
type = "simple-entity",
icon = "__core__/graphics/empty.png",
icon_size = 1,
icon_mipmaps = 0,
flags = {"placeable-neutral", "not-on-map"},
order = "z",
max_health = 1,
render_layer = "object",
collision_mask = pathing_collision_mask,
pictures = {
{
filename = "__core__/graphics/empty.png",
width = 1,
height = 1
}
}
}
local template_item = {
type = "item",
flags = {
"hidden"
},
name = "constructron_pathing_dummy",
icon = "__core__/graphics/empty.png",
icon_size = 1,
order = "z",
stack_size = 1
}
for _, size in pairs({96, 64, 32, 16, 12, 10, 8, 6, 5, 4, 2, 1}) do
local proxy_entity = table.deepcopy(template_entity)
proxy_entity.collision_box = {{-size / 2, -size / 2}, {size / 2, size / 2}}
proxy_entity.selection_box = {{-size / 2, -size / 2}, {size / 2, size / 2}}
proxy_entity.name = "constructron_pathing_proxy_" .. size
local proxy_item = table.deepcopy(template_item)
proxy_item.name = "constructron_pathing_proxy_" .. size
proxy_item.place_result = "constructron_pathing_proxy_" .. size
data:extend({proxy_entity, proxy_item})
end