Integrate lumber mill code into this mod

This commit is contained in:
Simon Brodtmann 2025-12-16 00:03:33 +01:00
parent bb624c1159
commit 11d5f65680
2 changed files with 238 additions and 80 deletions

View file

@ -4,7 +4,6 @@ local sounds = require("__base__.prototypes.entity.sounds")
local Entity = require("__cf-lib__/data/Entity")
local gfx = Lignumis.graphics .. "entity/deep-miner/"
local techGfx = Lignumis.graphics .. "technology/"
local name = "deep-miner"
local function animationLayer()
@ -18,12 +17,12 @@ local function animationLayer()
scale = 0.5,
stripes = {
{
filename = gfx .. "core-extractor-animation-1.png",
filename = gfx .. "deep-miner-animation-1.png",
width_in_frames = 8,
height_in_frames = 8
},
{
filename = gfx .. "core-extractor-animation-2.png",
filename = gfx .. "deep-miner-animation-2.png",
width_in_frames = 8,
height_in_frames = 7
}
@ -35,7 +34,7 @@ data:extend({
{
type = "mining-drill",
name = name,
icon = gfx .. "core-extractor-icon.png",
icon = Lignumis.graphics .. "icons/deep-miner.png",
flags = { "placeable-neutral", "player-creation" },
minable = { mining_time = 0.2, result = name },
fast_replaceable_group = name,
@ -69,7 +68,7 @@ data:extend({
animation = {
layers = {
{
filename = gfx .. "core-extractor-shadow.png",
filename = gfx .. "deep-miner-shadow.png",
priority = "high",
width = 1400,
height = 1400,
@ -101,12 +100,12 @@ data:extend({
scale = 0.5,
stripes = {
{
filename = gfx .. "core-extractor-emission-1.png",
filename = gfx .. "deep-miner-emission-1.png",
width_in_frames = 8,
height_in_frames = 8
},
{
filename = gfx .. "core-extractor-emission-2.png",
filename = gfx .. "deep-miner-emission-2.png",
width_in_frames = 8,
height_in_frames = 7
}
@ -149,7 +148,7 @@ data:extend({
{
type = "item",
name = name,
icon = gfx .. "core-extractor-icon.png",
icon = Lignumis.graphics .. "icons/deep-miner.png",
subgroup = "extraction-machine",
order = "a[items]-d[deep-miner]",
inventory_move_sound = item_sounds.mechanical_large_inventory_move,
@ -177,7 +176,7 @@ data:extend({
{
type = "technology",
name = name,
icon = techGfx .. "core-extractor.png",
icon = Lignumis.graphics .. "technology/deep-miner.png",
icon_size = 256,
effects = {
{ type = "unlock-recipe", recipe = name }

View file

@ -1,7 +1,10 @@
local Recipe = require("__cf-lib__/data/Recipe")
local Technology = require("__cf-lib__/data/Technology")
local LumberMillFactory = require(MF.buildings .. "LumberMill")
local LumberMill = LumberMillFactory()
local hit_effects = require("__base__.prototypes.entity.hit-effects")
local item_sounds = require("__base__.prototypes.item_sounds")
local Entity = require("__cf-lib__/data/Entity")
local gfx = Lignumis.graphics .. "entity/lumber-mill/"
local name = "lumber-mill"
data:extend({
{
@ -18,84 +21,240 @@ if mods["wood-logistics"] then
return
end
local lumberMill = LumberMill.EntityBuilder:new()
:baseProductivity(0.5)
if electric_lumber_mill then
lumberMill:electricEnergySource({ emissions_per_minute = { noise = 100 } })
else
lumberMill:burnerEnergySource({ emissions_per_minute = { noise = 100 } })
end
lumberMill:apply({
crafting_categories = { "wood-processing" },
crafting_speed = 2,
energy_usage = "1000kW",
surface_conditions = {
{
property = has_oxygen and "oxygen" or "pressure",
min = 3
local energy_source = electric_lumber_mill and {
type = "electric",
usage_priority = "secondary-input",
emissions_per_minute = { noise = 100 }
} or {
type = "burner",
fuel_categories = { "chemical" },
effectivity = 1,
fuel_inventory_size = 3,
emissions_per_minute = { pollution = 10, noise = 100 }
}
data:extend({
{
type = "assembling-machine",
name = name,
icon = Lignumis.graphics .. "icons/lumber-mill.png",
flags = { "placeable-neutral", "player-creation" },
minable = { mining_time = 0.2, result = name },
fast_replaceable_group = name,
max_health = 500,
corpse = "big-remnants",
dying_explosion = "medium-explosion",
collision_box = Entity.collisionBox(8, 8),
selection_box = Entity.selectionBox(8, 8),
damaged_trigger_effect = hit_effects.entity(),
drawing_box_vertical_extension = 1.3,
module_slots = 4,
icon_draw_specification = { scale = 2, shift = { 0, -0.3 } },
icons_positioning = {
{ inventory_index = defines.inventory.assembling_machine_modules, shift = { 0, 1.25 } }
},
{
property = "gravity",
min = 1
allowed_effects = { "consumption", "speed", "pollution", "quality" },
crafting_categories = { "wood-processing" },
crafting_speed = 2,
energy_source = energy_source,
energy_usage = "1MW",
effect_receiver = { base_effect = { productivity = 0.5 } },
surface_conditions = {
{
property = has_oxygen and "oxygen" or "pressure",
min = 3
},
{
property = "gravity",
min = 1
}
},
perceived_performance = { minimum = 0.25, performance_to_activity_rate = 0.25, maximum = 4 },
graphics_set = {
animation = {
layers = {
{
filename = gfx .. "lumber-mill-shadow.png",
priority = "high",
width = 800,
height = 700,
frame_count = 1,
line_length = 1,
repeat_count = 80,
animation_speed = 0.32,
shift = util.by_pixel(0, -8),
draw_as_shadow = true,
scale = 0.5
},
{
priority = "high",
width = 525,
height = 557,
frame_count = 80,
lines_per_file = 8,
animation_speed = 0.32,
shift = util.by_pixel(0, -8),
scale = 0.5,
stripes = {
{
filename = gfx .. "lumber-mill-animation-1.png",
width_in_frames = 8,
height_in_frames = 8
},
{
filename = gfx .. "lumber-mill-animation-2.png",
width_in_frames = 8,
height_in_frames = 2
}
}
},
}
},
working_visualisations = {
{
fadeout = true,
animation = {
layers = {
{
priority = "high",
width = 525,
height = 557,
frame_count = 80,
lines_per_file = 8,
animation_speed = 0.32,
shift = util.by_pixel(0, -8),
scale = 0.5,
stripes = {
{
filename = gfx .. "lumber-mill-animation-1.png",
width_in_frames = 8,
height_in_frames = 8
},
{
filename = gfx .. "lumber-mill-animation-2.png",
width_in_frames = 8,
height_in_frames = 2
}
}
},
{
priority = "high",
draw_as_glow = true,
blend_mode = "additive",
width = 525,
height = 557,
frame_count = 80,
lines_per_file = 8,
animation_speed = 0.32,
shift = util.by_pixel(0, -8),
scale = 0.5,
stripes = {
{
filename = gfx .. "lumber-mill-emission-1.png",
width_in_frames = 8,
height_in_frames = 8
},
{
filename = gfx .. "lumber-mill-emission-2.png",
width_in_frames = 8,
height_in_frames = 2
}
}
}
}
}
}
}
},
open_sound = { filename = "__base__/sound/open-close/train-stop-open.ogg", volume = 0.6 },
close_sound = { filename = "__base__/sound/open-close/train-stop-close.ogg", volume = 0.5 },
working_sound = {
fade_in_ticks = 4,
fade_out_ticks = 20,
audible_distance_modifier = 0.6,
max_sounds_per_type = 2,
sound = { filename = "__space-age__/sound/entity/foundry/foundry.ogg", volume = 0.6 },
sound_accents = {
{ sound = { filename = Lignumis.sound .. "entity/lumber-mill/lumber-mill-saw-1.ogg", volume = 0.8 }, frame = 26, audible_distance_modifier = 0.5 },
{ sound = { filename = Lignumis.sound .. "entity/lumber-mill/lumber-mill-fall.ogg", volume = 1.2 }, frame = 42, audible_distance_modifier = 0.5 },
{ sound = { filename = Lignumis.sound .. "entity/lumber-mill/lumber-mill-saw-2.ogg", volume = 0.8 }, frame = 53, audible_distance_modifier = 0.4 },
{ sound = { filename = Lignumis.sound .. "entity/lumber-mill/lumber-mill-split.ogg", volume = 0.4 }, frame = 62, audible_distance_modifier = 0.3 },
{ sound = { variations = sound_variations(Lignumis.sound .. "entity/lumber-mill/lumber-mill-plank", 3, 0.5) }, frame = 14, audible_distance_modifier = 0.3 },
{ sound = { variations = sound_variations(Lignumis.sound .. "entity/lumber-mill/lumber-mill-plank", 3, 0.5) }, frame = 34, audible_distance_modifier = 0.3 },
{ sound = { variations = sound_variations(Lignumis.sound .. "entity/lumber-mill/lumber-mill-plank", 3, 0.5) }, frame = 54, audible_distance_modifier = 0.3 },
{ sound = { variations = sound_variations(Lignumis.sound .. "entity/lumber-mill/lumber-mill-plank", 3, 0.5) }, frame = 74, audible_distance_modifier = 0.3 },
}
}
},
{
type = "item",
name = name,
icon = Lignumis.graphics .. "icons/lumber-mill.png",
subgroup = "production-machine",
order = "eb[lumber-mill]",
inventory_move_sound = item_sounds.mechanical_large_inventory_move,
pick_sound = item_sounds.mechanical_large_inventory_pickup,
drop_sound = item_sounds.mechanical_large_inventory_move,
place_result = name,
stack_size = 20,
default_import_location = "lignumis",
weight = 200 * kg
},
{
type = "recipe",
name = name,
category = "crafting",
additional_categories = { "wood-processing" },
enabled = false,
ingredients = table.trim({
{ type = "item", name = "stone-brick", amount = 40 },
{ type = "item", name = "lumber", amount = 50 },
{ type = "item", name = "wooden-gear-wheel", amount = 50 },
{ type = "item", name = "gold-plate", amount = basic_circuit_board and 20 or 40 },
basic_circuit_board and { type = "item", name = "basic-circuit-board", amount = 20 } or nil,
{ type = "item", name = "burner-assembling-machine", amount = 2 }
}),
energy_required = 60,
results = { { type = "item", name = name, amount = 1 } }
},
{
type = "technology",
name = name,
icon = Lignumis.graphics .. "technology/lumber-mill.png",
icon_size = 256,
prerequisites = electric_lumber_mill and { "automation-science-pack" } or { "steam-science-pack" },
unit = {
count = 250,
ingredients = electric_lumber_mill and {{ "automation-science-pack", 1 }} or {{ "wood-science-pack", 1 }, { "steam-science-pack", 1 }},
time = 15
}
}
})
local lumber_mill_item = LumberMill.ItemBuilder:new()
:apply({
default_import_location = "lignumis",
order = "2[lumber-mill]"
})
LumberMill.RecipeBuilder:new()
:ingredients(table.trim({
{ type = "item", name = "stone-brick", amount = 40 },
{ type = "item", name = "lumber", amount = 50 },
{ type = "item", name = "wooden-gear-wheel", amount = 50 },
{ type = "item", name = "gold-plate", amount = basic_circuit_board and 20 or 40 },
basic_circuit_board and { type = "item", name = "basic-circuit-board", amount = 20 } or nil,
{ type = "item", name = "burner-assembling-machine", amount = 2 }
}))
:apply({
additional_categories = { "wood-processing" }
})
local tech = LumberMill.TechnologyBuilder:new()
:count(250)
:time(15)
if electric_lumber_mill then
tech:prerequisites({ "automation-science-pack" })
:ingredients({ { "automation-science-pack", 1 } })
else
tech:prerequisites({ "steam-science-pack" })
:ingredients({ { "wood-science-pack", 1 }, { "steam-science-pack", 1 } })
end
tech:apply()
LumberMill.RecipeBuilder:new()
:ingredients({
{ type = "item", name = "stone-brick", amount = 40 },
{ type = "item", name = "lumber", amount = 50 },
{ type = "item", name = "wooden-gear-wheel", amount = 50 },
{ type = "item", name = "copper-plate", amount = basic_circuit_board and 20 or 40 },
{ type = "item", name = basic_circuit_board and "basic-circuit-board" or "electronic-circuit", amount = 20 },
{ type = "item", name = "assembling-machine-1", amount = 2 }
})
:apply({
name = "lumber-mill-copper",
Recipe:new("lumber-mill")
:unlockedByTechnology("lumber-mill")
:clone("lumber-mill-copper")
:assign({
ingredients = {
{ type = "item", name = "stone-brick", amount = 40 },
{ type = "item", name = "lumber", amount = 50 },
{ type = "item", name = "wooden-gear-wheel", amount = 50 },
{ type = "item", name = "copper-plate", amount = basic_circuit_board and 20 or 40 },
{ type = "item", name = basic_circuit_board and "basic-circuit-board" or "electronic-circuit", amount = 20 },
{ type = "item", name = "assembling-machine-1", amount = 2 }
},
localised_name = { "entity-name.lumber-mill" },
additional_categories = { "wood-processing" },
icons = {
{ icon = lumber_mill_item.icon },
{ icon = Lignumis.graphics .. "icons/lumber-mill.png" },
{ icon = basic_circuit_board and "__base__/graphics/icons/copper-plate.png" or "__base__/graphics/icons/electronic-circuit.png", scale = 0.25, shift = { 8, 8 } }
}
})
Technology:new(
electric_lumber_mill and "lumber-mill"
or basic_circuit_board and "copper-processing"
or "electronics"
):addRecipe("lumber-mill-copper")
:unlockedByTechnology(
electric_lumber_mill and "lumber-mill"
or basic_circuit_board and "copper-processing"
or "electronics"
)
:apply()
Recipe:new("wooden-chest"):addCategory("wood-processing")
Recipe:new("small-electric-pole"):addCategory("wood-processing")