Page 1 of 1

biome index

PostPosted: Fri Jan 08, 2016 22:31
by Smitje
Thanks for all the help so far, just a short question today:

I'm using mapgen V7

inside minetest.register_on_generated(function(minp, maxp, seed)
bmap = minetest.get_mapgen_object("biomemap") returns an index (actually a list of indices). Where can I find what biome is linked to what index?
Do I just count them in mapgen.lua or is there a way to get the name from the index.

Sorry I feel like this is a dumb question I should be able to figure out, but I'm not educated as a programmer.

Cheers Smitje

Re: biome index

PostPosted: Sat Jan 09, 2016 00:08
by duane
Smitje wrote:Where can I find what biome is linked to what index?


Good question. This is how I do it:

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 biome_ids then
   biome_ids = {}
   for name, desc in pairs(minetest.registered_biomes) do
      local i = minetest.get_biome_id(desc.name)
      biome_ids[i] = desc.name
   end
end


Mind you, get_biome_id was added fairly recently, so there are likely still people playing with versions of minetest that don't have it yet.

An alternative is to copy and reregister all the biomes, so that you know which order they were put back in. Just stick each description in a table, clear all biomes, and note which name goes in which number as you register them again. That's the order they'll be in... unless someone else tries the same trick, of course.

I did something similar with the decorations, here.