Page 1 of 1

[SOLVED]Replace an already built entity?

Posted: Sun Aug 12, 2018 2:55 am
by Staplergun
Is it possible to use a keybind to say, change an entity from one to another?

I effectively want to GET the entity, then replace it with another magically. I know how to read entity data. I don't know how to call a place action.

For reference it will be the same TYPE and it is a quickplace item (pipe-to-ground)

Example:
Bobs mod has multiple types of material. Lets say I want to press CONTROL + R to change to a different material without having the new pipe in my inventory.
Or maybe I want to do weird things like press CONTROL + R and have a pipe turn into a conveyor belt or something. I just want to know how to make the game replace one item with another without the player having to carry the secondary item in their inventory.

Re: Replace an already built entity?

Posted: Sun Aug 12, 2018 1:19 pm
by eradicator

Code: Select all

LuaSurface.create_entity{name='stuff',fast_replace=true,...}
https://lua-api.factorio.com/latest/LuaSurface.html

Re: Replace an already built entity?

Posted: Sun Aug 12, 2018 5:53 pm
by Staplergun
Much appreciated. I thought I had deleted this post since I found it after a misclick in the API page.