Can I get some biome informations?

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Can I get some biome informations?

by burli » Thu Apr 07, 2016 10:37

Is it possible to get informations about the biome the player is currently in? Or can I just get humidity and temperature? In MC you can see if you are in the plains, swampland and so on
 

User avatar
duane
Member
 
Posts: 776
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r

Re: Can I get some biome informations?

by duane » Thu Apr 07, 2016 12:54

burli wrote:Is it possible to get informations about the biome the player is currently in? Or can I just get humidity and temperature? In MC you can see if you are in the plains, swampland and so on


There doesn't seem to be any way to do that directly. What you can do is get the biome noises from settings and use them to calculate the temperature and humidity, and then use that to pick the biome. This is a bit complicated in most of the mapgens, except for valleys, in which it's extremely complicated.
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Can I get some biome informations?

by burli » Thu Apr 07, 2016 13:11

Hm, but the mapgen knows the biome when he generates the map, right? What if the mg stores something like "biome:plains" in the NodeMetaRef of each node? Or would that be to much data?
 

User avatar
duane
Member
 
Posts: 776
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r

Re: Can I get some biome informations?

by duane » Thu Apr 07, 2016 15:43

burli wrote:Hm, but the mapgen knows the biome when he generates the map, right? What if the mg stores something like "biome:plains" in the NodeMetaRef of each node? Or would that be to much data?


You could do that. Of course, if the node moves, you'll have the wrong metadata on it, and again, you need an independent way to determine the values. Otherwise you'll have people carrying desert sand to the arctic with them, to keep warm.

If you make a function called by on_generate, it can copy the heat and humidity data wherever you like. At minimum, you'd have one number for every horizontal node you're storing (31K^2 for the whole map). Then you'd have to save that data somewhere and call it back when you need it. I don't think the size would be an issue so much as finding some way to store and retrieve it that wouldn't bog down the game.

I can't think of any easy way to do it.
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Can I get some biome informations?

by burli » Fri Apr 15, 2016 19:01

In voxel.lua from valley_c you are using biomemap. Can other mods can use this information too?
 

User avatar
duane
Member
 
Posts: 776
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r

Re: Can I get some biome informations?

by duane » Sun Apr 17, 2016 04:18

burli wrote:In voxel.lua from valley_c you are using biomemap. Can other mods can use this information too?


Sure. Bear in mind that the function I use to translate the biome numbers was only added in the last six months, so it won't be available on everyone's version of minetest.
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Can I get some biome informations?

by burli » Sun Apr 17, 2016 15:30

How could a get_biome(pos) function look like? Can you give me a hint?
 

User avatar
duane
Member
 
Posts: 776
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r

Re: Can I get some biome informations?

by duane » Tue Apr 19, 2016 01:30

burli wrote:How could a get_biome(pos) function look like? Can you give me a hint?


It's basically this:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
-- Create a table of biome ids, so I can use the biomemap.
if not valc.biome_ids then
   local i
   valc.biome_ids = {}
   for name, desc in pairs(minetest.registered_biomes) do
      i = minetest.get_biome_id(desc.name)
      valc.biome_ids[i] = desc.name
   end
end

local function get_biome(x, z)
   index_2d = (z - minp.z) * csize.y * csize.x + (x - minp.x)
   biome = valc.biome_ids[biomemap[index_2d]]
end


However, the biome map is only there during the generate function, so it's useless after you create the chunk.
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: Can I get some biome informations?

by paramat » Tue Apr 19, 2016 05:31

Sometime i might add an API for getting biome at any time after mapgen, the core code is already in mgv7.
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Can I get some biome informations?

by burli » Tue Apr 19, 2016 05:38

paramat wrote:Sometime i might add an API for getting biome at any time after mapgen, the core code is already in mgv7.

That would be awesome. Than I don't need to make a mod.
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Can I get some biome informations?

by burli » Sun May 08, 2016 19:12

[quote="duane"]
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local function get_biome(x, z)
   index_2d = (z - minp.z) * csize.y * csize.x + (x - minp.x)
   biome = valc.biome_ids[biomemap[index_2d]]
end


What is csize? Couldn't find any reference
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: Can I get some biome informations?

by paramat » Mon May 09, 2016 03:58

Chunksize, usually 80 but it can be different so get it from csize.x = maxp.x - minp.x + 1.
csize.x = csize.y = csize.z as our chunks are cubic.
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Can I get some biome informations?

by burli » Mon May 09, 2016 06:09

Thx
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Can I get some biome informations?

by burli » Mon May 09, 2016 16:33

duane wrote:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
   index_2d = (z - minp.z) * csize.y * csize.x + (x - minp.x)



I think this is wrong. Should be

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
index_2d = (z * csize.z + x)


With you equation I get huge numbers and the biome map always return nil
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: Can I get some biome informations?

by paramat » Mon May 09, 2016 18:57

Yes duane's equation is wrong, should be:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
index_2d = (z - minp.z) * csize + (x - minp.x) + 1

But i'm not sure about the + 1 at the end, that might be needed as c++ tables index from 0 while lua tables index from 1.
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: Can I get some biome informations?

by burli » Mon May 09, 2016 20:02

Ah, you are calculating the absolute world coordinate. I just calculate the relative coordinate inside the the chunk
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron