Mining results without resource patch?

Place to get help with not working mods / modding interface.
BinaryMan
Inserter
Inserter
Posts: 21
Joined: Mon Mar 24, 2014 12:02 am
Contact:

Mining results without resource patch?

Post by BinaryMan »

I was trying to figure out how to place an entity (doesn't need to be on a resource tile) that will effectively mine random result ores from any resource definitions present in other mods, but with a low probability for each (like 1%). I don't think the MiningDrill prototype will work without resource tiles, so I thought maybe an assembler type entity with the recipe that uses stone and has "results = somefunction()"

In that function, I would like to enumerate through base ores and bob's ores (which are all presumably in a resource type array somewhere) and assign probabilities say default = 0.01 (1%) drop rate, and for ores that I know are there and common like copper/iron I would assign a higher drop rate on those. However, that would be potentially a dozen or more results so I am not sure that is the best approach.

Perhaps if I can trick a mining drill into thinking there is a resource by checking every second (via ticks events) and putting an invisible resource layer around the player's position so that the miner is able to be placed, and giving it a really high value so that the "fake resource" never runs out? Then remove all regular resources from the map except maybe oil (although if using the assembler approach it could be a fluid output with a probability).
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5289
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Mining results without resource patch?

Post by Klonan »

Well heres an idea,

Use a chemical plant as the item to place, make it a custom one with 1 fluid output, call this output the 'mining drill output', but basically just for the direction of the mining drill.

when the chemical plant is placed, use the 'on_entity_built' event to remove the chemical plant, stamp down a mining drill with the same direction, and then spawn a resource entity underneath the mining drill.

Then, use the destroyed/mined/deconstructed events to remove that resource tile when the mining drill is removed.
BinaryMan
Inserter
Inserter
Posts: 21
Joined: Mon Mar 24, 2014 12:02 am
Contact:

Re: Mining results without resource patch?

Post by BinaryMan »

Code: Select all

    ingredients =
    {
    },
    results = 
    {
      {type="fluid", name="water", amount=10}
    },
I found this in bob's water pump which makes "free" water. But I could use something like:

Code: Select all

{type="item", name="iron-ore", amount=1, probability = 0.1}
{type="item", name="copper-ore", amount=1, probability = 0.1}
... other ores and probabilities ... 
{type="fluid", name="crude-oil", amount=1, probability = 0.1}
That should do it for all general resources. Crafting speed, chances, pollution, and power use can be adjusted easily enough to balance that. I guess resource-specific recipes can be made the same way (say, for iron only, higher chance of iron but less or no others).

My motivation for doing it is to enable a scenario where my starting area is smaller and I play with max biter settings, so instead of trying to get all the ores to spawn in a small area which usually doesn't work well (overlapping small resource disappears or resource patch too close to biters) the "underground mining" method using a recipe would make that scenario more playable regardless of autoplace settings. I am still learning on the scripting...
Post Reply

Return to “Modding help”