Hi
I created a new entity based on a rail (No choice, really!). I would like to be able to connect it electricity and wires (red and green). I don't especially need to connect cable physically (ideally, cables won't be seen), just the property?
That would be great.
Many thanks
Niko
Adding wires and cables to a new entity
Re: Adding wires and cables to a new entity
You can't add wires to entity types that don't support them in the core game.
The backing logic doesn't exist on that entity to save, load, connect, disconnect, and render the wires.
The backing logic doesn't exist on that entity to save, load, connect, disconnect, and render the wires.
If you want to get ahold of me I'm almost always on Discord.
Re: Adding wires and cables to a new entity
Hey
Well, I had the idea of the year, the one that would make you rich
More seriously, would it be possible to add the possibility in a next version?
Well, I had the idea of the year, the one that would make you rich

More seriously, would it be possible to add the possibility in a next version?
Re: Adding wires and cables to a new entity
You can possibly use scripting to create an invisible entity that does accept wires (and has no collision) on top of the rails and attach the red/green wires to that entity.
Re: Adding wires and cables to a new entity
Hey Lilly
That's a good idea. Do you know if this is possible to actually create a new entity that would be a mix of two? Or to link two entities (For instance, If I remove my rail, the top entity shall be removed as well).
Thanks for the tipp
Niko
That's a good idea. Do you know if this is possible to actually create a new entity that would be a mix of two? Or to link two entities (For instance, If I remove my rail, the top entity shall be removed as well).
Thanks for the tipp
Niko
Re: Adding wires and cables to a new entity
You cannot mix two types of entities, but you can link them using events. Code would look something like this:
Code: Select all
script.on_event(defines.events.on_built_entity, function(event)
if event.created_entity.name == "my-rail-type" then
local entity = event.created_entity
local control = entity.surface.create_entity{
name = "my-rail-control",
position = entity.position,
}
end
end)
script.on_event(defines.events.on_preplayer_mined_item, function(event)
if event.entity.name == "my-rail-type" then
local control = event.entity.find_entity("my-rail-control", event.entity.position)
control.destroy()
end
end)
Re: Adding wires and cables to a new entity
oh, sounds great, many thanks!
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: Adding wires and cables to a new entity
A good example mod to look at is Concrete Lampposts.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.