create_entity{fast_replace=true} used for ghosts

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
Mylon
Filter Inserter
Filter Inserter
Posts: 513
Joined: Sun Oct 23, 2016 11:42 pm
Contact:

create_entity{fast_replace=true} used for ghosts

Post by Mylon »

Example:

Code: Select all

roboport.surface.create_entity{name="entity-ghost", position=belts.position, inner_name=p.name, direction = belts.direction, force=roboport.force, fast_replace=true}
Doing this under an existing entity already will summon a bot to try and fulfill the ghost, but the bot never places it because the area is blocked. Please allow the bot to check the fast_replace flag on the ghost and place the held item and pick up the old one.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: create_entity{fast_replace=true} used for ghosts

Post by Klonan »

Create entity doesn't do all the classic collision checks, if you want to check for entities before creating the ghost then you can use:
http://lua-api.factorio.com/latest/LuaS ... ace_entity

User avatar
Mylon
Filter Inserter
Filter Inserter
Posts: 513
Joined: Sun Oct 23, 2016 11:42 pm
Contact:

Re: create_entity{fast_replace=true} used for ghosts

Post by Mylon »

I specifically want to emulate the fast_replace behavior when placing by hand, but allow bots to do it.

Currently I create the ghost, and then check the ghost regularly if a bot is standing on it with the item and then do a create_entity call with {name=ghost.ghost_name, fast_replace=true}, which removes both the original entity and the ghost. It's a weird hack and has some difficulties (namely, catching the old item which gets dripped on the ground) but it works.

Allowing bots to support this behavior natively would improve the performance/feel of this method.
Last edited by Mylon on Tue Jan 03, 2017 9:20 pm, edited 1 time in total.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: create_entity{fast_replace=true} used for ghosts

Post by Klonan »

Mylon wrote:I specifically want to emulate the fast_replace behavior when placing by hand, but allow bots to do it.

Currently I create the ghost, and then check the ghost regularly if a bot is standing on it with the item and then do a create_entity call with the ghost.ghost_name, which removes both the original entity and the ghost. It's a weird hack and has some difficulties (namely, catching the old item which gets dripped on the ground) but it works.

Allowing bots to support this behavior natively would improve the performance/feel of this method.
So what you really need would be contsruction bots to support fast replacing entities,
Nothing to do with the create_entity command

Post Reply

Return to “Modding interface requests”