How to set up a custom infinite research
How to set up a custom infinite research
I'd like to create my own infinite research to increase speed and/or productivity of a certain machine. The problem is I only know how to add regular researches and I don't know how to make the research apply bonuses to my machine.
Re: How to set up a custom infinite research
As with all questions on how to mod something I first look at how the base game or small mods by the developers do things.
For example Klonans Robot Battery research.
For example Klonans Robot Battery research.
My Mods: mods.factorio.com
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: How to set up a custom infinite research
Adding productivity to specific machines is impossible. Only labs and drills as a general category have productivity reserach right now. Assuming you're thinking about some kind of assembling machine, then you're completely out of luck because assemblers can not have "built-in" productivity.
Re: How to set up a custom infinite research
@ Optera
Thanks, i was searching for a mod with an infinite research to learn from.
Thanks, i was searching for a mod with an infinite research to learn from.
Re: How to set up a custom infinite research
So it looks like I can't access speed or productivity. Is it at least possible to modify a global variable with a research? I could then do some stuff in control.lua
Re: How to set up a custom infinite research
You can se handlers for on_research_finished and on_technology_effects_reset.Villfuk02 wrote:So it looks like I can't access speed or productivity. Is it at least possible to modify a global variable with a research? I could then do some stuff in control.lua
Re: How to set up a custom infinite research
Is it possible to somehow change module values or change it's prototype in control.lua?
Re: How to set up a custom infinite research
No.Villfuk02 wrote:Is it possible to somehow change module values or change it's prototype in control.lua?
You could make tons of prototypes, one per research, level and replace the modules in each machine when the research finishes. That will be just as performance intensive as doing the same with machines though.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: How to set up a custom infinite research
I.e given the fact that on_research_finished is amongst the most rare events in the game, the performance impact would be negligible if done right, and worst case cause a minor lag spike after each relevant reserach if done wrong. But you'd have to deal with preventing the player from taking the modules out and stuffing them into something they're not intended for. Bleh. Replacing the machine itself is far easier to handle. Though still a fair bit of annoying code to get right in all cases. Also replacing the whole machine is more expensive than replacing a single module because you have to replicate the whole machine state (circuits, power, ingredients, crafting process, module slots, etcpp).Bilka wrote: You could make tons of prototypes, one per research, level and replace the modules in each machine when the research finishes. That will be just as performance intensive as doing the same with machines though.
Re: How to set up a custom infinite research
That should be possible to handle by fast_replacing the machine per script.eradicator wrote:Also replacing the whole machine is more expensive than replacing a single module because you have to replicate the whole machine state (circuits, power, ingredients, crafting process, module slots, etcpp).
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: How to set up a custom infinite research
I could also make the modules change their stats when inserted into the machine (they will be usable only in one machine). After every research finishes the code will check if it was the research I wanted. If yes, update all modules in the machine.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: How to set up a custom infinite research
Oh. I wasn't aware that create_entity can fast_replace. I suspect that would still be more expensive (if only slightly) than changing a single module.Bilka wrote:That should be possible to handle by fast_replacing the machine per script.
Both of these are impossible, as already mentioned above (including hack-arounds).Villfuk02 wrote:I could also make the modules change their stats when inserted into the machine (they will be usable only in one machine).