Place entity on the water edge

Place to get help with not working mods / modding interface.
Post Reply
hackamod
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Mon Apr 25, 2022 2:39 pm
Contact:

Place entity on the water edge

Post by hackamod »

I am trying to place a new building on the edge of the water much in the way the "offshore pump" is placed.
In fact one of the buildings could be almost a copy paste of the offshore pump except it does not need to pump water.
Another building I want to use will need more tiles beside the water to be placed.
Can you help me understand what mechanics are taking place to highlight the available places to put the offshore pump and where I can see the implementation for the offshore pump? Inside the base mod / prototypes where the pump is defined there is a note about the water layer that might mean I have more to learn before I can make this work

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Place entity on the water edge

Post by DaveMcW »

The offshore pump water detection feature is not exposed to modders.

What you can do is make two entities. Entity 1 is an offshore pump, entity 2 is an assembling machine. Use the item to place entity 1. Then use control.lua scripting to swap to entity 2 in the on_built_entity and on_robot_built_entity events.

hackamod
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Mon Apr 25, 2022 2:39 pm
Contact:

Re: Place entity on the water edge

Post by hackamod »

DaveMcW wrote:
Thu Apr 27, 2023 1:42 am
What you can do is make two entities.
Not a bad idea, please share your thoughts on this idea vs that one...

What about doing a deep copy of the pump and then removing the pipe connection, add a crafting recipe and change the graphics... I do not know enough about what is involved to see which way is better.

I need to make multiple buildings snap to the edge of the water in the same manner, most of them can be implemented at the size of the pump.
I would like to place buildings with a larger footprint but I can probably just use the pump 1-tile method and just offset the graphic enough that most of the building is on land no matter the shape of the shore. If I must... in order to get that box to highlight where it is good to place.

hackamod
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Mon Apr 25, 2022 2:39 pm
Contact:

Re: Place entity on the water edge

Post by hackamod »

...any thoughts on the idea of stripping the pump down?
Really I am curious if it is possible to just add the ability to craft to any entity?
Can I make one building do smelting and crafting just by changing the recipe?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Place entity on the water edge

Post by DaveMcW »

The game will only read the data.lua fields that match the entity type. You can't add a recipe to an offshore pump. And you can't add water detection to an assembling machine.

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2570
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Place entity on the water edge

Post by FuryoftheStars »

There are also some things that are required for the entity type used. For example, pipes cannot be removed from an offshore pump (though there are ways to hide their being displayed).
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

hackamod
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Mon Apr 25, 2022 2:39 pm
Contact:

Re: Place entity on the water edge

Post by hackamod »

Please provide any details you can, I have not solved this issue yet.
Still don't quite have my head around the bigger picture.
Ultimately I am trying to build 3 different buildings at the water edge, that can replace one another. 3 types of fish traps.
They really need to snap to the water edge like the pump does but the entire graphic will be different.
I have not done any work with pipes yet but it seems the pipe connections are not part of the graphic, but an add on.
This would add a really nice touch to the mod if it can be done

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2570
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Place entity on the water edge

Post by FuryoftheStars »

The wiki will tell you which parts are optional (and thus by extension, what's required):
https://wiki.factorio.com/Prototype/OffshorePump

If you drill in on each component, it'll give you some additional information, too. For example, drilling in on the fluidbox, you can learn this exists for it:
https://wiki.factorio.com/Types/FluidBo ... ction_info
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

hackamod
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Mon Apr 25, 2022 2:39 pm
Contact:

Re: Place entity on the water edge

Post by hackamod »

Thanks for the links. Especially hiding the pipe connections.
I am not sure I am following your suggestion... are you suggesting I copy the pump, hide the connections, and change the graphic?... but keep the pump?
(This is the way I had imagined it in the beginning but that seems to have been pushed aside for the idea of swapping entities on placement)
I look to the more experienced modders for an opinion of the best way to approach this workaround.
Ultimately I just want to limit the placement of fish traps to the water edge, and of course look like "not a pump" :lol:

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2570
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Place entity on the water edge

Post by FuryoftheStars »

You should copy the pump, do not include null out what's not needed for your setup and do what you can to hide what you have to leave (but don't want/need), change the graphic so it looks like your entity, but then on placement in control.lua, swap it out for your actual entity.

I did something similar for my Restrictions On Artificial Tiles mod for tree placement, but it may be difficult to follow the code because there's a lot more than just that going on (and I reversed the collision_mask logic to make it so you couldn't place trees adjacent to concrete/stone brick/etc. In your case, you should be able to leave these at default and just increase the size of the bounding box if needed).
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

hackamod
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Mon Apr 25, 2022 2:39 pm
Contact:

Re: Place entity on the water edge

Post by hackamod »

With my recent experience I now understand that is what the first reply said to do also.... I just didnt get it then :roll:

I should have it now, thanks to both of you

Post Reply

Return to “Modding help”