Configurable Custom Electric Mining Drill


Adds a custom Electric Mining Drill for which mining speed, area size and module slots can be configured. Energy use, pollution rate - and optionally recipe ingredient cost - scale with mining speed to somewhat preserve game balance. Has support for custom ore categories.

Content
2 days ago
1.1 - 2.0
1.56K
Mining Cheats

i ✔ [Feature Request] Allow custom resource categories

1 year, 3 months ago

Some mods make resources that don't conform to the resource category "basic-solid". It would be nice if there was a setting field where I can specify with a comma separated list of resource categories the mining drill is able to mine. For example, space exploration doesn't allow mining of iridite and naquium with normal mining drills, because their resource category is "hard-resource", so a drill that can mine all the solids then for space exploration would specify "basic-solid,hard-resource"

Don't know of other mods that add in other resource categories, but I would not mind being able to manually specify the category as needed.

1 year, 3 months ago

All right, I'll look into it. Since you never know what kind of custom resource categories might be added by other mods, adding an option with a text field in settings seems like a good idea. I am rather new to programming and modding Factorio, so it will probably take a little while for me to figure out.

By the way, do any of these resources from SE require any kind of input (like sulfuric acid) to be provided to the drill? I don't know yet, whether that might play a role.

1 year, 3 months ago

both of the hard resources used by space exploration do in fact require sulfuric acid for mining.

1 year, 3 months ago

Hi again, I actually found out half an hour ago. :-) Anyway, I have just succeeded in making a functioning prototype with input from a comma-separated list in the settings! The custom drill can now be placed on either resource without problems, and it can mine them as long as sulfuric acid is supplied. The mining speed does seem extraordinarily slow, especially for naquitite, but aside from that the speed and everything else scales properly with the settings.

Now I just gotta refine the code, add in proper checks and test it some more to ensure its function.

1 year, 3 months ago
(updated 1 year, 3 months ago)

Just an update: The mod now seems to work fine, but there are some things I still want to improve.

There are some very weird mod conflicts with AAI Industry and BottleNeck Lite, where they just don't accept my mod adding a resource category to my mining drill if it doesn't exist already within the Prototype/ResourceCategory table, causing a fail to load. It can get even worse if various mods are uninstalled and reinstalled. I don't like that, so I figured that maybe it would help to check if data.raw["resource-category"] contains any of the names from the new list, then add the existing ones to the mining drill while ignoring anything non-existent, but for some reason I just can't make it work.

So for now I don't check, but simply add whatever is written in the text-field (parsing it to a list with string values) to both the mining drill and the category list, whether they are used for anything or not. It works fine, seems to tolerate bad input and it resolves the above issues somehow. But it is something I want to improve on, since it feels like a hack.

I will have to research other mods and see if they have a solution.

1 year, 3 months ago
(updated 1 year, 3 months ago)

The way to check when iterating through the list of supplied names, is to do something like this.

if data.raw["resource-category"][name_to_check] then
    -- Code to add the resource category name to the mining drill.
end

Or the other alternative is to do the following.

for _, resource in pairs(data.raw["resource-category"])
    if resource.name == name_to_check then
        -- Code to add the resource category to the mining drill
    end
end

In any case, the best time to run any of that code is during data-final-fixes.lua

1 year, 3 months ago

Thank you very much, the second solution was just what I needed! I had tried a lot of very similar things, even at the final loading stage, but I just couldn't quite get it right.

It works as I want it now. Nothing is written to the category table, it is only used as a check, while useless entries in the text-field are simply ignored. Gotta take a break, and then I will test everything again and make sure it works.

1 year, 3 months ago

Done! The newest version, v.0.5.1, has been uploaded! Everything seems to be in order.

1 year, 3 months ago

By the way, feedback is welcome. :-)

New response