How to set up a custom infinite research

Place to get help with not working mods / modding interface.
Post Reply
Villfuk02
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Mon Apr 30, 2018 7:23 am
Contact:

How to set up a custom infinite research

Post by Villfuk02 »

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.

User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2919
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: How to set up a custom infinite research

Post by Optera »

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.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: How to set up a custom infinite research

Post by eradicator »

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.

Villfuk02
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Mon Apr 30, 2018 7:23 am
Contact:

Re: How to set up a custom infinite research

Post by Villfuk02 »

@ Optera
Thanks, i was searching for a mod with an infinite research to learn from.

Villfuk02
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Mon Apr 30, 2018 7:23 am
Contact:

Re: How to set up a custom infinite research

Post by Villfuk02 »

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

betrok
Fast Inserter
Fast Inserter
Posts: 101
Joined: Wed Feb 28, 2018 12:08 pm
Contact:

Re: How to set up a custom infinite research

Post by betrok »

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
You can se handlers for on_research_finished and on_technology_effects_reset.

Villfuk02
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Mon Apr 30, 2018 7:23 am
Contact:

Re: How to set up a custom infinite research

Post by Villfuk02 »

Is it possible to somehow change module values or change it's prototype in control.lua?

Bilka
Factorio Staff
Factorio Staff
Posts: 3165
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: How to set up a custom infinite research

Post by Bilka »

Villfuk02 wrote:Is it possible to somehow change module values or change it's prototype in control.lua?
No.

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.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: How to set up a custom infinite research

Post by eradicator »

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.
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
Factorio Staff
Factorio Staff
Posts: 3165
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: How to set up a custom infinite research

Post by Bilka »

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).
That should be possible to handle by fast_replacing the machine per script.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Villfuk02
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Mon Apr 30, 2018 7:23 am
Contact:

Re: How to set up a custom infinite research

Post by Villfuk02 »

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.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: How to set up a custom infinite research

Post by eradicator »

Bilka wrote:That should be possible to handle by fast_replacing the machine per script.
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.
Villfuk02 wrote:I could also make the modules change their stats when inserted into the machine (they will be usable only in one machine).
Both of these are impossible, as already mentioned above (including hack-arounds).

Post Reply

Return to “Modding help”