Recipes for mining?

Things that we aren't going to implement
MarcasRealAccount
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu Aug 27, 2020 7:46 pm
Contact:

Recipes for mining?

Post by MarcasRealAccount »

On viewtopic.php?f=221&t=77368&p=463883&hi ... ce#p463883 forum post from almost a year ago someone asked if it would be possible for mining drills to use a recipe system so that modders could customize how an ore would be mined.
Like for instance being able make it require water as well as sulfuric acid for uranium ore for certain mining drills and others would only require sulfuric acid or maybe make a recipe that only gave 1 ore for every 2 ores mined.
But a dev responded that it was likely not ever going to happen because it would probably not get used by the base mod, which is pretty sad since modding in general should be about allowing pretty much anything to be done.

I am currently working on a mod https://mods.factorio.com/mod/dustless-miners that aims to reduce pollution from miners by basically vacuuming up the dust from the drill and pumping it out a pipe on the back, but since there is currently no way to do it easily without the use of the control.lua file I had to make a very hacky function that inserted a fluid into the miner entity which caused it to push the dust through the pipe and I would love to say this is not GOOD since lua is way too slow.

And so I'm just re-asking the same question as someone did a year ago to know if it might get added.
Just so we are clear when the dev said
It would break literally every mod out there and add in a lot of overhead to the mining system for things the base game would never use
I think that is totally a big fat lie, if this was added it would obviously not get added in a minor version and since every major version older mods aren't compatible by default it would mean that the issue isn't there.
Recipes are recipes and define how things get crafted. Mining is a completely different system and we aren't going to be merging them together - sorry.
And with this I could easily say why use the same system why not make an expanded recipe system that is used for miners, or just add in some functions that only work if it is executed on a miner.
Literally most of the excuses that the dev made is pretty dumb considering it is easily possible and yes it could possibly be used by the base mod at some point in the future like for instance that the base mod had its own better mining drill that produced less pollution.
Koub
Global Moderator
Global Moderator
Posts: 7938
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: Recipes for mining?

Post by Koub »

MarcasRealAccount wrote: Thu Aug 27, 2020 8:17 pm Just so we are clear when the dev said
It would break literally every mod out there and add in a lot of overhead to the mining system for things the base game would never use
I think that is totally a big fat lie, if this was added it would obviously not get added in a minor version and since every major version older mods aren't compatible by default it would mean that the issue isn't there.
I'm sure you're going to convince the whole dev team your point is valid with this irrefutable demonstration : "You lie, I know better than you how the game is coded". I'm impressed.

There is a major difference between needing to change a number in a json or whatever to tell "this mod is compatible with this new version" and needing to change the actual contents of the mod, and that doesn't address the overhead issue.
MarcasRealAccount wrote: Thu Aug 27, 2020 8:17 pmLiterally most of the excuses that the dev made is pretty dumb considering it is easily possible and yes it could possibly be used by the base mod at some point in the future like for instance that the base mod had its own better mining drill that produced less pollution.
So "you're are liars, stop making dumb excuses, this suggestion is easy to implement, with no drawback for the game, just do it".
Maybe could you mod your communication skills to be less assertive ? Just a personal opinion.
Koub - Please consider English is not my native language.
MarcasRealAccount
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu Aug 27, 2020 7:46 pm
Contact:

Re: Recipes for mining?

Post by MarcasRealAccount »

I obviously didnt mean I know how the game is coded, but since you in a way implied I should just make the most important part for you [attachment 1] (I know you use C++ but here's java cuz its what I know the best, I also know that I should've used a .txt file but I have no program that could give me that on my phone)

This isn't the most perfect code ever but it should serve its purpose in handling the miner recipe stuff.
I'm fully aware that namings and such probably isn't the same but you should get the point.

What I meant when addressing "It would break literally every mod out there" was that because the mod becomes incompatible with each major version it implies that if the mod developer only changes the version in the info.json file to the latest version it might become broken, and so the problem would not arrise.

As for the overhead if he meant overhead in performance then having a recipe system for the miners would require more to run, but considering there's already lots of other machines that use recipes, I think that statement is a bit bogus. If he meant overhead in developing then I would say you've already developed similar system earlier, it shouldn't be too difficult right?

