Modding mining drills to work without an ore patch

Place to get help with not working mods / modding interface.
Octavio
Burner Inserter
Burner Inserter
Posts: 6
Joined: Tue Aug 29, 2017 10:38 pm
Contact:

Modding mining drills to work without an ore patch

Post 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})
Trific
Fast Inserter
Fast Inserter
Posts: 155
Joined: Thu Dec 31, 2020 7:57 pm
Contact:

Re: Modding mining drills to work without an ore patch

Post 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})
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Modding mining drills to work without an ore patch

Post 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.
Octavio
Burner Inserter
Burner Inserter
Posts: 6
Joined: Tue Aug 29, 2017 10:38 pm
Contact:

Re: Modding mining drills to work without an ore patch

Post 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.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3724
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Modding mining drills to work without an ore patch

Post 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.
Octavio
Burner Inserter
Burner Inserter
Posts: 6
Joined: Tue Aug 29, 2017 10:38 pm
Contact:

Re: Modding mining drills to work without an ore patch

Post 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.
Post Reply

Return to “Modding help”