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
Entity that is only placeable on another entity
-
- Long Handed Inserter
- Posts: 92
- Joined: Sun Jun 18, 2017 2:21 pm
- Contact:
Re: Entity that is only placeable on another entity
if it goes to trees I think you can use :
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.
Code: Select all
{
type = "create-entity",
entity_name = "dead-tree",
check_buildability = true
},
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.
Re: Entity that is only placeable on another entity
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.
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.
Re: Entity that is only placeable on another entity
Also very interested in this.
Re: Entity that is only placeable on another entity
Only functionality like this in the game at the moment is with resouces and mining drills
-
- Long Handed Inserter
- Posts: 92
- Joined: Sun Jun 18, 2017 2:21 pm
- Contact:
Re: Entity that is only placeable on another entity
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?Klonan wrote:Only functionality like this in the game at the moment is with resouces and mining drills
Re: Entity that is only placeable on another entity
Because assembling machines have a property that saysrobertpaulson wrote: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?Klonan wrote:Only functionality like this in the game at the moment is with resouces and mining drills
Code: Select all
fast_replaceable_group = "assembling-machine",
In theory you could also make a mod that can fast-replace assemblers with furnaces, but I doubt it would be useful.
-
- Long Handed Inserter
- Posts: 92
- Joined: Sun Jun 18, 2017 2:21 pm
- Contact:
Re: Entity that is only placeable on another entity
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?daniel34 wrote: Because assembling machines have a property that saysAll 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).Code: Select all
fast_replaceable_group = "assembling-machine",
In theory you could also make a mod that can fast-replace assemblers with furnaces, but I doubt it would be useful.