Page 1 of 1

[MOD 0.12.x] Multiplied Minables

Posted: Tue May 03, 2016 8:28 pm
by Bokrug
Description:
  • Multiplies the amount of ore received from mining by x2, x5, or x10. Just in case you thought the game was too slow.
    Requested by a redditor and made possible by prg.
Image Image

Details:
  • Name: Multiplied Minables
    Catagory: Convinience
    MOD Version: 0.1.0
    Factorio Version: 0.12.x
    License: MIT

Re: [MOD 0.12.x] Multiplied Minables

Posted: Tue May 03, 2016 8:30 pm
by mooklepticon
Someone on Reddit was just asking about something like this!

Re: [MOD 0.12.x] Multiplied Minables

Posted: Tue May 03, 2016 8:38 pm
by Bokrug
mooklepticon wrote:Someone on Reddit was just asking about something like this!
I saw that and decided to to take a shot at it.

Re: [MOD 0.12.x] Multiplied Minables

Posted: Tue May 03, 2016 10:25 pm
by mooklepticon
Bokrug wrote:
mooklepticon wrote:Someone on Reddit was just asking about something like this!
I saw that and decided to to take a shot at it.
You are a good human.

Re: [MOD 0.12.x] Multiplied Minables

Posted: Fri May 06, 2016 5:26 pm
by SoulForge
Can support be added for mods that add ores like bobs?

I tried to add to your existing list;

data.raw["resource"]["zinc-ore"].minable.count = 10

But it throws errors.

Re: [MOD 0.12.x] Multiplied Minables

Posted: Fri May 06, 2016 5:33 pm
by orzelek
SoulForge wrote:Can support be added for mods that add ores like bobs?

I tried to add to your existing list;

data.raw["resource"]["zinc-ore"].minable.count = 10

But it throws errors.
You can add it but it needs to execute after ore has been added.
Setting optional dependency for bobsores might solve this.

Re: [MOD 0.12.x] Multiplied Minables

Posted: Fri May 06, 2016 7:23 pm
by SoulForge
orzelek wrote:
SoulForge wrote:Can support be added for mods that add ores like bobs?

I tried to add to your existing list;

data.raw["resource"]["zinc-ore"].minable.count = 10

But it throws errors.
You can add it but it needs to execute after ore has been added.
Setting optional dependency for bobsores might solve this.
Just as a side question to this. How would that work with angels infinite ores? It still only pulls 1 from those patches.

Re: [MOD 0.12.x] Multiplied Minables

Posted: Fri May 06, 2016 8:25 pm
by prg
Maybe just go through all the resources and multiply the count of everything that's not a fluid.

Code: Select all

for _, res in pairs(data.raw.resource) do
    if not res.category --crude-oil has "basic-fluid" here, for ores this is nil
    and res.minable then
        if res.minable.count then
            res.minable.count = res.minable.count * 10
        else
            res.minable.count = 10
        end
    end
end
Do this in data-updates.lua so other mods will already have added their own entities.

edit: and this should now work with resources that drop multiple results:

Code: Select all

multiplier = 10

for _, res in pairs(data.raw.resource) do
    if not res.category --crude-oil has "basic-fluid" here, for ores this is nil
    and res.minable then
        if res.minable.result then
            if res.minable.count then
                res.minable.count = res.minable.count * multiplier
            else
                res.minable.count = multiplier
            end
        elseif res.minable.results then
            for _, result in pairs(res.minable.results) do
                result.amount_min = result.amount_min * multiplier
                result.amount_max = result.amount_max * multiplier
            end
        end
    end
end
Warning: not really tested.

Re: [MOD 0.12.x] Multiplied Minables

Posted: Sat May 07, 2016 7:02 am
by sporefreak
Don't suppose it would be possible to make it so a special pick causes more ores instead of automatic multiplied ores?
In my current mod pack i would love to make player mining always faster then drilling (as long as you keep up with it and have only a few miners)

Re: [MOD 0.12.x] Multiplied Minables

Posted: Sun May 08, 2016 1:43 pm
by SoulForge
prg wrote:Maybe just go through all the resources and multiply the count of everything that's not a fluid.

Code: Select all

for _, res in pairs(data.raw.resource) do
    if not res.category --crude-oil has "basic-fluid" here, for ores this is nil
    and res.minable then
        if res.minable.count then
            res.minable.count = res.minable.count * 10
        else
            res.minable.count = 10
        end
    end
end
Do this in data-updates.lua so other mods will already have added their own entities.

edit: and this should now work with resources that drop multiple results:

Code: Select all

multiplier = 10

