Access noise in game
Posted: Tue Aug 23, 2022 4:04 pm
Hi. I´m making a mod and need to customize the map generation (for something like a world map in an rpg).
I read up some on NoiseExpression, and on perlin noise functions.
https://wiki.factorio.com/Types/NoiseExpression
My instinctive plan was to define some noise layers, for example "myElevation", "moist" and "forest".
Then factorio would do the heavy perlin noise calculations, saving me computing power and actually having to write the complicated perlin noise functions.
Then in "on_chunk_generated" in control.lua I could read the values for my custom noise layers for each tile, and decide what tile to to place from that.
But i cannot find how to get the value of noise layers for a tile in control.lua. Is it possible?
My thought was to do something like
moist > 0.8 = grass-3
0.8 > moist > 0.6 = grass-2
0.6 > moist > 0.4 = grass-1
0.4 > moist > 0.2 = sand-3
0.2 > moist > 0.0 = sand-2
....
Overriding this would be patches of dirt full of trees, representing forest
And overriding this would be red-dirt with rocks, representing mountains
Is something like this possible by defining custom functions for existing noise layers?
I don't fully understand how the noise layer works in vanilla. Instead of the way I wrote above it seem to use a separate function for each tile type. So which tile is then placed? The one whose function returns the greatest value?
I also don't understand why you would create a new noise layer, when only the predefined ones actually affect what tiles are placed?
Any noise gurus here?
I read up some on NoiseExpression, and on perlin noise functions.
https://wiki.factorio.com/Types/NoiseExpression
My instinctive plan was to define some noise layers, for example "myElevation", "moist" and "forest".
Then factorio would do the heavy perlin noise calculations, saving me computing power and actually having to write the complicated perlin noise functions.
Then in "on_chunk_generated" in control.lua I could read the values for my custom noise layers for each tile, and decide what tile to to place from that.
But i cannot find how to get the value of noise layers for a tile in control.lua. Is it possible?
My thought was to do something like
moist > 0.8 = grass-3
0.8 > moist > 0.6 = grass-2
0.6 > moist > 0.4 = grass-1
0.4 > moist > 0.2 = sand-3
0.2 > moist > 0.0 = sand-2
....
Overriding this would be patches of dirt full of trees, representing forest
And overriding this would be red-dirt with rocks, representing mountains
Is something like this possible by defining custom functions for existing noise layers?
I don't fully understand how the noise layer works in vanilla. Instead of the way I wrote above it seem to use a separate function for each tile type. So which tile is then placed? The one whose function returns the greatest value?
I also don't understand why you would create a new noise layer, when only the predefined ones actually affect what tiles are placed?
Any noise gurus here?