paramat wrote:Using 2D perlin noise, for an example of how to make a temperature/humidity biome system see https://github.com/paramat/paragenv7/blob/master/init.lua
paramat wrote:I thought that too, but was told by hmmmm that it's faster to state them as locals inside the function, apparently getting id is a very fast operation.
Don wrote:Wondering if one of you could give a brief explanation of get_content_id and what you mean by inside and outside.
I am trying to learn but get stuck on things.
...
minetest.register_on_generated(function(minp, maxp, seed)
...
local c_air = minetest.get_content_id("air")
...
-- Using c_air somewhere ...
...
local c_air = minetest.get_content_id("air")
minetest.register_on_generated(function(minp, maxp, seed)
...
-- Using c_air somewhere ...
Sane wrote:But how can that be? The callback literally runs thousands of times.
So either calling minetest.get_content_id outside the callback takes very very long
or reading the mod local values takes considerably longer than what i've guessed.
Ferk wrote:Sane wrote:But how can that be? The callback literally runs thousands of times.
So either calling minetest.get_content_id outside the callback takes very very long
or reading the mod local values takes considerably longer than what i've guessed.
Doesn't each chunk get generated only once in the entire life of the world?
I guess after a big area of the map has already been generated it might be less likely for new chunks to require generation (normally players would just settle down nearby the spawn), so if get_content_id is very cheap you'd rather want to avoid having variables in the "global" scope of the module wasting memory. No player is gonna explore the 775x775x775 chunks of the entire world.
But I'm just guessing. I doubt the difference is very significant anyway.
-- 2D noise for temperature
local np_temp = {
offset = 0,
scale = 1,
spread = {x = 2048, y = 2048, z = 2048},
seed = 9130,
octaves = 3,
persist = 0.33
}
Ferk wrote:Maybe it would be best to contribute to rubenwardy's modding book.
Perhaps the official wiki should be replaced with something more like this.
Ferk wrote:It would be nice if we could reference to sections of the autogenerated html by using hashtag references ...
afflatus wrote:Ferk wrote:It would be nice if we could reference to sections of the autogenerated html by using hashtag references ...
Wouldn't it just?
Users browsing this forum: No registered users and 12 guests