Doing Pipe and Heat Pipe-like Connections on other entities?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Templarfreak
Burner Inserter
Burner Inserter
Posts: 15
Joined: Thu Oct 05, 2017 2:21 pm
Contact:

Doing Pipe and Heat Pipe-like Connections on other entities?

Post by Templarfreak »

Totally new to modding Factorio here. It is my understanding that only Pipe and Heat-Pipe entities have the ability to do this, but maybe it is still possible otherwise? The only thing I think is possible is spawning entities on top of my power poles that do the visuals while my main entity does the power transferring, but obviously that's far from ideal when there's going to realistically be tons and tons of these things (more on that in a bit). Also is there any way to hide the graphic for the copper/red/green cables? And maybe even force a pole to spawn with red/green cables and/or not allow them to connect at all too (And ontop of that make it impossible to disconnect them)?

Basically the idea here is that it is a power pole that can only connect to other power poles directly next to each other and power things directly next to them, and I wanted to use the heat pipe as a graphic for them. As an added bonus, is there a way to require water to be filled into these entities before they transfer power? That is not totally necessary but I think it would help to further balance my idea here.

And while we're at it, why are entity types not exposed to Lua so people can make their own entity types and not have to do convoluted things like spawning multiple entities via scripting? (Which really sucks as that's going to majorly impact performance the more you have to do that, and for this idea especially that is going to create *tons* of entities)

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Doing Pipe and Heat Pipe-like Connections on other entities?

Post by bobingabout »

So you want to mod in a power system where electricity basically acts like a heat pipe.

You know, you can actually create entities (Assembling machine types for example) that are powered via heat directly, right?

As for what you actually want to do... I don't think there's a way to do it. (Electrical poles need to be connected together via a cable, however, you can change the cable's graphic to be invisible, but I don't think you can change the graphics to make it look like they're physically connected to each other), but you could force the "to get power it needs to be directly next to a pole" idea by setting the power distribution range really small, so it reaches only into the neighbouring tile (Like the big pole does)

As for what to overlay? well... Pipe or heatpipe might come to mind first, however, those are automatic and the result would be that they attach to each other, and any other pipes that are adjacent, but not to the entity because there's no pipe connector on the entity. A better idea would be to use a phantom car, where each direction facing is one of the possible graphics, and then you manually change the car's facing to the graphic you want to display. Don't ask me how to actually do it, I'm just repeating an idea that seems fairly popular.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

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

Re: Doing Pipe and Heat Pipe-like Connections on other entities?

Post by eradicator »

@Templarfreak:
The next time you ask a question please do it in proper order and not as a collection of random sentences. Trying to guess what you're actually trying to achieve is kinda hard from that post. Especially with the "beginning" in the middle...

Are you trying to power assemblers directly with steam maybe? Please elaborate. (I'm not sure if liquid can be used as a fuel currently, but that might at least be worth an api interface request. And if not you could still try to fake it by using a 0-power assembler with fluid required in the recipes)

@Bob:
Using a car has the (large) drawback that every car type entity renders that red arrow on the (mini-)map. Which would be pretty meh here. Walls (e.g stone-wall) also have conneted graphics while not having much other code attached to them, so they might work better.
Templarfreak wrote:And while we're at it, why are entity types not exposed to Lua so people can make their own entity types and not have to do convoluted things like spawning multiple entities via scripting? (Which really sucks as that's going to majorly impact performance the more you have to do that, and for this idea especially that is going to create *tons* of entities)
Because the code required to allow dynamic prototyping would be huge, complicated, and slow. (paraphrasing what devs have said many times.)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
Templarfreak
Burner Inserter
Burner Inserter
Posts: 15
Joined: Thu Oct 05, 2017 2:21 pm
Contact:

Re: Doing Pipe and Heat Pipe-like Connections on other entities?

Post by Templarfreak »

"You know, you can actually create entities (Assembling machine types for example) that are powered via heat directly, right?"

But it also needs to work with unmodified vanilla machines, *and* not overlap with Nuclear Reactor heat-pipes, otherwise you could just feed that heat from Nuclear Reactors directly into machines and that would be pretty ridiculously OP.

"but you could force the "to get power it needs to be directly next to a pole" idea by setting the power distribution range really small, so it reaches only into the neighbouring tile (Like the big pole does)"

Yeah, that's the simplest part. I was able to figure that out, it's just that the visuals I want is the problem. I guess my only choice is to spawn an extra entity. It's relatively simple to do, but you end up placing twice as many entities which could fill any entity limit up and slow the game down much faster than usual. Spawning an entity over it will work, though. The spawned entity could be a wall type and that has connectable graphics.

"Are you trying to power assemblers directly with steam maybe? Please elaborate. (I'm not sure if liquid can be used as a fuel currently, but that might at least be worth an api interface request. And if not you could still try to fake it by using a 0-power assembler with fluid required in the recipes)"

Pretty sure I got the idea across pretty easily. It's a power pole that has a very short radius (easy to do) that is going to have connected visuals (kinda intermediate) and does not show the cables (probably difficult, I don't know how to do this at all or at least not without making all power poles also not show cables) and possibly not have copper, red, or green cables connectable and/or disconnectable at all (probably impossible with the current Lua API, cables seems like *very* hard-coded behavior).

"Because the code required to allow dynamic prototyping would be huge, complicated, and slow. (paraphrasing what devs have said many times.)"

