Page 1 of 1
Place entity on the water edge
Posted: Wed Apr 26, 2023 10:03 pm
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
Re: Place entity on the water edge
Posted: Thu Apr 27, 2023 1:42 am
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.
Re: Place entity on the water edge
Posted: Thu Apr 27, 2023 9:57 am
by hackamod
DaveMcW wrote: ↑Thu Apr 27, 2023 1:42 amWhat 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.
Re: Place entity on the water edge
Posted: Sat Apr 29, 2023 10:02 pm
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?
Re: Place entity on the water edge
Posted: Sun Apr 30, 2023 2:11 am
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.
Re: Place entity on the water edge
Posted: Wed May 10, 2023 11:13 am
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).
Re: Place entity on the water edge
Posted: Wed May 10, 2023 5:56 pm
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
Re: Place entity on the water edge
Posted: Thu May 11, 2023 11:47 am
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
Re: Place entity on the water edge
Posted: Thu May 11, 2023 3:04 pm
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"
Re: Place entity on the water edge
Posted: Thu May 11, 2023 5:01 pm
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).
Re: Place entity on the water edge
Posted: Thu May 11, 2023 5:36 pm
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
I should have it now, thanks to both of you