[Help wanted] Defining new Resource and Mining Result

Place to get help with not working mods / modding interface.
User avatar
Vigil
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sat Jun 04, 2016 7:38 pm
Contact:

[Help wanted] Defining new Resource and Mining Result

Post by Vigil »


[TL;DR] I need help creating a resource patch like crude oil that makes solid items, with a min output per cycle, and help creating a machine that drills that resource. Details below.


I mean to make a special kind of mineral mining site that behaves largely like crude oil patches, but produces a solid item, with a minimum rate of 1 item per mining cycle. I want it to be very sparse and very rare so that whenever you find one it feels like the biter god of nauvis himself has blessed you, because these veins will hopefully be quite powerful but power-hungry to mine.

In ..\Factorio\data\base\prototypes\entity\resources.lua the crude oil definition can be found.
As of 0.14.XX,

Code: Select all

LINE9: category = "basic-fluid",

LINE12: minimum = 1500,
LINE13: normal = 15000,

LINE31: autoplace={ 
to LINE48

LINE49: stage_counts = {0},
LINE50: stages={
to LINE64
Please correct me if I am wrong, but from this I can make the following assumptions:

- 9 - This category can be set to basic-solid safely, and whatever new building is placed on the new resource spot can harvest solids, right?

- 12 - This just decides what the lowest possible amount of material per SECOND can be produced, right? I could increase this tenfold to go from 0.1/s to 1/s, right?
- 13 - This describes the value that 63% of all crude oil spots will be within 1 standard deviation of, right, as according to the Normal Distribution?

- 31~48 - These are the world generation parameters, right? How do they work, if anyone knows?

- 49 - This describes how the seam changes each time a threshold is crossed, right? Like how ore spots get more and more sparse as they're harvested?

- 50~64 - This tells Factorio how the stages change each time a threshold is passed, and where they are on the spritesheet, right? How are they set out?

Also, could someone please advise me - does Factorio use the demo-resources prototype to handle all other resource generation, even in the full game? If so, that's tremendously confusing and I'm grumpy about it. ;P

Thanks in advance for any help offered. If this thread already exists somewhere, link me to it and I'll get rid of this one, if I can.

I am already under the assumption that I'll have to make a new resource category for solids if I don't want players to be able to just pop a mining drill onto the site; I'd also like to know if that's possible, or even the right thing to do.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [Help wanted] Defining new Resource and Mining Result

Post by bobingabout »

Demo prefixed files are the only files loaded for the Demo.
All files are loaded for the full version of the game.

basic-fluid and basic-solid are basically just filters to say HOW you can mine it. in this instance, basic-fluid limits it to the oil drill, and basic-fluid limits it to hand mining, burner miner drill, and electric miner drill. Take a look at the 3 mining building entities, you'll notice the same limits (basic-fluid or basic-solid) is listed on the entity. What is actually mined (an item, or a fluid) doesn't really matter, as long as the mining entity is set up to handle that resource, so making a resource that combines the two methods is possible.
You can quite easily make new resource categories and add them to a resource and mining entity as you see fit.

Minimum and Normal work together, the amount you mine (Per second) is minimum/normal. so 1500/15000 results in 0.1(units per second). Neither tag actually controls anything about how much a resource entity will actually have.

Your other assumptions look about right.

An important note though about using infinite/minimum/maximum like oil: If you set a resource to "infinite" to use this system then it will always tell you it mines in resource per second, but if a mining entity covers more than a single node, the readings will tell you it mines at the speed of every node added together, when in reality it will cycle through all nodes and mine one at a time. If you plan to set up a new resource that is infinite, try and set it up so you can't mine more than a single node at a time. (Just like Oil.)
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
User avatar
Vigil
Burner Inserter
Burner Inserter
Posts: 12
Joined: Sat Jun 04, 2016 7:38 pm
Contact:

Re: [Help wanted] Defining new Resource and Mining Result

Post by Vigil »

bobingabout wrote:Demo prefixed files are the only files loaded for the Demo.
All files are loaded for the full version of the game.

basic-fluid and basic-solid are basically just filters to say HOW you can mine it. in this instance, basic-fluid limits it to the oil drill, and basic-fluid limits it to hand mining, burner miner drill, and electric miner drill. Take a look at the 3 mining building entities, you'll notice the same limits (basic-fluid or basic-solid) is listed on the entity. What is actually mined (an item, or a fluid) doesn't really matter, as long as the mining entity is set up to handle that resource, so making a resource that combines the two methods is possible.
You can quite easily make new resource categories and add them to a resource and mining entity as you see fit.

Minimum and Normal work together, the amount you mine (Per second) is minimum/normal. so 1500/15000 results in 0.1(units per second). Neither tag actually controls anything about how much a resource entity will actually have.

Your other assumptions look about right.

An important note though about using infinite/minimum/maximum like oil: If you set a resource to "infinite" to use this system then it will always tell you it mines in resource per second, but if a mining entity covers more than a single node, the readings will tell you it mines at the speed of every node added together, when in reality it will cycle through all nodes and mine one at a time. If you plan to set up a new resource that is infinite, try and set it up so you can't mine more than a single node at a time. (Just like Oil.)
@bobingabout: Thank you very much, this information is tremendously helpful! I did not know about some of the quirks you included at the end, so that's helpful information, too... Incidentally, if neither of those tags control how much resource the entity has, how do I control that, myself? edit: I suppose being able to choke the minimum value should actually be all I need in that regard, seeing as they deplete over time...
[ Currently not able to service requests. Apologies for the inconvenience. ]
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [Help wanted] Defining new Resource and Mining Result

Post by bobingabout »

Minimum value is the amount it stops depleating at. set it to 1, and you'll reduce the resource all the way down to 1 unit, and then it stays there. Set it to 1000, and it stops at 1000. However if you set it to 1000 and it starts at 500, it will be stuck at 500.


what controls how "Rich" a resource is, is controlled by the following lines (They're in the autoplace controls)
richness_multiplier = 13000,
richness_base = 350,
I don't know how they actually work, but by tweaking these values will change how much is in a single entity. Pre-0.13 they also used to control how often a resource would apear, and how large a patch would be, by being affected by the noise layer, which made things quite difficult to work out how much was in a resource (and changing map settings could cause a resource to not apear at all... or cover the entire map if calculated wrong) so 0.13 introduced a new tag
coverage = 0.02, -- Cover on average 2% of surface area.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
Post Reply

Return to “Modding help”