Perhaps allowing for a single entity to have multiple entity-types would work. Or maybe they can break some of the behavior that *should* be more generic into all entity-types, such as receiving, storing, and sending power (like Accumulators and power poles), connectable graphics (walls, pipes, with a simple condition to verify what it can and cannot connect with), and generating power. None of these really inherently need to have certain sets of data like say, assembling, rail, robot, combinator, or belt-type entities do (Which all have very specific and detailed behavior). The problem is, without something along these lines you *have* to spawn in multiple entities to add capabilities to something. But this also only works on totally static entities. If you were to spawn multiple entities for mobile entities, the code to make it work seamlessly in Lua would be so complex and massive that more than a hundred or so of this entity will likely just crash the game out-right. It is a massive bottleneck. At the very least they could give us a real SDK so people can make their own actual code in the game without needing to bug devs for every little new feature they want.

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

Re: Doing Pipe and Heat Pipe-like Connections on other entities?

Post by eradicator »

Pretty sure I got the idea across pretty easily
Pretty sure my brain disagrees. So you say you want to...make sort of a cable that needs to be connected to every machine then? Which makes me guess you'd then disable normal power poles? Because you said you want it to be usable with existing machines and normal ones would be far better than yours for that.

Besides the electricity network is not made to cope with one-tile sized electric poles. Even without the connected visuals this would probably be pretty bad for performance. In any case far worse than the walls you're going to spawn in for the visuals.

You might be able to "forbid" the use of circuit wires by simply not specifying any wire-connection-points.

The normal power-wire graphic doesn't seem to be on a per entity basis tho. So unless you plan to completely replace the electricity distribution system i think you're out of luck for hiding them. The sprite for that is "copper-wire.png" defined in /data/core/prototypes/utility-sprites.lua.
Perhaps allowing for a single entity to have multiple entity-types would work. Or maybe they can break some of the behavior that *should* be more generic into all entity-types, such as receiving, storing, and sending power (like Accumulators and power poles), connectable graphics (walls, pipes, with a simple condition to verify what it can and cannot connect with), and generating power. None of these really inherently need to have certain sets of data like say, assembling, rail, robot, combinator, or belt-type entities do (Which all have very specific and detailed behavior). The problem is, without something along these lines you *have* to spawn in multiple entities to add capabilities to something. But this also only works on totally static entities. If you were to spawn multiple entities for mobile entities, the code to make it work seamlessly in Lua would be so complex and massive that more than a hundred or so of this entity will likely just crash the game out-right. It is a massive bottleneck. At the very least they could give us a real SDK so people can make their own actual code in the game without needing to bug devs for every little new feature they want.
The devs are always open to good suggestions. So if you think you have the ultimate solution for all our modding problems be sure to go ahead and tell them. I'll be the first to thank you when it's implemented. I've seen a lot of people fail to be convincing evnough before tho :P

User avatar
Templarfreak
Burner Inserter
Burner Inserter
Posts: 15
Joined: Thu Oct 05, 2017 2:21 pm
Contact:

Re: Doing Pipe and Heat Pipe-like Connections on other entities?

Post by Templarfreak »

"The devs are always open to good suggestions. So if you think you have the ultimate solution for all our modding problems be sure to go ahead and tell them. I'll be the first to thank you when it's implemented. I've seen a lot of people fail to be convincing evnough before tho :P"

Well, yeah, it's kind of impossible to know what is and isn't possible without knowing the code and obviously they are not not going to be showing the code any time soon so making good suggestions that have good counter-arguments for why they'd not want to do that are virtually impossible, outside of what I suggested. It'd be pretty simple and easy to break the hard-coding for say connected visuals, unless they made it so unbelievably more complex and complicated than it really needs to be.

"Besides the electricity network is not made to cope with one-tile sized electric poles. Even without the connected visuals this would probably be pretty bad for performance. In any case far worse than the walls you're going to spawn in for the visuals."

I'd be inclined to agree if I didn't already try it and it seems to be running surprisingly flawlessly. I guess it's just because Heat Pipes (I decided to make my "dummy" visual entity a Heat Pipe-type) don't really have a lot of code on them, so each frame passes through all the heat pipes fairly quickly. All of the complex code on heat pipes are purely visual and not that complex. I do think if you tried doing this with way more complex entities, such as stuff that moves or something similarly complex, it would definitely noticeably impact performance. For instance, AAI's Zone maker beacon thing is notoriously slow and heavy on performance unless you have very good circuit conditions to cut down on how many tiles it's scanning.

"The normal power-wire graphic doesn't seem to be on a per entity basis tho. So unless you plan to completely replace the electricity distribution system i think you're out of luck for hiding them. The sprite for that is "copper-wire.png" defined in /data/core/prototypes/utility-sprites.lua."

That's very strange, because there are "copper_wire_picture" tags yet they seem to not actually do anything.

"You might be able to "forbid" the use of circuit wires by simply not specifying any wire-connection-points."

Nope, not specifying a green/red point in the connection's list just makes them default to the origin of the entity (A power pole also *has* to have a connection point). Like, this:

Code: Select all

    connection_points =
    {
      {
        shadow =
        {
        },
        wire =
        {
        }
      },
    },
You have to have at least one of these defined for an electric-pole entity. These don't even seem to define what is connectable, it just only defines where they appear visually. By having them blank like that, it just defaults to 0,0 or something as far as I can tell.

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

Re: Doing Pipe and Heat Pipe-like Connections on other entities?

Post by eradicator »

Oh well good for you if spamming poles works fine. I'm still not sure if you want to completely replace the power distribution system, i.e. if removing the copper-wire sprite alltogether would be an option. Tho it'd be pretty expensive to do any kind of circutry in that scenario if you pay one cable per tile :/.

coper_wire_picture was apparently removed in 0.15 and it's not used in any of the base files. So your source for that is probably outdated.

For removing the connection point i specifically meant the circuit-wire points. The copper-cable point would clearly be required. But i guess you meant that too. Just saying to be certain ;)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding help”