I'm having trouble accessing custom noise layers at runtime with calculate_tile_properties. I've searched around and I see that from the original post (viewtopic.php?p=438975&sid=73a3aebfb456 ... 2b#p438975), you have to add it to property_expression_names. It doesn't specify whether this is at the prototype stage or the control stage, but I've tried both to no avail:
(data)
Code: Select all
data:extend(
{
{
type = "noise-layer",
name = "fertility"
},
{
type = "noise-expression",
name = "fertility",
intended_property = "fertility",
expression =
{
type = "function-application",
function_name = "factorio-basis-noise",
arguments =
{
x = noise.var("x"),
y = noise.var("y"),
seed0 = tne(noise.var("map_seed")),
seed1 = tne(123),
input_scale = tne(1/100),
output_scale = tne(1)
}
}
}
})
for _,mapgen in pairs(data.raw["map-gen-presets"]) do
log(serpent.block(mapgen))
for _,preset in pairs(mapgen) do
if preset.basic_settings then
if preset.basic_settings.property_expression_names then
preset.basic_settings.property_expression_names["fertility"] = "fertility"
else
preset.basic_settings.property_expression_names = {fertility = "fertility"}
end
end
end
end
Code: Select all
for _,surface in pairs(game.surfaces) do
surface.map_gen_settings.property_expression_names["fertility"]="fertility"
end
game.print("fertility:"..serpent.block(game.players[1].surface.calculate_tile_properties({"fertility"}, {game.players[1].position})))
I even tried creating a tile to generate with the noise layer so it would be "used," but no luck with that either
Code: Select all
local noise = require("noise")
local tilled_soil = util.table.deepcopy(data.raw.tile["landfill"])
tilled_soil.name = "tilled-soil"
tilled_soil.layer = 17
tilled_soil.autoplace =
{
peaks = { noise_layer = "fertility" }
--coverage = 0
}
data:extend({tilled_soil})
I've also tried copy pasting this code into my mod files: viewtopic.php?p=572500#p572500
But for me, the grass covers the ENTIRE area, rather than being patchy like shared in screenshots with their post.
Any ideas what I'm missing in setting up the noise layer / noise expression to be accessible at control-time?