From dd58524a51a5fd31aa52a1c2f34735004f3dbd53 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Sat, 12 Apr 2025 03:19:51 +0900 Subject: [PATCH] .. --- PHI-CL/control.lua | 29 +++++++++++++++++++++++++++++ PHI-CL/data.lua | 19 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/PHI-CL/control.lua b/PHI-CL/control.lua index 499b022..01e4be3 100644 --- a/PHI-CL/control.lua +++ b/PHI-CL/control.lua @@ -159,4 +159,33 @@ if settings.startup['PHI-CT'].value or settings.startup['PHI-MI'].value or (sett gui_update(player, player.opened) end end) + + local entities = { + ['rail-support'] = true, + ['rail-ramp'] = true, + } + + local function build(event) + if entities[event.entity.name] then + local p = event.entity.surface.create_entity{name = 'rail-electric-pole', position = {event.entity.position.x, event.entity.position.y}, force = game.forces.neutral, quality = event.entity.quality} + p.destructible = false + end + end + + local function destroy(event) + if entities[event.entity.name] then + local e = event.entity.surface.find_entity({name = 'rail-electric-pole', quality = event.entity.quality.name}, {event.entity.position.x, event.entity.position.y}) + + if e then + e.destroy() + end + end + end + + script.on_event(defines.events.on_built_entity, build) + script.on_event(defines.events.on_robot_built_entity, build) + script.on_event(defines.events.on_entity_died, destroy) + script.on_event(defines.events.on_player_mined_entity, destroy) + script.on_event(defines.events.on_robot_pre_mined, destroy) + script.on_event(defines.events.script_raised_destroy, destroy) end diff --git a/PHI-CL/data.lua b/PHI-CL/data.lua index fff4907..aedbc0a 100644 --- a/PHI-CL/data.lua +++ b/PHI-CL/data.lua @@ -167,6 +167,25 @@ if settings.startup['PHI-CT'].value or settings.startup['PHI-MI'].value or (sett if mods['space-age'] and data.raw['inserter']['stack-inserter'] then data.raw['inserter']['stack-inserter'].allow_custom_vectors = true end + + local entity = table.deepcopy(data.raw['electric-pole']['big-electric-pole']) + entity.name = 'rail-electric-pole' + entity.hidden = true + entity.hidden_in_factoriopedia = true + entity.minable.result = nil + entity.maximum_wire_distance = math.floor(data.raw['rail-support']['rail-support'].support_range * 1.5) + entity.supply_area_distance = 0 + entity.water_reflection = nil + entity.pictures = nil + entity.active_picture = nil + entity.collision_box = {{0, 0}, {0, 0}} + entity.selection_box = nil + entity.collision_mask = {colliding_with_tiles_only = true, layers = {}, not_colliding_with_itself = true} + entity.flags = {'hide-alt-info', 'no-copy-paste', 'not-blueprintable', 'not-deconstructable', 'not-flammable', 'not-on-map', 'not-selectable-in-game', 'placeable-off-grid', 'placeable-player'} + entity.max_health = 2147483648 + entity.next_upgrade = nil + entity.order = 'zz' + data:extend({entity}) end if settings.startup['PHI-MI'].value then