The minetest.get_perlin() function returns nil in 0.4.8 (haven't tried other versions). The minetest.get_perlin_map() function, which is barely mentioned in lua_api.txt and not documented anywhere on the wiki, also returns nil in this version.
The PerlinNoise() constructor does return a valid object, on the other hand, as does the PerlinNoiseMap() constructor (which is not documented in the wiki).
There seem to be no notes in lua_api.txt or the wiki about any of these functions being deprecated or replaced, and without digging through Git history logs or source code it is impossible to tell the intent and thus whether it is the implementation or the documentation that needs to be fixed.
Running Ubuntu 13.10 with the minetestc55 0.4.8-0ppa1~ubuntu13.10.1 package installed through the stable apt repo, though I suspect there is nothing platform specific about this behavior.
minetest.get_perlin() and minetest.get_perlin_map() Return nil
-
- Member
- Posts: 647
- Joined: Thu Feb 21, 2013 23:54
-
- Member
- Posts: 647
- Joined: Thu Feb 21, 2013 23:54
Here is Lua code that can show the symptoms:
The expected output is:
but the observed output is:
Code: Select all
local NOISE_PARAMS =
{
offset = 0,
scale = 1,
spread = { x = 100, y = 100, z = 100 },
seed = 23,
octaves = 3,
persist = 0.70
};
local SIZE = { x = 100, y = 100, z = 100 };
local function logResult(context, obj)
local msg = (obj and "good") or "nil";
minetest.log("error", context.." returned "..msg.." object");
end
logResult("get_perlin", minetest.get_perlin(1, 2, 0.5, 100));
logResult("get_perlin_map", minetest.get_perlin_map(NOISE_PARAMS, SIZE));
logResult("PerlinNoise", PerlinNoise(23, 3, 0.70, 100));
logResult("PerlinNoiseMap", PerlinNoiseMap(NOISE_PARAMS, SIZE));
Code: Select all
17:53:56: ERROR[main]: get_perlin returned good object
17:53:56: ERROR[main]: get_perlin_map returned good object
17:53:56: ERROR[main]: PerlinNoise returned good object
17:53:56: ERROR[main]: PerlinNoiseMap returned good object
Code: Select all
17:53:56: ERROR[main]: get_perlin returned nil object
17:53:56: ERROR[main]: get_perlin_map returned nil object
17:53:56: ERROR[main]: PerlinNoise returned good object
17:53:56: ERROR[main]: PerlinNoiseMap returned good object
Last edited by prestidigitator on Thu Jan 02, 2014 01:57, edited 1 time in total.
- PilzAdam
- Member
- Posts: 4026
- Joined: Fri Jul 20, 2012 16:19
- GitHub: PilzAdam
- IRC: PilzAdam
- Location: Germany
The code for get_perlin() wasnt touched since 0.4.7, and it doesnt return nil for me.
EDIT: Ah, found your problem: You can only call it after the environment is created. So put the code in minetest.after(0, ...) or so.
EDIT: Ah, found your problem: You can only call it after the environment is created. So put the code in minetest.after(0, ...) or so.
Last edited by PilzAdam on Thu Jan 02, 2014 02:01, edited 1 time in total.
-
- Member
- Posts: 647
- Joined: Thu Feb 21, 2013 23:54
Who is online
Users browsing this forum: No registered users and 7 guests