How to prevent connection of different pipes?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Shaderon
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Dec 13, 2019 8:27 pm
Contact:

How to prevent connection of different pipes?

Post by Shaderon »

Hi. As I wrote in title, my question is how to prevent from connecting two different pipes.

For purpose I created a new fluid pipe with new graphic, and I don't want to let it connect with vanilla pipes even if my pipe can transfer same kinds of fluid like vanilla. So is it possible to prevent connection between my own pipe and vanilla pipe (as well as vanilla pump or tank). :D
Pain is an universal constant.


User avatar
Shaderon
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Dec 13, 2019 8:27 pm
Contact:

Re: How to prevent connection of different pipes?

Post by Shaderon »

This mod do what I want but it's too complicated for me to use or even find in this mod how it's work. I just need a code example that prevent connection of two different pipes or something from Factorio API that could help cuz I can't find anything like that :/.
Pain is an universal constant.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2610
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: How to prevent connection of different pipes?

Post by darkfrei »

Shaderon wrote:
Mon Dec 30, 2019 4:32 pm
This mod do what I want but it's too complicated for me to use or even find in this mod how it's work. I just need a code example that prevent connection of two different pipes or something from Factorio API that could help cuz I can't find anything like that :/.
There is no way to keep them disconnected. This pipes are storage tanks.

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 1944
Joined: Fri Nov 06, 2015 7:41 pm

Re: How to prevent connection of different pipes?

Post by Deadlock989 »

Shaderon wrote:
Mon Dec 30, 2019 4:32 pm
This mod do what I want but it's too complicated for me to use or even find in this mod how it's work. I just need a code example that prevent connection of two different pipes or something from Factorio API that could help cuz I can't find anything like that :/.
You would have to check on every placement of every pipe by every method, including blueprints and ghost revivals, whether or not the pipe is adjacent to a fluid box belonging to a desirable/undesirable entity, and then cancel the build if it's being placed somewhere you don't want. Not straightforward, and likely very difficult to catch every possible case. There is no direct support for it in the API/engine. Pipes are pipes.

User avatar
Shaderon
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Dec 13, 2019 8:27 pm
Contact:

Re: How to prevent connection of different pipes?

Post by Shaderon »

Geez I barely try to start making a mod and I must deal with with many problem from the start :/ I know that via lua we can do practically everything but there's a costs, costs of memory usage. The think what I want to do is simillar or even the same as in Yuoki industries: Add mechanical power to the game as a fluid. Because I think fluid is the best option to do thinks like that.

But if I add mechanical power and even all infrastructure like tansmission shafts or other things like that, then they will connect with existing pipes from vanilla what will looks ugly in my opinion. But the problem is greater, cuz normal pipe can also transfer mechanical power (as a fluid) so using it's no sense to use mechanical infrastructure if it will be more expensive in crafting than normal pipe from vanilla.

I searching in modding wiki and I found something like "Minimum" and "Maximum" fluid temperature that can be transfered through pipe, and a "filter", that allow to transfer specific fluids via fluid_box. Also there is a fluid "Minimum" and "Maximum" temperature, that we can determine while creating new fluid, so I had an Idea to create "mechanical" pipe that can transfer filtered fluid "mechanical_power" and even set this pipe temperature compartment to 1 or other numbers that isn't used by vanilla fluids. But vanilla pipe can still transfer this mechanical power, so then I must edit existing vanilla pipes and fluids to set them temperature compartment that can't be matched with temperature of "mechanical_power". BUT... even if I do this my mechanical pipes and vanilla pipes will still connect to each other, and if I put my mechanical power through my mechanical pipe while them will be connect to vanilla pipes then we propably get a crash :P.

So in short, what I want to do:
- add fluid called "mechanical_power",
- add infrastructure (as fluid boxes) to transfer only mechanical power,
- prevent mechanical infrastructure to transfer other fluids,
- prevent to connect mechanical infrastructure with vanilla or other pipes that I want to add in future,
- prevent to transfer mechanical power through vanilla or other pipes I will add in future.

I think it's all.

Even I try to seek solve in other mods that adds new types of pipes with hope that here I find a solution or any sign on which way to go, but the problem problem stil exists. So maybe theres no way to solve it without complicated script that use a lot of memory :/

Anyway thanks all for response. Maybe someday I find a good method to solve this problem. But if someone will solve this problem I will be grateful for any help :D
Pain is an universal constant.

PyroFire
Filter Inserter
Filter Inserter
Posts: 343
Joined: Tue Mar 08, 2016 8:18 am
Contact:

Re: How to prevent connection of different pipes?

Post by PyroFire »

It sounds like you're after a mix of different things.

- Unique pipes that don't connect to eachother, for example if we added copper pipes and had a thing where those pipes don't connect to the iron ones.

- Restricting specific fluids to specific types of pipes (e.g. if an iron pipe is carrying hot lava, it should probably melt, instead requiring a special lava pipe).

Both seem like cool ideas, but yeah i don't think it is possible with prototypes (api request?)

To do it "traditionally" entails checking pipe placements manually to force the pipe adjacency thing (so your special pipes dont connect to vanilla ones) and when a pipe is placed at the output of anything that creates your custom fluid to check it is using the required pipe.

User avatar
Shaderon
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Dec 13, 2019 8:27 pm
Contact:

Re: How to prevent connection of different pipes?

Post by Shaderon »

Yes, that's what I want!

I searched the Factorio API in hope that I would find functions that would allow the creation of such pipes, without having to write advanced scripts that will consume a lot of memory. However, I didn't find anything so I decided to write here.

The last idea that comes to my mind how to do this is to specify that vanilla pipes can only transfer a specific fluid using the "filter" method, but the problem is that I would then have to make a separate pipe for each separate liquid, which is unfortunately pointless. I also think about how to do it in other way and I wiil look for something that could somehow help here. Maybe I find other conception how to do it.

And thanks for the answer :)

If anyone knows something how to solve it, just please write in this topic, I will be grateful!
Pain is an universal constant.

Squelch
Fast Inserter
Fast Inserter
Posts: 167
Joined: Sat Apr 23, 2016 5:31 pm
Contact:

Re: How to prevent connection of different pipes?

Post by Squelch »

I'm following this with interest, and I feel the pipe interaction rules to be quite frustrating too.

Have you considered using the Heat Pipe prototype? They are far less common, and indeed unique to nuclear power, so as long as you keep your mechanical couplings away from that area, you should be able to use them alongside the existing pipe infrastructure without changing the base, fluid pipe, behaviour.

They are in effect, conduits for energy transfer - Heat instead of mechanical - re-use the existing prototype and shape it to your liking.

Post Reply

Return to “Modding help”

Who is online

Users browsing this forum: No registered users