[Documentation Error] voronoi_spot_noise actually returns positive normalized distance

Quorken
Burner Inserter
Burner Inserter
Posts: 17
Joined: Mon Aug 18, 2025 3:53 pm
Contact:

[Documentation Error] voronoi_spot_noise actually returns positive normalized distance

Post by Quorken »

As the title says - the current documentation for the voronoi_spot_noise noise function just says it returns the distance, which I thought meant tile distance. Rather, it seems to return the distance relative to the cell's max size in that direction (or the grid size) - some kind of normalized distance.

Additionally, it seems to return positive distances, not negative ones as specified - at least, for euclidean distance.

Documentation https://lua-api.factorio.com/latest/aux ... spot_noise:
voronoi_spot_noise
The distance from the current location to the closest point (0 at each point and descending to negative values in a cone around each point).
For example, this (data.lua):
data.raw["noise-expression"]["elevation"].expression = "voronoi_spot_noise{x=x, y=y, seed0=1241, seed1=12412, grid_size=200, jitter=0, distance_type='manhattan'}-0.5"
* Note the -0.5

for this command-line preview:
"$(FACTORIO_EXECUTABLE)" $(MOD_ARG) $(MOD_LOCATION) --generate-map-preview $(PREVIEW_LOCATION)/preview-4198238.png --map-preview-size 400 --map-gen-seed 4198238

yields this:
preview-4198238.png
preview-4198238.png (27.14 KiB) Viewed 294 times
And if it returned tile distance (as seems implied), there would just be a speck of ocean in the center.
If it actually returned negative distance, that would all be ocean, not land and ocean.

The documentation should reflect this, so people don't spend several hours debugging their noise expressions only to find out the voronoi_spot_noise doesn't return tile distance.

On a related note, it would be nice to have voronoi functions that return the actual tile distance from the cell center/edge/etc., especially if the normalized distance is based on the cell's actual dimensions (not the initial grid_size), as we do not have access to that in the noise expression tested, it seems it's based on the grid size?
Bilka
Factorio Staff
Factorio Staff
Posts: 3597
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: [Documentation Error] voronoi_spot_noise actually returns positive normalized distance

Post by Bilka »

It's indeed based on grid size, you can get the tile distance with tile_distance = grid_size * distance. Docs improved for 2.0.67, thanks for the note.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Post Reply

Return to “Resolved Requests”