I am making a Perlin noise script to spawn trees. And when I make a variable for resolution * frequency and divide x by it, it gives a different value than when do x / resolution * frequency.
Here is a screenshot of the trees with the variable:
And here it is without the variable (What it’s supposed to look like):
local function getHeight(x, y, resolution, frequency, amplitude)
local resXfreq = resolution * frequency -- this is the variable
-- this is the Output (picture below):
debugOutput:print(x / resolution * frequency .. " : " .. y / resolution * frequency) -- doing this works
debugOutput:print(x / resXfreq .. " :: " .. y / resXfreq) -- and this gives a diffent value
local noiseHeight = math.noise(
x / resolution * frequency, -- heres where it goes
y / resolution * frequency
)
--[[
Heres what it looks like with the variable
local noiseHeight = math.noise(
x / resXfreq, -- heres where it goes
y / resXfreq
)
]]--
noiseHeight = math.clamp(noiseHeight, -NOISEBUFFER, NOISEBUFFER) + NOISEBUFFER
return noiseHeight * amplitude
end
single colon is the x / resolution * frequency and a double is x / resXfreq


