Integrate wood logistics code into this mod

This commit is contained in:
Simon Brodtmann 2025-12-16 21:07:23 +01:00
parent 709c834ebd
commit e213ae9f2f
3 changed files with 463 additions and 95 deletions

View file

@ -48,6 +48,8 @@ AAILoaders.make_tier({
data.raw.recipe["aai-wood-loader"].additional_categories = { "wood-processing" } data.raw.recipe["aai-wood-loader"].additional_categories = { "wood-processing" }
data.raw["loader-1x1"]["aai-wood-loader"].animation_speed_coefficient = 1.01 * 32
if not basic_circuit_board then if not basic_circuit_board then
local nauvis_recipe = Recipe:new("aai-wood-loader"):clone("wood-loader-electronic-circuit") local nauvis_recipe = Recipe:new("aai-wood-loader"):clone("wood-loader-electronic-circuit")
nauvis_recipe:replaceIngredient("gold-cable", "electronic-circuit") nauvis_recipe:replaceIngredient("gold-cable", "electronic-circuit")

View file

@ -21,6 +21,7 @@ lane_splitter.prototype.structure_patch.east.filename = data.raw.splitter["wood-
lane_splitter.prototype.structure_patch.south.filename = data.raw.splitter["wood-splitter"].structure_patch.south.filename lane_splitter.prototype.structure_patch.south.filename = data.raw.splitter["wood-splitter"].structure_patch.south.filename
lane_splitter.prototype.structure_patch.west.filename = data.raw.splitter["wood-splitter"].structure_patch.west.filename lane_splitter.prototype.structure_patch.west.filename = data.raw.splitter["wood-splitter"].structure_patch.west.filename
lane_splitter.prototype.structure_patch.north.filename = data.raw.splitter["wood-splitter"].structure_patch.north.filename lane_splitter.prototype.structure_patch.north.filename = data.raw.splitter["wood-splitter"].structure_patch.north.filename
lane_splitter.prototype.animation_speed_coefficient = 1.01 * 32
lane_splitter.item.icon = Lignumis.graphics .. "icons/wood-lane-splitter.png" lane_splitter.item.icon = Lignumis.graphics .. "icons/wood-lane-splitter.png"
lane_splitter.item.order = "d[lane-splitter]-0[wood-lane-splitter]" lane_splitter.item.order = "d[lane-splitter]-0[wood-lane-splitter]"
lane_splitter.recipe.additional_categories = { "wood-processing" } lane_splitter.recipe.additional_categories = { "wood-processing" }

View file

@ -1,23 +1,105 @@
local BeltFactory = require(MF.logistics .. "Belts") local meld = require("meld")
local Belt = BeltFactory("wood", "brown", "slow") local hit_effects = require("__base__.prototypes.entity.hit-effects")
local sounds = require("__base__.prototypes.entity.sounds")
local basic_circuit_board = settings.startup["lignumis-basic-circuit-board"].value local item_sounds = require("__base__.prototypes.item_sounds")
local Recipe = require("__cf-lib__/data/Recipe")
if mods["wood-logistics"] and settings.startup["wood-logistics-belts"].value then if mods["wood-logistics"] and settings.startup["wood-logistics-belts"].value then
return return
end end
Belt.EntityBuilder:new() local basic_circuit_board = settings.startup["lignumis-basic-circuit-board"].value
:itemsPerSecond(7.5) local speed = 7.5 / 480
:nextTier("") local name = "wood"
:undergroundDistance(4) local transportBeltName = name .. "-transport-belt"
:animationSpeedMultiplier(1.01) local undergroundBeltName = name .. "-underground-belt"
:apply({ local splitterName = name .. "-splitter"
transportBelt = { local gfx = Lignumis.graphics .. "entity/wood-logistics/"
emissions_per_second = { noise = 2 / 60 }
local function createAnimation()
return meld({
animation_set = {
filename = gfx .. "wood-transport-belt.png",
priority = "extra-high",
size = 128,
scale = 0.5,
frame_count = 16,
direction_count = 20
}
}, belt_reader_gfx)
end
data:extend({
{
type = "transport-belt",
name = transportBeltName,
icon = Lignumis.graphics .. "icons/wood-transport-belt.png",
flags = { "placeable-neutral", "player-creation" },
minable = { mining_time = 0.1, result = transportBeltName },
max_health = 150,
next_upgrade = "transport-belt",
corpse = transportBeltName .. "-remnants",
dying_explosion = "transport-belt-explosion",
resistances = {
{
type = "fire",
percent = 90
}
}, },
undergroundBelt = { emissions_per_second = { noise = 2 / 60 },
emissions_per_second = { noise = 7.5 / 60 }, collision_box = { { -0.4, -0.4 }, { 0.4, 0.4 } },
selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
damaged_trigger_effect = hit_effects.entity(),
open_sound = sounds.transport_belt_open,
close_sound = sounds.transport_belt_close,
working_sound = {
sound = { filename = "__base__/sound/transport-belt.ogg", volume = 0.17 },
persistent = true
},
animation_speed_coefficient = 1.01 * 32,
fast_replaceable_group = "transport-belt",
related_underground_belt = undergroundBeltName,
speed = speed,
belt_animation_set = createAnimation(),
connector_frame_sprites = transport_belt_connector_frame_sprites,
circuit_connector = circuit_connector_definitions["belt"],
circuit_wire_max_distance = transport_belt_circuit_wire_max_distance
},
{
type = "corpse",
name = transportBeltName .. "-remnants",
icon = Lignumis.graphics .. "icons/wood-transport-belt.png",
hidden_in_factoriopedia = true,
flags = { "placeable-neutral", "not-on-map" },
subgroup = "belt-remnants",
order = "a-a-a",
selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
tile_width = 1,
tile_height = 1,
selectable_in_game = false,
time_before_removed = 60 * 60 * 15, -- 15 minutes
expires = false,
final_render_layer = "remnants",
animation = make_rotated_animation_variations_from_sheet(2, {
filename = gfx .. "wood-transport-belt-remnants.png",
line_length = 1,
width = 106,
height = 102,
direction_count = 4,
shift = util.by_pixel(1, -0.5),
scale = 0.5
})
},
{
type = "underground-belt",
name = undergroundBeltName,
icon = Lignumis.graphics .. "icons/wood-underground-belt.png",
flags = { "placeable-neutral", "player-creation" },
minable = { mining_time = 0.1, result = undergroundBeltName },
max_health = 150,
next_upgrade = "underground-belt",
corpse = undergroundBeltName .. "-remnants",
dying_explosion = "underground-belt-explosion",
factoriopedia_simulation = { factoriopedia_simulation = {
init = init =
[[ [[
@ -29,80 +111,363 @@ Belt.EntityBuilder:new()
position = {-0.5, 0} position = {-0.5, 0}
} }
]] ]]
},
max_distance = 4,
open_sound = sounds.machine_open,
close_sound = sounds.machine_close,
working_sound = table.deepcopy(data.raw["underground-belt"]["underground-belt"].working_sound),
underground_sprite = table.deepcopy(data.raw["underground-belt"]["underground-belt"].underground_sprite),
resistances = {
{
type = "fire",
percent = 60
},
{
type = "impact",
percent = 30
} }
}, },
splitter = { emissions_per_second = { noise = 7.5 / 60 },
emissions_per_second = { noise = 20 / 60 } collision_box = { { -0.4, -0.4 }, { 0.4, 0.4 } },
selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
damaged_trigger_effect = hit_effects.entity(),
animation_speed_coefficient = 1.01 * 32,
fast_replaceable_group = "transport-belt",
speed = speed,
structure = {
direction_in = {
sheet = {
filename = gfx .. "wood-underground-belt-structure.png",
priority = "extra-high",
width = 192,
height = 192,
y = 192,
scale = 0.5
} }
}) },
direction_out = {
local splitter_item = Belt.ItemBuilder:new() sheet = {
:itemsPerRocket("transportBelt", 200) filename = gfx .. "wood-underground-belt-structure.png",
:itemsPerRocket("undergroundBelt", 100) priority = "extra-high",
:itemsPerRocket("splitter", 100) width = 192,
:order("0") height = 192,
:apply() scale = 0.5
.splitter }
},
Belt.RecipeBuilder:new() direction_in_side_loading = {
:beltAmount(2) sheet = {
:ingredients("transportBelt", { filename = gfx .. "wood-underground-belt-structure.png",
priority = "extra-high",
width = 192,
height = 192,
y = 192 * 3,
scale = 0.5
}
},
direction_out_side_loading = {
sheet = {
filename = gfx .. "wood-underground-belt-structure.png",
priority = "extra-high",
width = 192,
height = 192,
y = 192 * 2,
scale = 0.5
}
},
back_patch = {
sheet = {
filename =
"__base__/graphics/entity/underground-belt/underground-belt-structure-back-patch.png",
priority = "extra-high",
width = 192,
height = 192,
scale = 0.5
}
},
front_patch = {
sheet = {
filename =
"__base__/graphics/entity/underground-belt/underground-belt-structure-front-patch.png",
priority = "extra-high",
width = 192,
height = 192,
scale = 0.5
}
}
},
belt_animation_set = createAnimation()
},
{
type = "corpse",
name = undergroundBeltName .. "-remnants",
icon = Lignumis.graphics .. "icons/wood-underground-belt.png",
hidden_in_factoriopedia = true,
flags = { "placeable-neutral", "not-on-map", "building-direction-8-way" },
subgroup = "belt-remnants",
order = "a-d-a",
selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } },
tile_width = 1,
tile_height = 1,
selectable_in_game = false,
time_before_removed = 60 * 60 * 15, -- 15 minutes
expires = false,
final_render_layer = "remnants",
remove_on_tile_placement = false,
animation = {
filename = gfx .. "wood-underground-belt-remnants.png",
line_length = 1,
width = 156,
height = 144,
direction_count = 8,
shift = util.by_pixel(10.5, 3),
scale = 0.5
}
},
{
type = "splitter",
name = splitterName,
icon = Lignumis.graphics .. "icons/wood-splitter.png",
flags = { "placeable-neutral", "player-creation" },
minable = { mining_time = 0.1, result = splitterName },
max_health = 170,
next_upgrade = "splitter",
corpse = splitterName .. "-remnants",
dying_explosion = "splitter-explosion",
resistances = {
{
type = "fire",
percent = 60
}
},
emissions_per_second = { noise = 20 / 60 },
collision_box = { { -0.9, -0.4 }, { 0.9, 0.4 } },
selection_box = { { -0.9, -0.5 }, { 0.9, 0.5 } },
damaged_trigger_effect = hit_effects.entity(),
animation_speed_coefficient = 1.01 * 32,
structure_animation_speed_coefficient = 0.7,
structure_animation_movement_cooldown = 10,
icon_draw_specification = { scale = 0.5 },
fast_replaceable_group = "transport-belt",
speed = speed,
open_sound = sounds.machine_open,
close_sound = sounds.machine_close,
working_sound = sounds.splitter,
related_transport_belt = transportBeltName,
structure = {
north = {
filename = gfx .. "wood-splitter-north.png",
frame_count = 32,
line_length = 8,
priority = "extra-high",
width = 160,
height = 70,
shift = util.by_pixel(7, 0),
scale = 0.5
},
east = {
filename = gfx .. "wood-splitter-east.png",
frame_count = 32,
line_length = 8,
priority = "extra-high",
width = 90,
height = 84,
shift = util.by_pixel(4, 13),
scale = 0.5
},
south = {
filename = gfx .. "wood-splitter-south.png",
frame_count = 32,
line_length = 8,
priority = "extra-high",
width = 164,
height = 64,
shift = util.by_pixel(4, 0),
scale = 0.5
},
west = {
filename = gfx .. "wood-splitter-west.png",
frame_count = 32,
line_length = 8,
priority = "extra-high",
width = 90,
height = 86,
shift = util.by_pixel(6, 12),
scale = 0.5
}
},
structure_patch = {
north = util.empty_sprite(),
east = {
filename = gfx .. "wood-splitter-east-top_patch.png",
frame_count = 32,
line_length = 8,
priority = "extra-high",
width = 90,
height = 104,
shift = util.by_pixel(4, -20),
scale = 0.5
},
south = util.empty_sprite(),
west = {
filename = gfx .. "wood-splitter-west-top_patch.png",
frame_count = 32,
line_length = 8,
priority = "extra-high",
width = 90,
height = 96,
shift = util.by_pixel(6, -18),
scale = 0.5
}
},
belt_animation_set = createAnimation()
},
{
type = "corpse",
name = splitterName .. "-remnants",
icon = Lignumis.graphics .. "icons/wood-splitter.png",
hidden_in_factoriopedia = true,
flags = { "placeable-neutral", "not-on-map" },
subgroup = "belt-remnants",
order = "a-g-a",
selection_box = { { -0.9, -0.5 }, { 0.9, 0.5 } },
tile_width = 2,
tile_height = 1,
selectable_in_game = false,
time_before_removed = 60 * 60 * 15, -- 15 minutes
expires = false,
final_render_layer = "remnants",
remove_on_tile_placement = false,
animation = {
filename = gfx .. "wood-splitter-remnants.png",
line_length = 1,
width = 190,
height = 190,
direction_count = 4,
shift = util.by_pixel(3.5, 1.5),
scale = 0.5
}
},
{
type = "item",
name = transportBeltName,
icon = Lignumis.graphics .. "icons/wood-transport-belt.png",
subgroup = "belt",
color_hint = { text = "1" },
order = "a[transport-belt]-0[" .. transportBeltName .. "]",
inventory_move_sound = item_sounds.transport_belt_inventory_move,
pick_sound = item_sounds.transport_belt_inventory_pickup,
drop_sound = item_sounds.transport_belt_inventory_move,
place_result = transportBeltName,
stack_size = 100,
weight = 5 * kg
},
{
type = "item",
name = undergroundBeltName,
icon = Lignumis.graphics .. "icons/wood-underground-belt.png",
subgroup = "belt",
color_hint = { text = "1" },
order = "b[underground-belt]-0[" .. undergroundBeltName .. "]",
inventory_move_sound = item_sounds.mechanical_inventory_move,
pick_sound = item_sounds.mechanical_inventory_pickup,
drop_sound = item_sounds.mechanical_inventory_move,
place_result = undergroundBeltName,
stack_size = 50,
weight = 10 * kg
},
{
type = "item",
name = splitterName,
icon = Lignumis.graphics .. "icons/wood-splitter.png",
subgroup = "belt",
color_hint = { text = "1" },
order = "c[splitter]-0[" .. splitterName .. "]",
inventory_move_sound = item_sounds.mechanical_inventory_move,
pick_sound = item_sounds.mechanical_inventory_pickup,
drop_sound = item_sounds.mechanical_inventory_move,
place_result = splitterName,
stack_size = 50,
weight = 10 * kg
},
{
type = "recipe",
name = transportBeltName,
enabled = false,
energy_required = 0.5,
results = { { type = "item", name = transportBeltName, amount = 2 } },
ingredients = {
{ type = "item", name = "lumber", amount = 1 }, { type = "item", name = "lumber", amount = 1 },
{ type = "item", name = "wooden-gear-wheel", amount = 1 } { type = "item", name = "wooden-gear-wheel", amount = 1 }
}) }
:ingredients("undergroundBelt", { },
{
type = "recipe",
name = undergroundBeltName,
category = "crafting",
additional_categories = { "wood-processing" },
enabled = false,
energy_required = 1,
ingredients = {
{ type = "item", name = "lumber", amount = 1 }, { type = "item", name = "lumber", amount = 1 },
{ type = "item", name = "wood-transport-belt", amount = 4 }, { type = "item", name = "wood-transport-belt", amount = 4 },
}) },
:ingredients("splitter", { results = { { type = "item", name = undergroundBeltName, amount = 2 } }
},
{
type = "recipe",
name = splitterName,
category = "crafting",
additional_categories = { "wood-processing" },
enabled = false,
energy_required = 1,
ingredients = {
{ type = "item", name = "wood-transport-belt", amount = 2 }, { type = "item", name = "wood-transport-belt", amount = 2 },
{ type = "item", name = "lumber", amount = 2 }, { type = "item", name = "lumber", amount = 2 },
basic_circuit_board and { type = "item", name = "basic-circuit-board", amount = 5 } or basic_circuit_board and { type = "item", name = "basic-circuit-board", amount = 5 } or
{ type = "item", name = "gold-cable", amount = 10 } { type = "item", name = "gold-cable", amount = 10 }
})
:apply({
transportBelt = {
additional_categories = { "wood-processing" }
}, },
undergroundBelt = { results = { { type = "item", name = splitterName, amount = 1 } }
additional_categories = { "wood-processing" }
}, },
splitter = { {
additional_categories = { "wood-processing" } type = "technology",
name = name .. "-logistics",
category = "crafting",
additional_categories = { "wood-processing" },
icon = Lignumis.graphics .. "technology/wood-logistics.png",
icon_size = 256,
effects = {
{
type = "unlock-recipe",
recipe = "wood-transport-belt"
},
{
type = "unlock-recipe",
recipe = "wood-underground-belt"
},
{
type = "unlock-recipe",
recipe = "wood-splitter"
}
},
prerequisites = { "wood-science-pack" },
unit = {
count = 10,
ingredients = { { "wood-science-pack", 1 } },
time = 10
}
} }
}) })
Belt.TechnologyBuilder:new()
:prerequisites({ "wood-science-pack" })
:ingredients({ { "wood-science-pack", 1 } })
:count(10)
:time(10)
:apply()
if not basic_circuit_board then if not basic_circuit_board then
data:extend({ Recipe:new("wood-splitter"):clone("wood-splitter-electronic-circuit")
Belt.RecipeBuilder:new() :replaceIngredient("gold-cable", "electronic-circuit", 2)
:ingredients("splitter", { :assign({
{ type = "item", name = "wood-transport-belt", amount = 2 },
{ type = "item", name = "lumber", amount = 2 },
{ type = "item", name = "electronic-circuit", amount = 2 }
})
:build({
splitter = {
name = "wood-splitter-electronic-circuit",
localised_name = { "entity-name.wood-splitter" }, localised_name = { "entity-name.wood-splitter" },
icons = { icons = {
{ icon = splitter_item.icon }, { icon = gfx .. "wood-splitter-icon.png" },
{ icon = "__base__/graphics/icons/electronic-circuit.png", scale = 0.25, shift = { 8, 8 } } { icon = "__base__/graphics/icons/electronic-circuit.png", scale = 0.25, shift = { 8, 8 } }
},
additional_categories = { "wood-processing" }
} }
}) })
.splitter :unlockedByTechnology("electronics")
}) :apply()
table.insert(data.raw.technology["electronics"].effects, {
type = "unlock-recipe",
recipe = "wood-splitter-electronic-circuit"
})
end end