The Problem
I'd like to be able to define custom research/technology effects (in particular for entities, but I can imagine this being useful outside of entities alone). This is particularly relevant for entities (which might not necessarily be part of the base game) that a modder might want to give research upgrades (especially infinite upgrades) to.I feel that the best way to convey what I would like to be able to do is by contrasting something that can do this with something that can't.
Already Implemented Case
This effect can already be achieved (and indeed has already been done and put into a mod) for logistic robot carrying capacity research, and is done by adding a new infinite research with:
Code: Select all
effects =
{
{
type = "worker-robot-storage",
modifier = 1
}
}
This code only works if the type "worker-robot-storage" is defined. It is also relevant to note that this effect seems to override the value for max_payload_size that is defined in the entity (on the off chance someone is reading this and doesn't know: see C:\Program Files (x86)\Steam\steamapps\common\Factorio\data\base\prototypes\entity\entities.lua line 6233; Windows installation).
Not Implemented Case
However, if the research effect you want isn't already defined (e.g. assembling machine craft speed, which is an attribute of the assembly machine entity - just as cargo capacity is for logistic robots), there is no way to define it yourself (to my knowledge - please correct me if I am wrong). Instead, you need to do something like the following process (using the example of increasing assembly machine crafting speed):
- Define a new assembly machine entity for each level of research which is exactly the same but with a higher crafting speed
- Create a new technology entry for each level (I don't believe there is a way to work it with being an infinite technology - someone correct me if I am wrong on this)
- Add to on_research_finished:
- - For all possible places that an assembling machine could be (on the ground, in player inventory, hotbar, on a belt, in chests, in a logistic robot, in a blueprint (very problematic!), etc):
- Take a copy of all the assembly machine details (progress, recipe, loaded item counts, location, etc)
- Delete the old assembly machine
- Place the new assembly machine
- Restore all of the old assembly machine details in the new assembly machine
Clearly, the second case is much less fun than in the first case. Notably, the second case also requires you to generate exponentially more entities relative to number of attributes you want to be able to infinitely research. It also notably doesn't play nice with other mods that use the entity in question. I also suspect that this is much worse for performance than if the research effect was supported by the base game, but its hard to say for sure, and depends how research effects work behind the scenes.
My Proposal
Carrying on the example of assembly machine crafting speed, we should be able to define our own research effect. I'd expect it to look something like the following (of course, this could take any form - the functionality is more important than the syntax/format/style/etc I use here):Code: Select all
type = "technology-effect",
name = "assembly-machine-crafting-speed",
modifier_target = "assembly-machine-3"
modification = {
entity.crafting_speed = entity.crafting_speed + modifier
}
Code: Select all
effects =
{
{
type = "assembly-machine-crafting-speed",
modifier = 0.1
}
}
My Proposal v2
Another solution to this problem is that instead of allowing us to define the research effect, research effects for all the attributes of all entities are added to the base game. I expect this will not be favored because it doesn't address items not part of the base game, and most of them would be unused.Closing Thoughts
I've used terms like "all", "any", or "custom" here a lot. I'd be quite happy if the research effects supported in modding was just expanded in some way, even if it is not extensive and allow us to go crazy with infinite things.I understand that the ability to have everything infinitely upgrade-able may not be in the spirit of Factorio, but that is why I think it is apt for a modding/scripting capability - not as part of the base game by default.
There may be some nice simple solution for the second case I describe in "the problem" that I'm just not aware of. If there is, let me know. If there isn't, feel free to let me know all the same; I'd be interested to know if modders have run into this situation themselves.
I think it would be interesting to have a segment of a Factorio Friday Facts on how the current built-in research effects work 'behind the scenes' (unless it has already been done, in which case, I wouldn't mind a link to it).
I'm aware of a request for range research which was put into the "Won't implement" category (which, if I am honest, is where I expect this request will go to as well - but I like to think that it won't). However, I think this suggestion is quite different in what it asks for. I am aware that there may be a lot of technical issues with this (as noted in the response to the linked request), but I think that this could be reasonably achieved for a fair amount of cases without it breaking things.