Page 1 of 1

Drill resource output type

Posted: Tue Mar 11, 2014 3:06 pm
by Rathael
Can we get the ability to specify which resource in range of a drill will be mined?

Re: Drill resource output type

Posted: Tue Mar 11, 2014 4:49 pm
by AlexPhoenix
you can specify resource category, not exactly resources.
coal-ore,copper-ore,iron-ore => basic-solid
crude-oil => basic-fluid.

base\prototypes\categories\resource-category.lua
definition of the, here.

in resource definition this is variable:

Code: Select all

    category = "basic-fluid",
default basic-solid as i can see

so, you can use this.

Re: Drill resource output type

Posted: Tue Mar 11, 2014 6:04 pm
by Rathael
Yes, I know about those two categories. I made a modular drills mod. It has a Modular Drill factory where you can exchange a Basic Mining Drill for a Modular Drill item. Then you select which drill type you want and use the Modular Drill plus some other resources to change it into a specific resource drill like an Iron Drill Mk 1, Coal Drill mk4. But there is no way to specify which resource should be mined by the drill. I want to be able to place the drill so it covers say iron and copper, but will only mine the iron and leave the copper alone.

Re: Drill resource output type

Posted: Tue Mar 11, 2014 6:06 pm
by ludsoe
Id rather just have a UI button on we can push to change what a miner does. Maybe this can go under suggestions?

Re: Drill resource output type

Posted: Tue Mar 11, 2014 6:30 pm
by AlexPhoenix
Rathael wrote:Yes, I know about those two categories. I made a modular drills mod. It has a Modular Drill factory where you can exchange a Basic Mining Drill for a Modular Drill item. Then you select which drill type you want and use the Modular Drill plus some other resources to change it into a specific resource drill like an Iron Drill Mk 1, Coal Drill mk4. But there is no way to specify which resource should be mined by the drill. I want to be able to place the drill so it covers say iron and copper, but will only mine the iron and leave the copper alone.
i mean you can create your own cats and change standart resources cats(and then standart mining drill resource_categories, to access all solids)
and you will have what you want :)

Re: Drill resource output type

Posted: Tue Mar 11, 2014 7:15 pm
by Rathael
AlexPhoenix wrote:i mean you can create your own cats and change standart resources cats(and then standart mining drill resource_categories, to access all solids)
and you will have what you want :)
Hmm I thought about that, but wouldn't it break compatibility for other mods like Dytech?

Re: Drill resource output type

Posted: Tue Mar 11, 2014 7:52 pm
by slay_mithos
What you can do for compatibility is to make a small mod that requires dytech and makes the changes to its miners, just like you do to change the base prototypes in your mod.

Re: Drill resource output type

Posted: Tue Mar 11, 2014 8:04 pm
by FreeER
What you can do for compatibility is to make a small mod that requires dytech and makes the changes to its miners, just like you do to change the base prototypes in your mod.
In this case what you'd probably want to use a mod dependency of "? dytech" so that dytech gets loaded before your mod does (if it exists, if it doesn't then the dependency is ignored) and then in your data.lua file use if data.raw["some-dytech-drill"] then require("file-that-modifies-dytech-miners") end. This way you only try to modify dytech if it's actually there. Replace the strings in the if statement with the proper names of course :)
But, you'd have to do the same for every mod that you want compatibility for (and adds drills) and keep the modifying files updated with the other mods...

Re: Drill resource output type

Posted: Tue Mar 11, 2014 8:18 pm
by slay_mithos
I didn't know you could do a dependency that would not require the mod to be present, very good information, thanks.

Re: Drill resource output type

Posted: Wed Mar 12, 2014 1:46 am
by Rathael
Thanks! I will do it this way, but I don't like it. There may not be many mods right now, but that will change once more people start to play Factorio. Having to keep updated copies of every mod that touches drills or adds a new resource could become a huge problem. It would be easier if there was simply a line like resource_output = {"iron-ore"} or resource_output = {"basic-solid", "quartz-ore", "somedytech-ore"} in there.

Re: Drill resource output type

Posted: Wed Mar 12, 2014 1:59 am
by FreeER
Well, you could always create a regular entity and use control.lua to make it 'mine' what you want (assuming you can reach the category of the resource through lua, I would think so but I haven't tested it). You'd store a table of the nearby ore you are going to mine (using game.findentitiesfiltered{name="resource_you_want_to_mine", area=some_distance_you_want}) and then in ontick reduce the table.oreEntity.amount by 1 (after checking that exists, and removing it from the table if it doesn't) and insert that amount into the drill entity (and/or place that resource on the ground/, and/or check for an existing entity to one side of it...not sure how you could allow rotation though). I don't think that findentitiesfiltered can filter based on category, but you should be able to filter based on type="resource" and then remove any entities from the resulting table that do not match the category you want to mine (again, assuming you can reach the category of a resource through lua).

Not sure if that method is really 'better', but it is more compatible with other mods. Not certain why I didn't mention this before :lol:

edit: perhaps a different interface request would be to allow accessing the rotation of an entity through lua, then people could determine where to place items based on that...

edit2:
slay_mithos wrote:I didn't know you could do a dependency that would not require the mod to be present, very good information, thanks.
Yep, it is useful at times, and you are completely welcome :D

Re: Drill resource output type

Posted: Wed Mar 12, 2014 9:18 am
by Dysoch
slay_mithos wrote:I didn't know you could do a dependency that would not require the mod to be present, very good information, thanks.
if you want to see them in action, download v1.3 of my mod and check the data.lua file in the main folder.
all the mod compatibilities are there.