[Mod] Biome Info API [1.0.3] [biomeinfo]

Post Reply
User avatar
Wuzzy
Member
Posts: 3962
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

[Mod] Biome Info API [1.0.3] [biomeinfo]

by Wuzzy » Post

API to get biome information for v6 worlds

This is an API mod for modders to provide some missing functions related to biome in v6 worlds. Note the v6 mapgen has its own biome system, so the core Lua API functions to get biome data are useless here.

Currently, this mod has functions only related to the v6 mapgen, but more functions might be added in future.

You can get the temperature, humidity and biome of a given position in v6 worlds. You can also get a list of all active v6 biomes in the current world (since some biomes can be disabled).

Known limitations
  • v6 biome detection does not support biomeblend yet. This means biome detection is not perfectly accurate near biome borders if the biomeblend mapgen flag is enabled, it's just an estimate instead
Mod infos:
Last edited by Wuzzy on Thu Jan 02, 2020 14:36, edited 2 times in total.
My creations. I gladly accept bitcoins: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH

User avatar
DrFrankenstone
Member
Posts: 166
Joined: Tue May 24, 2016 05:36
GitHub: treer
Location: Melbourne, Australia
Contact:

Re: [Mod] Biome Info API [1.0.1] [biomeinfo]

by DrFrankenstone » Post

Any chance of adding MT5-ish description tables for each biome?

I can certainly hard-code node_top etc. values myself, but the biomeinfo mod seems a better location for that information.

Perhaps also shims like biomeinfo.get_heat(pos) that returns biomeinfo.get_v6_heat(pos) * 100 if the mapgen is v6 and otherwise returns minetest.get_heat(pos)
Last edited by DrFrankenstone on Wed Jan 01, 2020 02:47, edited 1 time in total.

User avatar
Wuzzy
Member
Posts: 3962
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [Mod] Biome Info API [1.0.1] [biomeinfo]

by Wuzzy » Post

You mean, like a fake biome table like in minetest.registered_biomes? Sounds interesting, but the analogy would break down at some points. I believe heat_point and humidity_point wouldn't work.

I don't consider it important enough, to be honest. But I might accept patches.
My creations. I gladly accept bitcoins: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH

kestral
Member
Posts: 89
Joined: Mon Mar 27, 2017 21:56
GitHub: kestral246

Re: [Mod] Biome Info API [1.0.1] [biomeinfo]

by kestral » Post

Wuzzy,

I'm trying to add v6 support to my display_biome mod, but I'm having an issue.

Whenever I first enable the biome display, right after creating a brand new v6 world, I get the following error. However, if I then restart that world in minetest, my biome display works just fine.

ERROR[Main]: ServerError: AsyncErr: environment_Step: Runtime error from mod 'display_biome' in callback environment_Step(): .../biomeinfo/init.lua:117: attempt to index upvalue 'mgv6_perlin_biome' (a nil value)
ERROR[Main]: stack traceback:
ERROR[Main]: .../biomeinfo/init.lua:117: in function 'get_v6_heat'
ERROR[Main]: .../display_biome/init.lua:92: in function <.../display_biome/init.lua:71>
ERROR[Main]: .../builtin/game/register.lua:429: in function <.../builtin/game/register.lua:413>
ERROR[Main]: stack traceback:


biomeinfo/init.lua:117
return mgv6_perlin_biome:get_2d({x=bpos.x + mgv6_np_biome.spread.x*0.6, y=bpos.z + mgv6_np_biome.spread.z*0.2})


display_biome/init.lua:92
heat = math.floor(biomeinfo.get_v6_heat(bpos) * 100 + 0.5)/100



Secondly, should I multiply the v6 heat and humidity values by 100, or display them as fractions with two decimals?

User avatar
Wuzzy
Member
Posts: 3962
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [Mod] Biome Info API [1.0.1] [biomeinfo]

by Wuzzy » Post

Can you give me the full code you used for testing?
Secondly, should I multiply the v6 heat and humidity values by 100, or display them as fractions with two decimals?
Leave the numbers as-is (but you can ofc round the numbers as you like). The heat and humdity in v6 is just different. No reason to touch it.
My creations. I gladly accept bitcoins: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH

User avatar
DrFrankenstone
Member
Posts: 166
Joined: Tue May 24, 2016 05:36
GitHub: treer
Location: Melbourne, Australia
Contact:

Re: [Mod] Biome Info API [1.0.1] [biomeinfo]

by DrFrankenstone » Post

Kestral - you may be getting that error by not checking if the current mapgen is v6 before using biomeinfo.
Wuzzy wrote:Leave the numbers as-is (but you can ofc round the numbers as you like). The heat and humdity in v6 is just different. No reason to touch it.
Yeah, for an inspection tool there's no need to change them. I was only multiplying by 100 in the example to make it the same as MT5's default range of heat and humidity as a shim - so that special handling wouldn't be needed in code that decides things like whether ponds should be frozen etc.

--

My fake biome table (since lua_api.txt lists the aliases as required with Mapgen V6):

Code: Select all

biomes["Normal"] = {node_top="mapgen_dirt_with_grass", node_filler="mapgen_dirt",        node_stone="mapgen_stone"}
biomes["Desert"] = {node_top="mapgen_desert_sand",     node_filler="mapgen_desert_sand", node_stone="mapgen_desert_stone"}
biomes["Jungle"] = {node_top="mapgen_dirt_with_grass", node_filler="mapgen_dirt",        node_stone="mapgen_stone"}
biomes["Tundra"] = {node_top="mapgen_dirt_with_snow",  node_filler="mapgen_dirt",        node_stone="mapgen_stone"}
biomes["Taiga"]  = {node_top="mapgen_dirt_with_snow",  node_filler="mapgen_dirt",        node_stone="mapgen_stone"}
and node_riverbed="mapgen_sand" could also be added.

kestral
Member
Posts: 89
Joined: Mon Mar 27, 2017 21:56
GitHub: kestral246

Re: [Mod] Biome Info API [1.0.1] [biomeinfo]

by kestral » Post

Wuzzy,

I uploaded my code to: https://github.com/kestral246/display_biome/tree/v6.

Use /biomes to enable the display.

Thanks.

User avatar
Wuzzy
Member
Posts: 3962
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Version 1.0.2 released! Version 1.0.3 released!

by Wuzzy » Post

Okay, it seems Minetest just refuses to give me the default heat/humidity noise parameters when none is set in config. I have added a workaround by hardcoding the defaults into my script.

I hope it works now in the new version 1.0.3.
My creations. I gladly accept bitcoins: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH

Post Reply

Who is online

Users browsing this forum: texmex and 6 guests