Entity placement woes

Place to get help with not working mods / modding interface.
GotLag
Filter Inserter
Filter Inserter
Posts: 534
Joined: Sat May 03, 2014 3:32 pm
Contact:

Entity placement woes

Post by GotLag »

I've been hammering away at making a landfill mod, current progress is here:
http://gozaima.su/factorio/Landfill.zip
No locale, rudimentary placeholder graphics, temporary recipe

It works by adding an event handler that detects when a modified wall is placed. It then converts all the tiles around the wall into dirt, then deletes the wall. This part is working fine.
I've added a function that checks if there are any player structures in close proximity, and if it detects any it doesn't execute the landfill code, and gives the player another landfill item to compensate for the one that didn't function.

A problem I'm having is that as the entity is destroyed almost instantly, even a quick tap of the mouse consumes multiple items because the location becomes clear again before you can release the mouse button.
Is there a way to force the game to delay (even half a second) before allowing another one to be placed? Or can I somehow queue the destruction of the entity to happen in half a second without having to add an ontick() listener?

Or better still, is there a way to check if a location is valid BEFORE the entity is placed?

I mean I could just use demolish all structures within a certain area and use the entity graphics to show an overlay of where this will happen, but I'd like it to be more friendly than that. And that still doesn't solve the problem of a dozen entities being used on a single mouse click.
User avatar
ludsoe
Fast Inserter
Fast Inserter
Posts: 245
Joined: Tue Feb 11, 2014 8:16 am
Contact:

Re: Entity placement woes

Post by ludsoe »

MoLogicCore from MoMods has a timer system so you can queue functions, such as removing a entity.
GotLag
Filter Inserter
Filter Inserter
Posts: 534
Joined: Sat May 03, 2014 3:32 pm
Contact:

Re: Entity placement woes

Post by GotLag »

Solution found: event handler deletes the placed wall and creates a custom corpse with a 1-second fade time and appropriate collision mask at that location.
https://forums.factorio.com/forum/vie ... =14&t=3793
Post Reply

Return to “Modding help”