Page 1 of 1

How does autoplace work?

Posted: Sun Jul 27, 2025 9:26 pm
by rooster407
I having trouble understanding how to use autoplace, particularly the probability_expression variable. I've been stealing noise expressions from base since that goes way over my head.

I'm trying to use autoplace to add an entity scattered around the map, this is the code I have,

Code: Select all

local staplerootplant ={
	type = "simple-entity",
	name = "staple_root",
	icon ="__colonization__/graphics/stapleroot.png",
	icon_size = 66,
	max_health = 10,
	minable = { mining_time = 2, result = "staple_root"},
	graphics_set = {animation={north={
		filename="__colonization__/graphics/stapleroot.png",
		frame_count=1,
		width=72,
		height=66,
		scale = 1
	}}},
	collision_box = {{-0.4, -0.4}, {0.4, 0.4}},
	selection_box ={{-0.4, -0.4}, {0.4, 0.4}},
	
	autoplace = {
   		probability_expression = "min(0.2, trees_forest_path_cutout_faded,\z
                      min(0,\z
                      asymmetric_ramps{input=temperature, from_bottom=15, from_top=16, to_top=35, to_bottom=45},\z
                      asymmetric_ramps{input=moisture, from_bottom=0.1, from_top=0.2, to_top=0.3, to_bottom=0.4})\z
                      + min(0, distance/20 - 3)\z
                      - 0.5 + 0.2 * control:trees:size\z
                      + tree_small_noise * 0.1\z
                      + multioctave_noise{x = x,\z
                                          y = y,\z
                                          persistence = 0.65,\z
                                          seed0 = map_seed,\z
                                          seed1 = 'tree-09-brown',\z
                                          octaves = 3,\z
                                          input_scale = 1/25 * control:trees:frequency,\z
                                          output_scale = 0.6})"
  }
	}	
}
data:extend{staplerootplant}
It doesn't give any errors but nothing is generated ether.

If anyone knows an simple way to do this It'd be a great help.