Page 1 of 1

create_entity{fast_replace=true} used for ghosts

Posted: Tue Jan 03, 2017 7:42 pm
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.

Re: create_entity{fast_replace=true} used for ghosts

Posted: Tue Jan 03, 2017 8:54 pm
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

Re: create_entity{fast_replace=true} used for ghosts

Posted: Tue Jan 03, 2017 9:16 pm
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.

Re: create_entity{fast_replace=true} used for ghosts

Posted: Tue Jan 03, 2017 9:19 pm
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