error determining biome name

User avatar
PolySaken
Member
 
Posts: 396
Joined: Thu Nov 09, 2017 05:18
Location: djelibabi
GitHub: PolySaken-I-Am
In-game: PolySaken

error determining biome name

by PolySaken » Wed Oct 02, 2019 08:44

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?)
 

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

Re: error determining biome name

by duane » Wed Oct 02, 2019 12:28

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: 236
Joined: Sun Dec 16, 2018 12:50

Re: error determining biome name

by Termos » Wed Oct 02, 2019 13:16

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: 396
Joined: Thu Nov 09, 2017 05:18
Location: djelibabi
GitHub: PolySaken-I-Am
In-game: PolySaken

Re: error determining biome name

by PolySaken » Thu Oct 03, 2019 00:05

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.
 

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

Re: error determining biome name

by duane » Thu Oct 03, 2019 02:17

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: 236
Joined: Sun Dec 16, 2018 12:50

Re: error determining biome name

by Termos » Thu Oct 03, 2019 07:19

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: 534
Joined: Mon Dec 29, 2014 08:07
Location: USA
GitHub: ShadMOrdre
In-game: shadmordre

Re: error determining biome name

by ShadMOrdre » Thu Oct 03, 2019 17:11

Biomes are 2-D. This is why you cannot stack biomes.
MY MODS: lib_ecology lib_materials lib_clouds lib_node_shapes ---- Inspired By: Open Source Virtual World Simulator Opensimulator.
 

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

Re: error determining biome name

by Termos » Thu Oct 03, 2019 19:00

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: 3453
Joined: Sun Oct 28, 2012 00:05
Location: UK
GitHub: paramat
IRC: paramat

Re: error determining biome name

by paramat » Thu Oct 03, 2019 22:20

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: 396
Joined: Thu Nov 09, 2017 05:18
Location: djelibabi
GitHub: PolySaken-I-Am
In-game: PolySaken

Re: error determining biome name

by PolySaken » Thu Oct 03, 2019 22:52

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.
 

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

Re: error determining biome name

by Termos » Thu Oct 03, 2019 23:29

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

User avatar
PolySaken
Member
 
Posts: 396
Joined: Thu Nov 09, 2017 05:18
Location: djelibabi
GitHub: PolySaken-I-Am
In-game: PolySaken

Re: error determining biome name

by PolySaken » Fri Oct 04, 2019 06:59

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

The one It looks like the player is in.
 

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

Re: error determining biome name

by Termos » Fri Oct 04, 2019 09:29

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: 396
Joined: Thu Nov 09, 2017 05:18
Location: djelibabi
GitHub: PolySaken-I-Am
In-game: PolySaken

Re: error determining biome name

by PolySaken » Sat Oct 05, 2019 06:20

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.
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 4 guests