for _, res in pairs(data.raw.resource) do
    if not res.category --crude-oil has "basic-fluid" here, for ores this is nil
    and res.minable then
        if res.minable.result then
            if res.minable.count then
                res.minable.count = res.minable.count * multiplier
            else
                res.minable.count = multiplier
            end
        elseif res.minable.results then
            for _, result in pairs(res.minable.results) do
                result.amount_min = result.amount_min * multiplier
                result.amount_max = result.amount_max * multiplier
            end
        end
    end
end
Warning: not really tested.
It works! But if you don't go in and alter the original resources amount (or remove it) it multiples that value as well. Giving 100 per strike for the original ores

Re: [MOD 0.12.x] Multiplied Minables

Posted: Fri May 13, 2016 6:53 pm
by SoulForge
I retract what I said. It works for the Dark Matter ore but bobs ores throw an error.

Code: Select all

Error Util.cpp:58: __multi-mine-x10__/data-updates.lua:14: attempt to perform arithmetic on field 'amount_min' (a nil value)

Re: [MOD 0.12.x] Multiplied Minables

Posted: Fri May 13, 2016 7:12 pm
by prg
Ah, instead of separately specifying amount_min and _max, it's possible to simply use amount. So check which value actually exists and only multiply that one.

Re: [MOD 0.12.x] Multiplied Minables

Posted: Fri May 13, 2016 7:23 pm
by SoulForge
prg wrote:Ah, instead of separately specifying amount_min and _max, it's possible to simply use amount. So check which value actually exists and only multiply that one.
Thanks prg.

I have altered it with your suggestion and now it works. Code should read as;

Code: Select all

multiplier = 10

for _, res in pairs(data.raw.resource) do
    if not res.category --crude-oil has "basic-fluid" here, for ores this is nil
    and res.minable then
        if res.minable.result then
            if res.minable.count then
                res.minable.count = res.minable.count * multiplier
            else
                res.minable.count = multiplier
            end
        elseif res.minable.results then
            for _, result in pairs(res.minable.results) do
                result.amount = result.amount * multiplier
            end
        end
    end
end
Is it possible to fix this further to not need the resources file? I am still learning by altering what already exists.

Re: [MOD 0.12.x] Multiplied Minables

Posted: Fri May 13, 2016 7:46 pm
by prg
SoulForge wrote:

Code: Select all

multiplier = 10

for _, res in pairs(data.raw.resource) do
    if not res.category --crude-oil has "basic-fluid" here, for ores this is nil
    and res.minable then
        if res.minable.result then
            if res.minable.count then
                res.minable.count = res.minable.count * multiplier
            else
                res.minable.count = multiplier
            end
        elseif res.minable.results then
            for _, result in pairs(res.minable.results) do
                result.amount = result.amount * multiplier
            end
        end
    end
end
This should now blow up when amount_min and _max are used instead of just amount. You need to check which values exist and only multiply those.
SoulForge wrote:Is it possible to fix this further to not need the resources file? I am still learning by altering what already exists.
What resources file?

Re: [MOD 0.12.x] Multiplied Minables

Posted: Fri May 13, 2016 7:53 pm
by SoulForge
prg wrote:
SoulForge wrote:

Code: Select all

multiplier = 10

for _, res in pairs(data.raw.resource) do
    if not res.category --crude-oil has "basic-fluid" here, for ores this is nil
    and res.minable then
        if res.minable.result then
            if res.minable.count then
                res.minable.count = res.minable.count * multiplier
            else
                res.minable.count = multiplier
            end
        elseif res.minable.results then
            for _, result in pairs(res.minable.results) do
                result.amount = result.amount * multiplier
            end
        end
    end
end
This should now blow up when amount_min and _max are used instead of just amount. You need to check which values exist and only multiply those.
SoulForge wrote:Is it possible to fix this further to not need the resources file? I am still learning by altering what already exists.
What resources file?
The resource.lua file included with the original mod.

Has this in it;

Code: Select all

data.raw["resource"]["iron-ore"].minable.count = 10
data.raw["resource"]["copper-ore"].minable.count = 10
data.raw["resource"]["coal"].minable.count = 10
data.raw["resource"]["stone"].minable.count = 10
EDIT; Nevermind. I should follow through with my thoughts before posting it would seem. I removed everything but the data-updates file and the json file and it still works.

Re: [MOD 0.12.x] Multiplied Minables

Posted: Fri May 13, 2016 7:59 pm
by prg
SoulForge wrote:The resource.lua file included with the original mod.

Has this in it;

Code: Select all

data.raw["resource"]["iron-ore"].minable.count = 10
data.raw["resource"]["copper-ore"].minable.count = 10
data.raw["resource"]["coal"].minable.count = 10
data.raw["resource"]["stone"].minable.count = 10
That just hardcodes increased values for the base game resources. This is not needed anymore since we just go through all the resources later and multiply those.