Prevent pre_build from succeeding

Place to get help with not working mods / modding interface.
PFQNiet
Filter Inserter
Filter Inserter
Posts: 290
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

Prevent pre_build from succeeding

Post by PFQNiet »

I want to run some checks on_pre_build and, if a check fails, I want to cancel the placement of the item. Is this possible?

I'd rather avoid shenanigans like "the next on_built_entity event should destroy the entity" but that's totally an option if there's no cleaner way.
PFQNiet
Filter Inserter
Filter Inserter
Posts: 290
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

Re: Prevent pre_build from succeeding

Post by PFQNiet »

I should really test before posting XD

If you change the contents of the player's cursor during this event, then you change what gets built. So in my case...

Code: Select all

game.players[event.player_index].clear_cursor()
This cancels the build event. Of course it also clears the cursor but in my use-case that's acceptable.
Post Reply

Return to “Modding help”