Entity acting as another for blueprints and fast replace.

Place to get help with not working mods / modding interface.
Post Reply
sticklord
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Apr 14, 2018 4:13 pm

Entity acting as another for blueprints and fast replace.

Post by sticklord » Sun Apr 15, 2018 1:46 pm

Hello!

I've been working on a small mod to make all different pipes (added by other mods) not able to connect, by creating a 15 additional pipes ("pipe" creates "pipe-[0-14]" for example)for each pipe type. It works by changing the newly built pipe to a pipe which blocks the connections to pipes of another type if needed.
pipes.jpg
pipes.jpg (679.95 KiB) Viewed 696 times
I have some flaws i still need to figure out though:

- When blueprinting, i want it to select main pipe, not "pipe-3". Because those have blocked connections that doesn't work when rotating the blueprint.

- If all the pipes use the same fast-replace group, and i try to build over a modified pipe( "pipe-3" for example ) i can fast replace it with "pipe" and this pipe get changed back to "pipe-3" when placed. This makes a loop i would like to avoid.

I guess essentially i would want all the custom pipes "pipe-[0-14]" to to be read as "pipe" moused over and everything. I tried to save all my custom pipes with prototype.name = "pipe" and with the key "pipe-[0-14]" but that didnt work at all.

I'd appreciate any input:)

orzelek
Smart Inserter
Smart Inserter
Posts: 3279
Joined: Fri Apr 03, 2015 10:20 am

Re: Entity acting as another for blueprints and fast replace.

Post by orzelek » Sun Apr 15, 2018 6:37 pm

Did you set mining result for your entites to be a normal pipe of their type?
I'm not sure but I think blueprinting uses that.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 2604
Joined: Tue Jul 12, 2016 9:03 am

Re: Entity acting as another for blueprints and fast replace.

Post by eradicator » Sun Apr 15, 2018 7:16 pm

Blueprints only save the actual entity name. What is used to build that entity depends on what is available when the ghost is placed (i.e. when there are several items that can build an entity). If you want to exclude certain things from being in BPs you'll have to hook one of the blueprint events like on_blueprint_setup (name guessed from memory) and change the actual blueprint to not contain the things you want via set/get_blueprint_entities().

The name that is showns when mousing over pipes is unrelated to entity behavior and just a simple lookup from one of the local.cfg files. If you want to change them you'll need to include your own locale.cfg and have something like
pipe-1=__entity.name__.pipe
for all your new pipes to steal the name from the original pipe.

User avatar
Bilka
Factorio Staff
Factorio Staff
Posts: 1052
Joined: Sat Aug 13, 2016 9:20 am

Re: Entity acting as another for blueprints and fast replace.

Post by Bilka » Sun Apr 15, 2018 7:22 pm

Use placeable_by = {item="normal-pipe", count= 1} to change what your pipe gets placed by.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

sticklord
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Apr 14, 2018 4:13 pm

Re: Entity acting as another for blueprints and fast replace.

Post by sticklord » Sun Apr 15, 2018 8:04 pm

Thanks, modifying the blueprint did fix that first issue. I did swap out all my numbered pipes by the regular pipes.

And yeah, the pipes have all the original prototype values as the original pipe, except the fluidbox connections which is changed.

I also have added the placeable by value, but i guess thats only for robots? They shouldnt be able to, i only want my control.lua script to place them.

But i still have the issue where fast replace breaks it, ill try to explain it better: While running, i place the entity "pipe". My script replaces "pipe" with "pipe-3". And then when i move my mouse 1 pixel while still hovering the same pipe, i replace another "pipe" over "pipe-3". So i want the fast replace to treat all "pipe-#" as "pipe".

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 2604
Joined: Tue Jul 12, 2016 9:03 am

Re: Entity acting as another for blueprints and fast replace.

Post by eradicator » Mon Apr 16, 2018 11:39 am

