Entity that is only placeable on another entity

Place to get help with not working mods / modding interface.
Post Reply
Alex99
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Aug 26, 2017 2:51 am
Contact:

Entity that is only placeable on another entity

Post by Alex99 »

Is there a way to make one entity be only placeable on a certain type of entity?
e.g. an entity that when placed on a tree produces leafs

Then if this is possible then could one have them interact?
e.g. an entity that when placed on an assembly machine adds 2 module slots

Thanks in advance

EDIT: words are hard

robertpaulson
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Sun Jun 18, 2017 2:21 pm
Contact:

Re: Entity that is only placeable on another entity

Post by robertpaulson »

if it goes to trees I think you can use :

Code: Select all

{
							type = "create-entity",
							entity_name = "dead-tree",
							check_buildability = true
						},
IFAIK it checks if there is a tree then replaces it with a dead one, its a flag for a target_effects within a projectile. not sure why you wanna create leafs on a tree, but you can replace one with leafs (live tree) if it doesn't have them (dead tree). modification to tree entity might be necessary since they probably don't work both ways in vanilla

regarding the assemblers- to make more module slots you will have to modify the entity prototype, which cannot be done after the prototypes load. so 1stly you will have to make all entities you want this to affect have two versions (vanilla and +2module slots). then you will have to figure it out how to change the existing entity into the upgraded version.

I am still wondering if a "mousover" function exist in game or can be made. This will make it so you simply check what is under your cursor-destroy it and build over a new version. Some up-gradable entities use this mechanic so it is quite possible that it is that simple.

if not then I know there is a way to track all entities that were build by player and assigning them unique IDs, but I have no clue how to do it. AAI vehicles does this so you can look into that. Then you can select the entity, get the ID, get the entity details, replace it with a new upgraded version. It would be clunky but it will do the job.

Alex99
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Aug 26, 2017 2:51 am
Contact:

Re: Entity that is only placeable on another entity

Post by Alex99 »

Thanks for the reply but i meant to place an entity on another entity and still have both exist
i.e. to continue the tree and leaf example, have a tree, then without destroying or removing the tree, place an entity on the tree then (and this is irreverent) have the placed entity produce leafs.

The reason I abstracted it into the leaf/assembler example is because this is a part of a much larger project that would be impossible to explain a single post while still retaining the issue.

Mr.YaR
Inserter
Inserter
Posts: 26
Joined: Fri Jan 22, 2016 9:17 am
Contact:

Re: Entity that is only placeable on another entity

Post by Mr.YaR »

Also very interested in this.

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

Re: Entity that is only placeable on another entity

Post by Klonan »

Only functionality like this in the game at the moment is with resouces and mining drills

robertpaulson
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Sun Jun 18, 2017 2:21 pm
Contact:

Re: Entity that is only placeable on another entity

Post by robertpaulson »

Klonan wrote:Only functionality like this in the game at the moment is with resouces and mining drills
what about upgrading entities like assembly machines? I can place mk2 on mk1, but obv I cannot place mk2 on a ...furnace lets say... how the game knows what i'm trying to build on? is there a method written for it?

daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: Entity that is only placeable on another entity

Post by daniel34 »

robertpaulson wrote:
Klonan wrote:Only functionality like this in the game at the moment is with resouces and mining drills
what about upgrading entities like assembly machines? I can place mk2 on mk1, but obv I cannot place mk2 on a ...furnace lets say... how the game knows what i'm trying to build on? is there a method written for it?
Because assembling machines have a property that says

Code: Select all

fast_replaceable_group = "assembling-machine",
All entities that can be fast replaced have that property (search for "fast_replaceable_group" in all of the Factorio/data *.lua files). Chests ("container") can be replaced by other chests, inserters can be replaced by other inserters and so on. Currently the replacing entity has to be of the same size as the entity that is replaced, but 0.16 allows you to replace belts with splitters (FFF #206).

In theory you could also make a mod that can fast-replace assemblers with furnaces, but I doubt it would be useful.
quick links: log file | graphical issues | wiki

robertpaulson
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Sun Jun 18, 2017 2:21 pm
Contact:

Re: Entity that is only placeable on another entity

Post by robertpaulson »

daniel34 wrote: Because assembling machines have a property that says

Code: Select all

fast_replaceable_group = "assembling-machine",
All entities that can be fast replaced have that property (search for "fast_replaceable_group" in all of the Factorio/data *.lua files). Chests ("container") can be replaced by other chests, inserters can be replaced by other inserters and so on. Currently the replacing entity has to be of the same size as the entity that is replaced, but 0.16 allows you to replace belts with splitters (FFF #206).

In theory you could also make a mod that can fast-replace assemblers with furnaces, but I doubt it would be useful.
I see. Well, from this I am deducting that this function has to check where user is trying to build the entity and checks if the entity under it is eligible for an upgrade (similarly to the drills/resource interaction mentioned above). Could it be possible to access this check via lua? is it likely that this function would be implemented in the future, or is it too troublesome?

Post Reply

Return to “Modding help”