biome index

Smitje
Member
 
Posts: 22
Joined: Wed Nov 14, 2012 20:42

biome index

by Smitje » Fri Jan 08, 2016 22:31

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
 

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

Re: biome index

by duane » Sat Jan 09, 2016 00:08

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.
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 8 guests

cron