Help making an Infinite Resources mod

Place to get help with not working mods / modding interface.
Post Reply
User avatar
sonaxaton
Burner Inserter
Burner Inserter
Posts: 16
Joined: Sat Dec 30, 2017 12:18 am
Contact:

Help making an Infinite Resources mod

Post by sonaxaton »

I'm trying to make a very simple mod which makes all resources infinite and not deplete. Before 0.17.65 this was pretty easy, I just set infinite = true and infinite_depletion_amount = 0 on every resource and that was pretty much it. However, after that update changed the way infinite yields affect mining yields, you now have a situation where ores spawn with 1000% yield, meaning you mine about 10 ores at a time. What I really want is a way to change the autoplace settings of all resources so that the yield is always a static 100%, but I can't figure out a good way to this without affecting the other parts of the autoplace settings like where patches are placed and how big they are. All I want to change is how yield is calculated when placing individual entities. Is this possible? I've tried playing around with the minimum and normal properties of resources, but they only seem to set a multiplier on resource yields.

User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 2420
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: Help making an Infinite Resources mod

Post by BlueTemplar »

Too late, somebody else already did it* ! :P
*(or at least found a way to approximate the desired result...)
See this discussion :
viewtopic.php?p=450709#p450709
BobDiggity (mod-scenario-pack)

User avatar
sonaxaton
Burner Inserter
Burner Inserter
Posts: 16
Joined: Sat Dec 30, 2017 12:18 am
Contact:

Re: Help making an Infinite Resources mod

Post by sonaxaton »

Thanks! It looks like they have the exact same problems as me. I'll check out their mod and see if I can get inspiration from them. For reference this is my mod: https://mods.factorio.com/mod/sonaxaton ... -resources

User avatar
sonaxaton
Burner Inserter
Burner Inserter
Posts: 16
Joined: Sat Dec 30, 2017 12:18 am
Contact:

Re: Help making an Infinite Resources mod

Post by sonaxaton »

Okay so I took the idea from that thread to just retroactively update resource patches when they're generated in control.lua like so:

Code: Select all

script.on_event(defines.events.on_chunk_generated, function(event)
    resources = event.surface.find_entities_filtered{
        area = event.area,
        type = "resource",
    }
    for _, resource in pairs(resources) do
        -- set all new resources to exactly their normal amount
        resource.amount = resource.prototype.normal_resource_amount
    end
end)
This seems to work well.

Post Reply

Return to “Modding help”