sticklord wrote: I also have added the placeable by value, but i guess thats only for robots? They shouldnt be able to, i only want my control.lua script to place them.
Yes. That's only for robots.
sticklord wrote: But i still have the issue where fast replace breaks it, ill try to explain it better: While running, i place the entity "pipe". My script replaces "pipe" with "pipe-3". And then when i move my mouse 1 pixel while still hovering the same pipe, i replace another "pipe" over "pipe-3". So i want the fast replace to treat all "pipe-#" as "pipe".
Sounds like you want pipe-3 to dynamically be fast-replaceable and not fast-replaceable depending one when it was last fast-replaced. And that's not possible. You can only make pipe-3 not fast replaceable by pipe at all by putting it into another group.

mrvn
Smart Inserter
Smart Inserter
Posts: 2573
Joined: Mon Sep 05, 2016 9:10 am

Re: Entity acting as another for blueprints and fast replace.

Post by mrvn » Mon Apr 16, 2018 12:42 pm

There already are mods that add straight, L and T pipes that do not dynamically connect. That gives you a total of 5 (4 + underground) pipes to make any pipe network you like. No need for any fancy script magic there either.

sticklord
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Apr 14, 2018 4:13 pm

Re: Entity acting as another for blueprints and fast replace.

Post by sticklord » Mon Apr 16, 2018 3:14 pm

