-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol.lua
More file actions
37 lines (31 loc) · 1.46 KB
/
Copy pathcontrol.lua
File metadata and controls
37 lines (31 loc) · 1.46 KB
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
local event = require("__flib__.event")
local build_events = {
defines.events.on_built_entity,
defines.events.on_robot_built_entity,
defines.events.script_raised_built,
defines.events.script_raised_revive
}
local safe_buildings_filter = {}
-- Safe buildings. Set all buildings marked as safe to be indestructible when they are built.
for _, name in pairs { "big-electric-pole", "small-lamp", "train-stop" } do
if (settings.global["combat-tweaks--safe-buildings--" .. name].value) then
safe_buildings_filter[#safe_buildings_filter + 1] = { filter = "name", name = name }
end
end
-- Safe rails, special case as there are multiple items here
if (settings.global["combat-tweaks--safe-buildings--rails"].value) then
safe_buildings_filter[#safe_buildings_filter + 1] = { filter = "name", name = "curved-rail" }
safe_buildings_filter[#safe_buildings_filter + 1] = { filter = "name", name = "straight-rail" }
end
-- Safe signals, special case to cover both regular and chain signals
if (settings.global["combat-tweaks--safe-buildings--rail-signals"].value) then
safe_buildings_filter[#safe_buildings_filter + 1] = { filter = "name", name = "rail-signal" }
safe_buildings_filter[#safe_buildings_filter + 1] =
{ filter = "name", name = "rail-chain-signal" }
end
if #safe_buildings_filter > 0 then
event.register(build_events, function(event)
local entity = event.created_entity or event.entity
entity.destructible = false
end, safe_buildings_filter)
end