Force blueprint placement

Place to get help with not working mods / modding interface.
Post Reply
MostlyNumbers
Inserter
Inserter
Posts: 26
Joined: Fri Apr 13, 2018 10:07 pm
Contact:

Force blueprint placement

Post by MostlyNumbers »

Hi all,
I'm trying to modify a blueprint as it's placed. Specifically, I want to insert landfill underneath the entities.

I have a custom input set on "SHIFT + mouse-button-1" to intercept the BP placement, and add the ground tiles. The issue is if the entire BP is over water, no entities are placeable, and so the added tiles don't get placed either.

I tried inserting a hidden entity with no collision mask (ie placeable over water) during the custom-input event, to force blueprint placement. The custom-input event does trigger before blueprint placement, because the added entity shows up over land, but apparently the decision whether or not to place the blueprint occurs before the custom-input event, because over water still nothing get placed. Interestingly, this works if you double-click over water, since the first time the hidden item gets added to the BP, the second time it's already present and the BP gets placed.

So, are any of the following fixable:

If I add the hidden entity during on_player_cursor_stack_changed, everything works, since the hidden item is already in the BP when the decision to place is made (by the game). The issue there is the mod would corrupt every BP with a hidden entity, which would remain if exported or the mod is uninstalled.

I could call LuaItemStack.build_blueprint() from my custom-input event, but as far as I know, there's no way to get the cursor's in-game position.

Is there a way to programmatically emulate a user input? (force the double-click action)

Is there a way to intercept the BP placement decision (occurring before custom-input event)?

MostlyNumbers
Inserter
Inserter
Posts: 26
Joined: Fri Apr 13, 2018 10:07 pm
Contact:

Re: Force blueprint placement

Post by MostlyNumbers »

For now working around this with a toggle hotkey for the hidden object, so non-corrupted blueprints can be exported (ie just toggle off the option again).

You can see the current implementation here: Blueprint Footprint

Still interested in better solutions to this though!

Post Reply

Return to “Modding help”