Commit 55e4aa20 authored by Rob Nelson's avatar Rob Nelson
Browse files

Add belts to protection list.

parent 24178def
......@@ -11,11 +11,29 @@ local indestructible = (function(list) local set = {} for _, l in ipairs(list) d
"curved-rail"
})
local substring_matches = {
"transport-belt",
"underground-belt",
"pole"
}
local function name_is_invulnerable(name)
if indestructible[name] then
return true
end
for i, substr in ipairs(substring_matches) do
if name:find(substr) then
return true
end
end
return false
end
script.on_event(defines.events.on_built_entity, function(event)
local entity = event.created_entity
if entity then
local name = entity.name
if name:find("pole") or indestructible[name] then
if name_is_invulnerable(name) then
entity.destructible = false
end
end
......@@ -25,7 +43,7 @@ local function Destructible(event)
local entity = event.created_entity
if entity then
local name = entity.name
if name:find("electric-pole") or indestructible[name] then
if name_is_invulnerable(name) then
entity.destructible = true
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment