Page 1 of 1

Modding mining drills to work without an ore patch

Posted: Sat Mar 20, 2021 5:28 am
by Octavio
Hi,
I'm trying to mod the mining drills to work without an ore patch. I mostly succeeded. I changed its type to be an assembler and set the respective recipes. Everything works fine except that the drills are completely invisible. I imagine that they lost all the graphics and animation references.

Does anyone know an easy way to keep the original graphics and animations without having to copy all the respective code from the original?

Here's an extract of the code I have so far (data.lua)...
data:extend({
{
type = "recipe-category",
name = "mining"
}
})

data:extend({
{
type = "recipe",
name = "coal",
category = "mining",
enabled = true,
ingredients = {},
energy_required = 8,
result = "coal"
}
})

local drill = data.raw['mining-drill']['burner-mining-drill']
data.raw['mining-drill']['burner-mining-drill'] = nil
drill.type = "assembling-machine"
drill.crafting_speed = 1
drill.crafting_categories = {"mining"}
data:extend({drill})

Re: Modding mining drills to work without an ore patch

Posted: Sat Mar 20, 2021 5:47 am
by Trific
Use table.deepcopy like this:

Code: Select all

local drill = table.deepcopy(data.raw['mining-drill']['burner-mining-drill'])
data.raw['mining-drill']['burner-mining-drill'] = nil
drill.type = "assembling-machine"
drill.crafting_speed = 1
drill.crafting_categories = {"mining"}
data:extend({drill})

Re: Modding mining drills to work without an ore patch

Posted: Sat Mar 20, 2021 6:00 am
by Optera
If you also want that drill to be affected by mining productivity research you'll have to use hidden beacons with productivity modules and update them in control.

Re: Modding mining drills to work without an ore patch

Posted: Sat Mar 20, 2021 6:12 am
by Octavio
Trific wrote: Sat Mar 20, 2021 5:47 am Use table.deepcopy like this:

Code: Select all

local drill = table.deepcopy(data.raw['mining-drill']['burner-mining-drill'])
data.raw['mining-drill']['burner-mining-drill'] = nil
drill.type = "assembling-machine"
drill.crafting_speed = 1
drill.crafting_categories = {"mining"}
data:extend({drill})
That didn't work. Still invisible. :-(
I'm guessing that the program looks for different properties for the animations in assemblers and mining drills.

Re: Modding mining drills to work without an ore patch

Posted: Sat Mar 20, 2021 7:42 am
by DaveMcW
Yes, assembling-machine uses "animation" while mining-drill uses "animations".

I'm surprised you got as far as you did, I would strongly recommend only copying something of the same type.

Code: Select all

local drill = table.deepcopy(data.raw['assembling-machine']['assembling-machine-2'])
drill.name = "custom-mining-drill"
drill.crafting_speed = 1
drill.crafting_categories = {"mining"}
drill.animation = table.deepcopy(data.raw['mining-drill']['burner-mining-drill'].animations)
data:extend({drill})
I also recommend you don't steal entity names from the base game, as that will cause a bunch of mod conflicts.

Re: Modding mining drills to work without an ore patch

Posted: Sat Mar 20, 2021 12:16 pm
by Octavio
drill.animation = table.deepcopy(data.raw['mining-drill']['burner-mining-drill'].animations)
Thanks a lot! That worked.
And I appreciate the advice. I'm quite new to modding.