eradicator wrote: Sounds like you want pipe-3 to dynamically be fast-replaceable and not fast-replaceable depending one when it was last fast-replaced. And that's not possible. You can only make pipe-3 not fast replaceable by pipe at all by putting it into another group.
Yeah, not quite. If I have 3 pipe types; "iron-pipe", "steel-pipe" and "brass-pipe", iron should fast replace for all types but exclude itself: "iron-pipe" (which it does already) and "iron-pipe-#" (where # is a number 0-14). Same for the others.

But I'm starting to doubt this is possible:P At least with fast replace. I'll dig around to see if I can find a hacky way, like reducing build distance or blocking the placement or something.
mrvn wrote:There already are mods that add straight, L and T pipes that do not dynamically connect. That gives you a total of 5 (4 + underground) pipes to make any pipe network you like. No need for any fancy script magic there either.
Yeah I know theres a mod that makes all kind of junctions, but it's not as user friendly. And i dont get those cool looking windows with them :)

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 2604
Joined: Tue Jul 12, 2016 9:03 am

Re: Entity acting as another for blueprints and fast replace.

Post by eradicator » Mon Apr 16, 2018 6:47 pm

sticklord wrote:
eradicator wrote: Sounds like you want pipe-3 to dynamically be fast-replaceable and not fast-replaceable depending one when it was last fast-replaced. And that's not possible. You can only make pipe-3 not fast replaceable by pipe at all by putting it into another group.
Yeah, not quite. If I have 3 pipe types; "iron-pipe", "steel-pipe" and "brass-pipe", iron should fast replace for all types but exclude itself: "iron-pipe" (which it does already) and "iron-pipe-#" (where # is a number 0-14). Same for the others.

But I'm starting to doubt this is possible:P At least with fast replace. I'll dig around to see if I can find a hacky way, like reducing build distance or blocking the placement or something.
I understand fine what you say there. But you haven't said what prevents you from just making iron-pipe-x not fast-replaceable at all. Unless you want bronze pipe to be able to fast-replace iron-pipe-x, which is imposisble to combine with the conditions you stated above. And i don't know any hacks for that either, unless maybe if you were to use on_tick to scan .selected and then dynamically switch iron-pipe-x to .minable=false which hopefulle prevents it from being fast replaced...but that is pretty ugly as hacks go.

mrvn
Smart Inserter
Smart Inserter
Posts: 2573
Joined: Mon Sep 05, 2016 9:10 am

Re: Entity acting as another for blueprints and fast replace.

Post by mrvn » Tue Apr 17, 2018 2:21 pm

I don't see why you need those 15 pipes at all. As said you only need I, L, T, X and underground pipes.

sticklord
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Apr 14, 2018 4:13 pm

Re: Entity acting as another for blueprints and fast replace.

Post by sticklord » Tue Apr 17, 2018 5:33 pm

eradicator wrote:
sticklord wrote:
eradicator wrote: Sounds like you want pipe-3 to dynamically be fast-replaceable and not fast-replaceable depending one when it was last fast-replaced. And that's not possible. You can only make pipe-3 not fast replaceable by pipe at all by putting it into another group.
Yeah, not quite. If I have 3 pipe types; "iron-pipe", "steel-pipe" and "brass-pipe", iron should fast replace for all types but exclude itself: "iron-pipe" (which it does already) and "iron-pipe-#" (where # is a number 0-14). Same for the others.

But I'm starting to doubt this is possible:P At least with fast replace. I'll dig around to see if I can find a hacky way, like reducing build distance or blocking the placement or something.
I understand fine what you say there. But you haven't said what prevents you from just making iron-pipe-x not fast-replaceable at all. Unless you want bronze pipe to be able to fast-replace iron-pipe-x, which is imposisble to combine with the conditions you stated above. And i don't know any hacks for that either, unless maybe if you were to use on_tick to scan .selected and then dynamically switch iron-pipe-x to .minable=false which hopefulle prevents it from being fast replaced...but that is pretty ugly as hacks go.
Ah ok my bad. The reason i want them fast replaceable is, as you said, so you can easily replace bronze pipes with iron pipes. And yeah that's also an idea for a way to fix it. Haven't looked into ways yet, got another stupid mod idea i wanted to try out:p
mrvn wrote:I don't see why you need those 15 pipes at all. As said you only need I, L, T, X and underground pipes.
I need 15 different pipes because there's 4 connections on the pipe that can be either enabled or disabled. Which gives 2^4, minus the default pipe that aleady has all 4 connections enabled. I didn't try to make the pipes rotatable (is that a word?), and it would make the math alot harder:p

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 2604
Joined: Tue Jul 12, 2016 9:03 am

Re: Entity acting as another for blueprints and fast replace.

Post by eradicator » Tue Apr 17, 2018 8:01 pm

If they were rotatable you wouldn't have to fix blueprints though :P. Because they would just rotate with the print.

mrvn
Smart Inserter
Smart Inserter
Posts: 2573
Joined: Mon Sep 05, 2016 9:10 am

Re: Entity acting as another for blueprints and fast replace.

Post by mrvn » Thu Apr 19, 2018 9:08 am

eradicator wrote:If they were rotatable you wouldn't have to fix blueprints though :P. Because they would just rotate with the print.
Exactly.

And you could put all L pipes into one fast replace group, all T pipes in another. No more accidentally replacing a straight pipe with a 90° turn.

sticklord
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Apr 14, 2018 4:13 pm

Re: Entity acting as another for blueprints and fast replace.

Post by sticklord » Thu Apr 19, 2018 2:23 pm

That's not an issue. You don't touch the L pipes etc, just the regular pipes. When it's placed the script replaces it with a pipe the blocks the connections to pipes of a different color. And i'm pretty sure it's not possible to rotate the pipe entity. The other mods use a storage tank as base entity.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 2604
Joined: Tue Jul 12, 2016 9:03 am

Re: Entity acting as another for blueprints and fast replace.

Post by eradicator » Thu Apr 19, 2018 5:00 pm

sticklord wrote:That's not an issue. You don't touch the L pipes etc, just the regular pipes. When it's placed the script replaces it with a pipe the blocks the connections to pipes of a different color. And i'm pretty sure it's not possible to rotate the pipe entity. The other mods use a storage tank as base entity.
Huh. I wasn't even aware that you can change the connections on a normal pipe entity. Interesting =).

sticklord
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Apr 14, 2018 4:13 pm

Re: Entity acting as another for blueprints and fast replace.

Post by sticklord » Tue Apr 24, 2018 5:22 pm

I found a decent solution! Setting the flag "fast-replaceable-no-build-while-moving" makes you have to click once if you want to replace a pipe, but I can live with that. Maybe even better than the other fast replace :) Most importantly it doesn't overwrite it for every pixel the mouse is moved.

Post Reply

Return to “Modding help”