error determining biome name

Post Reply
User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

error determining biome name

by PolySaken » Post

I'm trying to use the current biome name for each player to determine what effects to apply, but either minetest.get_biome_data(pos) or minetest.get_biome_name(biome_data) is not working correctly.

(the full code)

Code: Select all

local biome=""
		
		local bname=minetest.get_biome_name(minetest.get_biome_data(player:get_pos())["biome"])
		print(bname)
		if string.find(bname, "%_") then
			local sbname = string.split(bname, "_")
			biome=sbname[1]
			print(1)
		else
			biome=bname
			print(2)
		end
		print(biome)
I'm getting the wrong output in the console for the biome i'm in.
For example: in the biome "plains", the code returns the biome name "jungle". does anyone know why this is happening.

(If this is just ambiguity about biome limits, could anyone recommend a better way to find the current biome?)
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
duane
Member
Posts: 1715
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r
Location: Oklahoma City
Contact:

Re: error determining biome name

by duane » Post

PolySaken wrote:I'm trying to use the current biome name for each player to determine what effects to apply, but either minetest.get_biome_data(pos) or minetest.get_biome_name(biome_data) is not working correctly.
Have you tried flooring the pos data? I don't remember offhand whether getpos returns float or integer data. Maybe get_biome_data expects integers.
Believe in people and you don't need to believe anything else.

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: error determining biome name

by Termos » Post

I'm pretty sure get_biome_data doesn't care about integers.
Maybe it's because player pos is one or two nodes away from the node he's standing on.
I'd try offsetting pos.y by players collisionbox[2] - 0.01

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: error determining biome name

by PolySaken » Post

Termos wrote:I'm pretty sure get_biome_data doesn't care about integers.
Maybe it's because player pos is one or two nodes away from the node he's standing on.
I'd try offsetting pos.y by players collisionbox[2] - 0.01
I'll give this a try.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
duane
Member
Posts: 1715
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r
Location: Oklahoma City
Contact:

Re: error determining biome name

by duane » Post

Termos wrote:I'm pretty sure get_biome_data doesn't care about integers.
Maybe it's because player pos is one or two nodes away from the node he's standing on.
I'd try offsetting pos.y by players collisionbox[2] - 0.01
As far as I know, biomes are still two-dimensional.
Believe in people and you don't need to believe anything else.

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: error determining biome name

by Termos » Post

That would make underground biomes impossible.
They're 3d, but yeah, on the surface they're 2d-ish, at least in MTG.

OP seems to be using a different game though.

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: error determining biome name

by ShadMOrdre » Post

Biomes are 2-D. This is why you cannot stack biomes.

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: error determining biome name

by Termos » Post

Sorry, disregard what I said then.
I'm definitely getting different biome ids for different y coords in the same xz column, but probably I'm missing something.

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

Re: error determining biome name

by paramat » Post

Should it be:

Code: Select all

local bname=minetest.get_biome_name(minetest.get_biome_data(player:get_pos()).biome)
.biome
instead of
["biome"]
?

Biomes are 3D and they are stacked in MTG. It is only heat and humidity noises that are 2D.

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: error determining biome name

by PolySaken » Post

Nothing seems to be working. I think the problem is with the borders of biomes not being cleanly defined. sometimes it's right, sometimes wrong, depending on the biome being entered and the one being left.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: error determining biome name

by Termos » Post

How do you determine which biome is 'right', anyway?

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: error determining biome name

by PolySaken » Post

Termos wrote:How do you determine which biome is 'right', anyway?
The one It looks like the player is in.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: error determining biome name

by Termos » Post

Ok, eyeballing may not be 100% reliable but should be good enough.

I've tested it myself, in vanilla MTG with carpathian mapgen the return of get_biome_data seems 100% exact so far, it works even for 1x1 biome blend inclusions.
Maybe it's the game/mod you're using. If any voxel manipulation is being done, that's probably the cause.

My test:

Code: Select all

minetest.register_on_chat_message(
	function(name, message)
		if message == 'doit' then
			local plyr = minetest.get_player_by_name(name)
			local pos = plyr:get_pos()
			pos.y = pos.y-0.01
			minetest.chat_send_all(minetest.get_biome_name(minetest.get_biome_data(pos).biome))
		end
	end
)

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: error determining biome name

by PolySaken » Post

Termos wrote:Ok, eyeballing may not be 100% reliable but should be good enough.

I've tested it myself, in vanilla MTG with carpathian mapgen the return of get_biome_data seems 100% exact so far, it works even for 1x1 biome blend inclusions.
Maybe it's the game/mod you're using. If any voxel manipulation is being done, that's probably the cause.

My test:

Code: Select all

minetest.register_on_chat_message(
	function(name, message)
		if message == 'doit' then
			local plyr = minetest.get_player_by_name(name)
			local pos = plyr:get_pos()
			pos.y = pos.y-0.01
			minetest.chat_send_all(minetest.get_biome_name(minetest.get_biome_data(pos).biome))
		end
	end
)
I tried modifying the y pos by -0.01 but it didn't change much. I think I'll just rewrite it all.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 12 guests