Large Mining Drill Not Enlarged
- BraveCaperCat
- Filter Inserter
- Posts: 430
- Joined: Mon Jan 15, 2024 10:10 pm
- Contact:
Large Mining Drill Not Enlarged
Hi! I am making some larger mining drills and the texture i am using (the texture of the electric mining drill) and it's texture has the same size as the normal electric mining drill, as shown in this screenshot:
How do i enlarge the texture with code so that it fits the collision box (4 by 4)Creator of multiple mods, including Quality Assurance - My most popular one.
Go check them out with the first and second links!
I'll probably be wanting or giving help with modding most of the time I spend here on the forum.
Go check them out with the first and second links!
I'll probably be wanting or giving help with modding most of the time I spend here on the forum.
Re: Large Mining Drill Not Enlarged
Take a look at MiningDrillPrototype.animations. This is an array of 4 animations (one for each direction), and you can set the scale factor for each one of those. So something like this should work:BraveCaperCat wrote: Tue Jan 16, 2024 8:59 am How do i enlarge the texture with code so that it fits the collision box (4 by 4)
Code: Select all
local large_drill = data.raw["mining-drill"]["bmd:large-mining-drill"]
for d, direction in pairs({"north", "east", "south", "west"}) do
if large_drill.animations and large_drill.animations[direction] then
large_drill.animations[direction].scale = 2
end
end
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
- BraveCaperCat
- Filter Inserter
- Posts: 430
- Joined: Mon Jan 15, 2024 10:10 pm
- Contact:
Re: Large Mining Drill Not Enlarged
That still doesn't seem to work. I managed to fix the collision_box and vector_to_place_result offsets. (and add locals)Pi-C wrote: Tue Jan 16, 2024 7:26 pmTake a look at MiningDrillPrototype.animations. This is an array of 4 animations (one for each direction), and you can set the scale factor for each one of those. So something like this should work:BraveCaperCat wrote: Tue Jan 16, 2024 8:59 am How do i enlarge the texture with code so that it fits the collision box (4 by 4)Code: Select all
local large_drill = data.raw["mining-drill"]["bmd:large-mining-drill"] for d, direction in pairs({"north", "east", "south", "west"}) do if large_drill.animations and large_drill.animations[direction] then large_drill.animations[direction].scale = 2 end end
New screenshot: Entire Contents of data.lua in my mod (incase it helps)
Code: Select all
local function config(name)
return settings.startup['bmd:' .. name].value
end
local miningExtraLargeEnabled = config('add-extralarge-mining')
local miningSmallEnabled = config('add-small-mining')
local normalMiningChangesEnabled = config('change-normal-miners')
local difficulty = config('difficulty-mode')
-- Info = {Ingredients, MiningSpeed, EnergySource, Radius, OutputOffset, MiningRadius, MaxModuleCount, EnergyUsage, TechCost, TechRequirements}
local function addMiningDrill(name, originalName, info)
local MiningDrillItem = table.deepcopy(data.raw['item'][originalName])
MiningDrillItem.name = name
MiningDrillItem.place_result = name
local MiningDrillRecipe = table.deepcopy(data.raw['recipe'][originalName])
MiningDrillRecipe.name = name
MiningDrillRecipe.result = name
MiningDrillRecipe.enabled = false
MiningDrillRecipe.normal = nil
MiningDrillRecipe.expensive = nil
MiningDrillRecipe.ingredients = info[1]
local MiningDrillEntity = table.deepcopy(data.raw['mining-drill'][originalName])
MiningDrillEntity.name = name
MiningDrillEntity.minable.result = name
MiningDrillEntity.mining_speed = info[2]
MiningDrillEntity.energy_source = info[3] or MiningDrillEntity.energy_source
local MiningDrillOffset = 0
if info[5] % 2 == 0 then
info[5] = info[5] + 0.5
end
if info[4] % 2 == 0 then
MiningDrillOffset = 0.5
end
MiningDrillEntity.collision_box = {{-info[4] + MiningDrillOffset, -info[4] + MiningDrillOffset}, {info[4] + MiningDrillOffset, info[4] + MiningDrillOffset}}
MiningDrillEntity.drawing_box = {{(-info[4] + MiningDrillOffset) * 2, (-info[4] + MiningDrillOffset) * 2}, {(info[4] + MiningDrillOffset) * 2, (info[4] + MiningDrillOffset) * 2}}
MiningDrillEntity.selection_box = {{-info[4] - 0.5 + MiningDrillOffset, -info[4] - 0.5 + MiningDrillOffset}, {info[4] + 0.5 + MiningDrillOffset, info[4] + 0.5 + MiningDrillOffset}}
MiningDrillEntity.tile_height = info[4]
MiningDrillEntity.tile_width = info[4]
MiningDrillEntity.vector_to_place_result = {info[5], -info[4] - 0.5}
MiningDrillEntity.resource_searching_radius = info[6]
MiningDrillEntity.module_specification.module_slots = info[7]
MiningDrillEntity.energy_usage = info[8] or MiningDrillEntity.energy_usage
MiningDrillEntity.input_fluid_box.pipe_connections = {{position = {-info[4] - 0.5 + MiningDrillOffset, 0}}, {position = {info[4] + 0.5 + MiningDrillOffset, 0.5}}, {position = {0.5, info[4] + 0.5 + MiningDrillOffset}}}
for d, direction in pairs({'north', 'east', 'south', 'west'}) do
if MiningDrillEntity.animations and MiningDrillEntity.animations[direction] then
MiningDrillEntity.animations[direction].scale = info[4]
end
end
local MiningDrillTech = table.deepcopy(data.raw['technology']['automation'])
MiningDrillTech.name = name
MiningDrillTech.effects = {{type = 'unlock-recipe', recipe = name}}
MiningDrillTech.normal = nil
MiningDrillTech.expensive = nil
MiningDrillTech.unit = info[9]
MiningDrillTech.prerequisites = info[10]
data:extend({MiningDrillItem, MiningDrillRecipe, MiningDrillEntity, MiningDrillTech})
end
local SteelGearWheel = table.deepcopy(data.raw['item']['iron-gear-wheel'])
SteelGearWheel.name = 'bmd:steel-gear-wheel'
local SteelGearWheelRecipe = table.deepcopy(data.raw['recipe']['iron-gear-wheel'])
SteelGearWheelRecipe.name = 'bmd:steel-gear-wheel'
SteelGearWheelRecipe.result = 'bmd:steel-gear-wheel'
SteelGearWheelRecipe.enabled = false
SteelGearWheelRecipe.normal = nil
SteelGearWheelRecipe.expensive = nil
SteelGearWheelRecipe.ingredients = {{'steel-plate', 25}, {'iron-gear-wheel', 6}}
SteelGearWheelRecipe.result_count = 6
local SteelBendingTech = table.deepcopy(data.raw['technology']['steel-processing'])
SteelBendingTech.name = 'bmd:steel-bending'
SteelBendingTech.effects = {{type = 'unlock-recipe', recipe = 'bmd:steel-gear-wheel'}}
SteelBendingTech.normal = nil
SteelBendingTech.expensive = nil
SteelBendingTech.unit = {ingredients = {{'automation-science-pack', 1}}, time = 15, count = 175}
SteelBendingTech.prerequisites = {'steel-processing', 'automation'}
data:extend({SteelGearWheel, SteelGearWheelRecipe, SteelBendingTech})
local ComputingUnit = table.deepcopy(data.raw['item']['processing-unit'])
ComputingUnit.name = 'bmd:computing-unit'
local ComputingUnitRecipe = table.deepcopy(data.raw['recipe']['processing-unit'])
ComputingUnitRecipe.name = 'bmd:computing-unit'
ComputingUnitRecipe.result = 'bmd:computing-unit'
ComputingUnitRecipe.enabled = false
ComputingUnitRecipe.normal = nil
ComputingUnitRecipe.expensive = nil
ComputingUnitRecipe.ingredients = {{'processing-unit', 8}, {'advanced-circuit', 60}, {'steel-plate', 80}, {'bmd:steel-gear-wheel', 1}, {'laser-turret', 120}}
ComputingUnitRecipe.result_count = 6
data:extend({ComputingUnit, ComputingUnitRecipe})
local AdvancedComputingUnit = table.deepcopy(data.raw['item']['bmd:computing-unit'])
AdvancedComputingUnit.name = 'bmd:advanced-computing-unit'
local AdvancedComputingUnitRecipe = table.deepcopy(data.raw['recipe']['bmd:computing-unit'])
AdvancedComputingUnitRecipe.name = 'bmd:advanced-computing-unit'
AdvancedComputingUnitRecipe.result = 'bmd:advanced-computing-unit'
AdvancedComputingUnitRecipe.enabled = false
AdvancedComputingUnitRecipe.normal = nil
AdvancedComputingUnitRecipe.expensive = nil
AdvancedComputingUnitRecipe.ingredients = {{'processing-unit', 24}, {'advanced-circuit', 40}, {'steel-plate', 20}, {'bmd:computing-unit', 1}, {'laser-turret', 250}}
AdvancedComputingUnitRecipe.result_count = 6
data:extend({AdvancedComputingUnit, AdvancedComputingUnitRecipe})
local ComputingTech = table.deepcopy(data.raw['technology']['advanced-electronics-2'])
ComputingTech.name = 'bmd:computing'
ComputingTech.effects = {{type = 'unlock-recipe', recipe = 'bmd:computing-unit'}, {type = 'unlock-recipe', recipe = 'bmd:advanced-computing-unit'}}
ComputingTech.normal = nil
ComputingTech.expensive = nil
ComputingTech.unit = {ingredients = {{'automation-science-pack', 3}, {'logistic-science-pack', 2}, {'chemical-science-pack', 2}}, time = 45, count = 175}
ComputingTech.prerequisites = {'advanced-electronics-2', 'chemical-science-pack', 'bmd:steel-bending', 'laser-turret'}
log('bmd:computing' .. serpent.block(ComputingTech))
data:extend({ComputingTech})
local LargeMiningDrillIngredients = {}
local XLMiningDrillIngredients = {}
local XXLMiningDrillIngredients = {}
local LargeMiningDrillMiningSpeed = 2
local XLMiningDrillMiningSpeed = 6
local XXLMiningDrillMiningSpeed = 9
if difficulty == 'bmd:easy-difficulty' then
LargeMiningDrillIngredients = {{'advanced-circuit', 75 }, {'bmd:steel-gear-wheel', 150 }, {'steel-plate', 50 }}
XLMiningDrillIngredients = {}
XXLMiningDrillIngredients = {}
LargeMiningDrillMiningSpeed = 3
XLMiningDrillMiningSpeed = 7
XXLMiningDrillMiningSpeed = 10
elseif difficulty == 'bmd:normal-difficulty' then
LargeMiningDrillIngredients = {}
XLMiningDrillIngredients = {}
XXLMiningDrillIngredients = {}
LargeMiningDrillMiningSpeed = 2
XLMiningDrillMiningSpeed = 6
XXLMiningDrillMiningSpeed = 9
elseif difficulty == 'bmd:hard-difficulty' then
LargeMiningDrillIngredients = {}
XLMiningDrillIngredients = {}
XXLMiningDrillIngredients = {}
LargeMiningDrillMiningSpeed = 1
XLMiningDrillMiningSpeed = 5
XXLMiningDrillMiningSpeed = 8
end
local LargeMiningDrillInfo = {LargeMiningDrillIngredients, LargeMiningDrillMiningSpeed, nil, 2, 0, 12, 8, nil, {ingredients = {{'automation-science-pack', 5}, {'logistic-science-pack', 4}, {'chemical-science-pack', 3}, {'production-science-pack', 2}}, time = 75, count = 250}, {'production-science-pack', 'bmd:steel-bending'}}
local XLMiningDrillInfo = {XLMiningDrillIngredients, XLMiningDrillMiningSpeed, nil, 4, 0, 18, 10, nil, {ingredients = {{'automation-science-pack', 6}, {'logistic-science-pack', 5}, {'chemical-science-pack', 4}, {'production-science-pack', 3}, {'utility-science-pack', 2}}, time = 90, count = 300 }, {'production-science-pack', 'utility-science-pack', 'bmd:steel-bending', 'bmd:large-mining-drill', 'bmd:computing'}}
local XXLMiningDrillInfo = {XXLMiningDrillIngredients, XXLMiningDrillMiningSpeed, nil, 6, 0, 24, 12, nil, {ingredients = {{'automation-science-pack', 7}, {'logistic-science-pack', 6}, {'chemical-science-pack', 5}, {'production-science-pack', 4}, {'utility-science-pack', 3}}, time = 105, count = 350}, {'bmd:xl-mining-drill', 'electric-energy-distribution-2', 'speed-module-3', 'effect-transmission'}}
if miningExtraLargeEnabled then
addMiningDrill('bmd:large-mining-drill', 'electric-mining-drill', LargeMiningDrillInfo)
addMiningDrill('bmd:xl-mining-drill', 'bmd:large-mining-drill', XLMiningDrillInfo)
addMiningDrill('bmd:xxl-mining-drill', 'bmd:xl-mining-drill', XXLMiningDrillInfo)
end
Creator of multiple mods, including Quality Assurance - My most popular one.
Go check them out with the first and second links!
I'll probably be wanting or giving help with modding most of the time I spend here on the forum.
Go check them out with the first and second links!
I'll probably be wanting or giving help with modding most of the time I spend here on the forum.
Re: Large Mining Drill Not Enlarged
I think I know what's wrong: MiningDrillPrototype.animations is only used if MiningDrillPrototype.graphics_set is not defined, but it is set in your template (the vanilla electric-miner you've copied). So, check the description of graphics_set, look for everything that is an animation, and add/change the scale factor. (By the way, 2 is likely not the correct scale, you've got to find that yourself.)BraveCaperCat wrote: Wed Jan 17, 2024 5:50 pmThat still doesn't seem to work.Pi-C wrote: Tue Jan 16, 2024 7:26 pmTake a look at MiningDrillPrototype.animations. This is an array of 4 animations (one for each direction), and you can set the scale factor for each one of those. So something like this should work:BraveCaperCat wrote: Tue Jan 16, 2024 8:59 am How do i enlarge the texture with code so that it fits the collision box (4 by 4)Code: Select all
local large_drill = data.raw["mining-drill"]["bmd:large-mining-drill"] for d, direction in pairs({"north", "east", "south", "west"}) do if large_drill.animations and large_drill.animations[direction] then large_drill.animations[direction].scale = 2 end end
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
- BraveCaperCat
- Filter Inserter
- Posts: 430
- Joined: Mon Jan 15, 2024 10:10 pm
- Contact:
Re: Large Mining Drill Not Enlarged
And this should workPi-C wrote: Wed Jan 17, 2024 6:25 pmI think I know what's wrong: MiningDrillPrototype.animations is only used if MiningDrillPrototype.graphics_set is not defined, but it is set in your template (the vanilla electric-miner you've copied). So, check the description of graphics_set, look for everything that is an animation, and add/change the scale factor. (By the way, 2 is likely not the correct scale, you've got to find that yourself.)BraveCaperCat wrote: Wed Jan 17, 2024 5:50 pmThat still doesn't seem to work.Pi-C wrote: Tue Jan 16, 2024 7:26 pmTake a look at MiningDrillPrototype.animations. This is an array of 4 animations (one for each direction), and you can set the scale factor for each one of those. So something like this should work:BraveCaperCat wrote: Tue Jan 16, 2024 8:59 am How do i enlarge the texture with code so that it fits the collision box (4 by 4)Code: Select all
local large_drill = data.raw["mining-drill"]["bmd:large-mining-drill"] for d, direction in pairs({"north", "east", "south", "west"}) do if large_drill.animations and large_drill.animations[direction] then large_drill.animations[direction].scale = 2 end end
Code: Select all
for i, Member in pairs(MiningDrillEntity.graphics_set) do
if type(Member) == 'table'
if Member['north'] and Member['east'] and Member['south'] and Member['west'] then
for d, direction in pairs({'north', 'east', 'south', 'west'}) do
if Member[direction] then
Member[direction].scale = info[4]
end
end
end
end
end
Or maybe it won't work:
Creator of multiple mods, including Quality Assurance - My most popular one.
Go check them out with the first and second links!
I'll probably be wanting or giving help with modding most of the time I spend here on the forum.
Go check them out with the first and second links!
I'll probably be wanting or giving help with modding most of the time I spend here on the forum.
Re: Large Mining Drill Not Enlarged
Could you post data.lua?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
- BraveCaperCat
- Filter Inserter
- Posts: 430
- Joined: Mon Jan 15, 2024 10:10 pm
- Contact:
Re: Large Mining Drill Not Enlarged
Did i not just post it's contents a bit further up?
Creator of multiple mods, including Quality Assurance - My most popular one.
Go check them out with the first and second links!
I'll probably be wanting or giving help with modding most of the time I spend here on the forum.
Go check them out with the first and second links!
I'll probably be wanting or giving help with modding most of the time I spend here on the forum.
Re: Large Mining Drill Not Enlarged
You did, but I think the error message is from an edited version. As the code snippet ("And this should work") has more lines than the code it replaced, and may or may not have been inserted with additional empty lines, it would be useful to see the data.lua in its latest state, so that the line number from the error message really points to the line that throws the error.
I've put the code from your data.lua into a testing mod to reproduce the crash, but that failed somewhere else, on trying to get the values of your settings which I don't have access to. If you care for that, you could send me your mod in its current state per PM, that should make debugging it easier.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
- BraveCaperCat
- Filter Inserter
- Posts: 430
- Joined: Mon Jan 15, 2024 10:10 pm
- Contact:
Re: Large Mining Drill Not Enlarged
Here you go:Pi-C wrote: Thu Jan 25, 2024 6:16 pmCould you send me your mod in its current state, that should make debugging it easier.
Creator of multiple mods, including Quality Assurance - My most popular one.
Go check them out with the first and second links!
I'll probably be wanting or giving help with modding most of the time I spend here on the forum.
Go check them out with the first and second links!
I'll probably be wanting or giving help with modding most of the time I spend here on the forum.