My last words: I don't mind if it isn't implemented, I read the old post and the excuses the dev made were very lacking as they made no sence to me at all, but I guess you probably didn't fully understand what I wanted to relay which I want to say I'm sorry for being a bit "assertive". Anyway I was just hoping that maybe now you devs would've changed your minds so that even more mods would be possible like mine where I wouldn't have to rely on hacky lua code. Maybe you could tell me why it's not going to be implemented so that I can understand what I would be able to help with making it possible. And again I never intended on being assertive or rude, I just didn't understand those excuses.
Attachments
Factorio miner recipe system.docx
(12.53 KiB) Downloaded 84 times
Rseding91
Factorio Staff
Factorio Staff
Posts: 14655
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Recipes for mining?

Post by Rseding91 »

It's not going to happen. Every reason I listed before is still true today. The logic you wrote is the exact overhead I'm not willing to add to every single mining drill in the game that will suffer the slowdown for something base game is not going to use.
If you want to get ahold of me I'm almost always on Discord.
MarcasRealAccount
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu Aug 27, 2020 7:46 pm
Contact:

Re: Recipes for mining?

Post by MarcasRealAccount »

In that case, would it be possible to have a new event like on_mining_drill_mine or something like it, where it executes when it mines an ore?
So that it wouldn't require as much trickery on my mods end that could mess up the game, or do you have a better solution?

Btw I made a "simple" test for the performance difference between regular miners and a method with recipes for mining and maybe I did something wrong because it ended up with up to 60% slower speeds, I should point out the test didn't use factorio in any way that's why I said "maybe I did something wrong".
Rseding91
Factorio Staff
Factorio Staff
Posts: 14655
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Recipes for mining?

Post by Rseding91 »

MarcasRealAccount wrote: Fri Aug 28, 2020 4:41 pm In that case, would it be possible to have a new event like on_mining_drill_mine or something like it, where it executes when it mines an ore?
So that it wouldn't require as much trickery on my mods end that could mess up the game, or do you have a better solution?
That's in the same realm as assembling machines/furnaces firing an event when they finish; not likely to ever happen due to performance concerns. Firing events has a performance impact even if zero mods are listening to the event and mining drills, assembling machines, and furnaces exist in thousands (and sometimes tens of thousands) and are constantly consuming and or producing items as they run.
MarcasRealAccount wrote: Fri Aug 28, 2020 4:41 pm Btw I made a "simple" test for the performance difference between regular miners and a method with recipes for mining and maybe I did something wrong because it ended up with up to 60% slower speeds, I should point out the test didn't use factorio in any way that's why I said "maybe I did something wrong".
It all depends on how it's implemented. Recipe lookups can be done multiple ways and depending on how it was done it could be O(1), O(log(N)), O(N), or worse. Iterating a list of ingredients and products also has extra overhead because they're going to be more indirection and more memory that has to be pulled in from system RAM.

There's a reason Factorio runs as well as it does and it's because we don't do things like you're attempting to do :P
If you want to get ahold of me I'm almost always on Discord.
MarcasRealAccount
Manual Inserter
Manual Inserter
Posts: 4
Joined: Thu Aug 27, 2020 7:46 pm
Contact:

Re: Recipes for mining?

Post by MarcasRealAccount »

I guess I will have to try to make it run on a certain number of miners each tick so that it doesn't lag as much as 50 ms with 1000 miners.

Well thanks anyway :)

As for the performance hit I think it had to do with getting the next resource, because I don't know if you keep resources in its own array or in a shared list of entities, and so I went with the worst case (being shared list of entities)... yeah well I can't say for sure because I don't know of a good method to debug timings of functions in java without literally running them more than 1000 times on functions that take less than 1 ms due to System.nanoTime() giving like a minimum delta time of 300'000 ns on my system.

Edit: I feel very happy getting 4000 miners to run under 0.3 ms where it runs 60 miners each tick, and without stuttering. I think I can go way higher
Edit 2: 17640 miners also run at under 0.3 ms I think the lag prevention works :D
Post Reply

Return to “Won't implement”