Help with autoplacing resources / updating an old mod
Posted: Mon Jul 28, 2025 12:03 pm
To create my first mod, I've chosen to update/migrate an existing (older) mod from 1.1 to 2.0: https://mods.factorio.com/mod/geothermalpower-yalda
I've managed to update the code to "run", but the resources (geothermal vents) do not place during a new game map gen, and does not show in preview.
I think the issue is that I need a probability_expression and richness_expression. I've tried to reuse the settings from base for Crude Oil to try to get generation working.
1. Am I correct that I need the two expressions?
2. Have I setup the rest correctly?
3. Where do I define the two expressions?
4. Is there an example expression that comes close to either the original mod's resource deployment OR close to oil patch placement?
Prototypes/autoplace-controls.lua:
prototypes/noise-layers.lua:
prototypes/resources.lua:
I've managed to update the code to "run", but the resources (geothermal vents) do not place during a new game map gen, and does not show in preview.
I think the issue is that I need a probability_expression and richness_expression. I've tried to reuse the settings from base for Crude Oil to try to get generation working.
1. Am I correct that I need the two expressions?
2. Have I setup the rest correctly?
3. Where do I define the two expressions?
4. Is there an example expression that comes close to either the original mod's resource deployment OR close to oil patch placement?
Prototypes/autoplace-controls.lua:
Code: Select all
data:extend({
{
name = "geothermal-vent",
order = "b-f",
richness = true,
type = "autoplace-control",
category = "resource",
base_density = 8.2,
base_spots_per_km2 = 1.8,
random_probability = 1/48,
random_spot_size_minimum = 1,
random_spot_size_maximum = 1, -- don't randomize spot size
additional_richness = 220000, -- this increases the total everywhere, so base_density needs to be decreased to compensate
has_starting_area_placement = true,
regular_rq_factor_multiplier = 1,
},
}
)
Code: Select all
data:extend({
{ --geothermal vents
type = "noise-layer",
name = "geothermal-vent",
},
}
)
Code: Select all
local resource_autoplace = require("resource-autoplace")
data:extend({
{
type = "resource",
name = "geothermal-vent",
icon = "__geothermal-refreshed__/graphics/resource/geothermal-vent/geothermal-vent-icon.png",
icon_size = 64, icon_mipmaps = 4,
flags = {"placeable-neutral"},
category = "geothermal-vent",
subgroup = "raw-resource",
order = "b-f",
has_starting_area_placement = true,
infinite = true,
highlight = true,
minimum = 160000,
normal = 500000,
infinite_depletion_amount = 10,
resource_patch_search_radius = 12,
tree_removal_probability = 0.8,
tree_removal_max_distance = 32 * 32,
minable = {
mining_time = 1,
results = {
{type = "fluid", name = "steam", amount_min = 20, amount_max = 30, probability = 2, temperature = 200}, },
},
collision_box = {{-1.4, -1.4}, {1.4, 1.4}},
selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
autoplace = resource_autoplace.resource_autoplace_settings(
{
type = "autoplace-control",
name = "geothermal-vent",
order = "b-f",
category = "resource",
base_density = 8.2,
base_spots_per_km2 = 1.8,
random_probability = 1/48,
random_spot_size_minimum = 1,
random_spot_size_maximum = 1, -- don't randomize spot size
richness = true,
additional_richness = 220000, -- this increases the total everywhere, so base_density needs to be decreased to compensate
has_starting_area_placement = true,
regular_rq_factor_multiplier = 1,
-- probability_expression = "geothermal_vent_probability",
-- richness_expression = "geothermal_vent_richness"
}),
stage_counts = {6330, 1930, 270, 50},
stages = {
sheet = {
filename = "__geothermal-refreshed__/graphics/resource/geothermal-vent/geothermal-vent.png",
priority = "extra-high",
width = 74,
height = 60,
frame_count = 4,
variation_count = 4,
shift = util.by_pixel(0, -2),
},
},
stages_effect = {
sheet = {
filename = "__geothermal-refreshed__/graphics/entity/vent-steam/vent-steam.png",
priority = "extra-high",
width = 152,
height = 120,
frame_count = 4,
variation_count = 4,
blend_mode = "additive",
flags = {"smoke"},
},
},
effect_animation_period = 5,
effect_animation_period_deviation = 1,
effect_darkness_multiplier = 1,
min_effect_alpha = 0.4,
max_effect_alpha = 0.7,
-- map_color = {r = 210, g = 219, b = 220},
map_color = {r = 255, g = 251, b = 0},
map_grid = false
},
}
)