[mod] Biome library [git][biome_lib]

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

[mod] Biome library [git][biome_lib]

by VanessaE » Sun Aug 09, 2015 14:33

Vanessa's plants/biome library


This library's purpose is to allow other mods to add growing things to the map in a straightforward, simple manner. It contains all the core functions needed by mods and modpacks such as More Trees, Tiny Trees, Plantlife, and others.

Spawning of plants is optionally sensitive to the amount of available light, elevation, nearness to other nodes, plant-to-plant density, water depth, and a whole host of controls.

All objects spawned or generated using this mod use Perlin noise to stay within simple biomes, rather than just letting everything just spread around the map randomly.

This library also features a basic temperature map, which should blend in nicely with SPlizard's Snow Biomes mod (the same Perlin settings are used, with the assumption that the edge of a snow biome is 0° Centigrade).

Both mapgen-based spawning and ABM-based spawning is supported. The active growing code is strictly ABM-based. L-system trees can be spawned at mapgen time via the engine's spawn_tree() function.

It is aimed primarily at mapgen v6, and does not use the biome capabilities supplied by mapgen v7 (that will change some day). As such, if used in a mapgen v7 world, it'll work just fine but the temperature and humidity maps will not match up the way you might expect.

On server-exit, biome_lib will "hang" the server for a bit so that it can play out the rest of its deferred-generation log. This process may take a couple of minutes, and is done to prevent areas being left under-populated.

This mod was formerly known as "plants_lib" and used to be included in the Plantlife Modpack.

Dependencies: default from minetest_game

Recommends: Plantlife Modpack, More Trees

Download: https://github.com/VanessaE/biome_lib/a ... master.zip
...or browse the code: https://github.com/VanessaE/biome_lib

License: WTFPL

API: This mod supplies a small number of very powerful functions. They are, briefly:

  • biome_lib:register_generate_plant()
  • biome_lib:spawn_on_surfaces()
  • biome_lib:grow_plants()
  • biome_lib:find_valid_wall()
  • biome_lib:is_node_loaded()

For a complete description of these functions as well as several of the internal variables within the mod, see API.txt, included in the distribution archive, or view it online.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
Clouds
Member
 
Posts: 102
Joined: Sat Aug 01, 2015 01:58
In-game: Cloud

Re: [mod] Biome library [git][biome_lib]

by Clouds » Sun Aug 09, 2015 17:40

Can i replace plant_lib with this and not have any issues?
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

Re: [mod] Biome library [git][biome_lib]

by VanessaE » Sun Aug 09, 2015 17:41

Only if the mods that depended on plants_lib are updated accordingly.

I've already taken care of Moretrees and Plantlife modpack, and have sent pull requests to several others, some of whom have already updated.

Any mod that used plants_lib will at minimum need its depends.txt updated to reference "biome_lib" instead. Otherwise those mods will throw unresolved-dependency errors.

Mods that have not been properly updated beyond that bare minimum will throw deprecation warnings but should still work.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
Clouds
Member
 
Posts: 102
Joined: Sat Aug 01, 2015 01:58
In-game: Cloud

Re: [mod] Biome library [git][biome_lib]

by Clouds » Sun Aug 09, 2015 17:44

Ah thank you. Can you tell me whats the true difference between the two there than its not in the plantlife modpack?
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

Re: [mod] Biome library [git][biome_lib]

by VanessaE » Sun Aug 09, 2015 17:46

The two mods are identical, save for the various functions' namespaces. Hence the deprecation warning.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
Clouds
Member
 
Posts: 102
Joined: Sat Aug 01, 2015 01:58
In-game: Cloud

Re: [mod] Biome library [git][biome_lib]

by Clouds » Sun Aug 09, 2015 17:50

Mhmm alright then I see no reason to update since my plant_lib is not even a week old.
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

Re: [mod] Biome library [git][biome_lib]

by VanessaE » Sun Aug 09, 2015 17:54

Yeah, you can leave it be for now, until you decide you need to update something that depends on the change. In that case you will remove the entire plantlife modpack, download the latest git of it, and add biome_lib as a separate mod.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

Re: [mod] Biome library [git][biome_lib]

by VanessaE » Sat Aug 15, 2015 21:27

Small update: fixed a typo in deprecated function call handler.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
afflatus
Member
 
Posts: 302
Joined: Tue Apr 01, 2014 19:47
GitHub: 0-afflatus
IRC: afflatus
In-game: afflatus

Re: [mod] Biome library [git][biome_lib]

by afflatus » Sat Nov 14, 2015 14:02

I have been trying to figure out some way of properly integrating biome_lib with v5 / v7 mapgen. Unfortunately they use different kinds of perlin noise and I can't see any way of directly retrieving temperature / humidity for a specific node. Ultimately this means I will have to deprecate biome_lib.register_generate_plant() in favour of minetest.register_decoration() and put up with the lack of subtlety. Having jungletrees and oranges spawn next to snow / tundra biomes isn't making me happy.

Is anyone else bothered by this or am I SOMO?
Grailtest is sleeping ...
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

Re: [mod] Biome library [git][biome_lib]

by VanessaE » Sat Nov 14, 2015 15:15

I'm bothered by that as well, but I haven't really had much time to fiddle with it.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
afflatus
Member
 
Posts: 302
Joined: Tue Apr 01, 2014 19:47
GitHub: 0-afflatus
IRC: afflatus
In-game: afflatus

Re: [mod] Biome library [git][biome_lib]

by afflatus » Sun Nov 15, 2015 00:57

In which case I'll persevere.
I'm also working on a mod of woodsoils to make use of the extra dirt_with_* nodes, which could be a good excuse for me to learn how to make a PR.
Grailtest is sleeping ...
 

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

Re: [mod] Biome library [git][biome_lib]

by duane » Sun Nov 15, 2015 04:21

afflatus wrote:I have been trying to figure out some way of properly integrating biome_lib with v5 / v7 mapgen. Unfortunately they use different kinds of perlin noise and I can't see any way of directly retrieving temperature / humidity for a specific node.


You can just use the heat and humidity maps. You access those the same way you would a 2D noise array.

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 heatmap = minetest.get_mapgen_object("heatmap")
   local humiditymap = minetest.get_mapgen_object("humiditymap")


It's a lot more efficient if you're doing an entire chunk at a time, of course.
 

User avatar
afflatus
Member
 
Posts: 302
Joined: Tue Apr 01, 2014 19:47
GitHub: 0-afflatus
IRC: afflatus
In-game: afflatus

Re: [mod] Biome library [git][biome_lib]

by afflatus » Sun Nov 15, 2015 14:12

duane wrote:You can just use the heat and humidity maps. You access those the same way you would a 2D noise array.


Surely only inside an on_generate() callback?

I can't immediately see how to pass the maps to biome_lib.perlin_temperature and biome_lib.perlin_humidity.
minetest.setting_get("mg_biome_np_heat") or ("mg_biome_np_humidity") returns a noise param string, which seems more useful, but would need parsing and converting - PerlinNoise takes four args: (seed, octaves, persistence, scale), so one of the big questions is how to get the spread / scale right.

Also the noise values need to be * -1 IIUC because mapgen and biome_lib use inverse values.

I am struggling because I don't have a deep enough understanding of Perlin noise, or the mechanics of map generation. So far I have managed to come up with a hacky workaround by trial and error which produces acceptable results. Any help in getting biome_lib and mapgen to sing from the same songsheet is gratefully received!

Edit: should I be looking at the points where noise1 and noise2 are defined?
Grailtest is sleeping ...
 

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

Re: [mod] Biome library [git][biome_lib]

by duane » Mon Nov 16, 2015 15:37

afflatus wrote:
duane wrote:You can just use the heat and humidity maps. You access those the same way you would a 2D noise array.


Surely only inside an on_generate() callback?


Oh. I was thinking it was only used in generating chunks.

I haven't looked at the problem very long, but wouldn't this duplicate the v7 noises?

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
v7_temperature = PerlinNoise({offset=50, scale=50, spread={x=750,y=750,z=750}, seed=5349, octaves=3, persist=0.5, lacunarity=2.0})
v7_humidity = PerlinNoise({offset=50, scale=50, spread={x=750,y=750,z=750}, seed=842, octaves=3, persist=0.5, lacunarity=2.0})
v7_temperature_blend = PerlinNoise({offset=0, scale=1.5, spread={x=8,y=8,z=8}, seed=13, octaves=2, persist=1, lacunarity=2.0})
v7_humidity_blend = PerlinNoise({offset=0, scale=1.5, spread={x=8,y=8,z=8}, seed=90003, octaves=2, persist=1, lacunarity=2.0})


Then just use this when you need the temperature/humidity.

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
temp = v7_temperature.get2d(pos) + v7_temperature_blend.get2d(pos)
humidity = v7_humidity.get2d(pos) + v7_humidity_blend.get2d(pos)


I may be thinking of minetest.get_perlin instead of PerlinNoise, assuming they aren't identical. Of course as soon as someone changes their perlin noises in minetest.conf, all bets are off.

Edit: Note that this is supposed to give temperature in Fahrenheit (yuck) and humidity * 100.
 

User avatar
afflatus
Member
 
Posts: 302
Joined: Tue Apr 01, 2014 19:47
GitHub: 0-afflatus
IRC: afflatus
In-game: afflatus

Re: [mod] Biome library [git][biome_lib]

by afflatus » Mon Nov 16, 2015 17:41

OK, I don't want to duplicate the noise, I want to read the actual parameters, because as you rightly say, as soon as someone changes the mapgen params it will break. I doubt it is really necessary to include the *_blend noise. So long as the spread of values over the map roughly correlates to the biomes, this will work.

I also think the values fed to temp and humidity in your example would need to be * -1 as biome_lib, like splizzard's snow mod uses inverse values. That is unless you can use negative values for 'scale'.

So I think I just need to bite the bullet and figure out a way of unpacking the values from the noise params string returned by 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
local np_temp = minetest.setting_get("mg_biome_np_heat")
local np_humid = minetest.setting_get("mg_biome_np_humidity")


See also: viewtopic.php?f=7&t=9215#p198262 for a better explanation.
Grailtest is sleeping ...
 

User avatar
afflatus
Member
 
Posts: 302
Joined: Tue Apr 01, 2014 19:47
GitHub: 0-afflatus
IRC: afflatus
In-game: afflatus

Re: [mod] Biome library [git][biome_lib]

by afflatus » Mon Nov 23, 2015 00:00

I came up with this, which seems to work in mg v7
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 temp_table = {}
local temp_string = minetest.setting_get("mg_biome_np_heat")
temp_string:gsub("%d+%.?%d*", function(c) table.insert(temp_table,c) end)

local temperature_seeddiff = temp_table[6] or 112
local temperature_octaves = temp_table[7] or 3
local temperature_persistence = temp_table[8] or 0.5
local temperature_scale = temp_table[3] or 150

local humid_table = {}
local humid_string = minetest.setting_get("mg_biome_np_humidity")
humid_string:gsub("%d+%.?%d*", function(c) table.insert(humid_table,c) end)

local humidity_seeddiff = humid_table[6] or 9130
local humidity_octaves = humid_table[7] or 3
local humidity_persistence = humid_table[8] or 0.5
local humidity_scale = humid_table[3] or 250

Testing it may take some time ...
Grailtest is sleeping ...
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

Re: [mod] Biome library [git][biome_lib]

by VanessaE » Tue Nov 24, 2015 02:42

That's actually a lot simpler than I expected! I look forward to your pull request if it works out. :-)
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
afflatus
Member
 
Posts: 302
Joined: Tue Apr 01, 2014 19:47
GitHub: 0-afflatus
IRC: afflatus
In-game: afflatus

Re: [mod] Biome library [git][biome_lib]

by afflatus » Tue Nov 24, 2015 13:04

Yep, well I'm still waiting to be slapped by some gotcha. ;-)

Mapgen testing is very slow and laborious, if anyone else fancies testing this out on a new map (especially mgv6) with default settings running a fairly vanilla Minetest Game (with plantlife / moretrees natch), I'd be really interested in some feedback. :-)
Grailtest is sleeping ...
 

DoyleChris
Member
 
Posts: 176
Joined: Sat Jul 25, 2015 19:54
In-game: DoyleChris

Re: [mod] Biome library [git][biome_lib]

by DoyleChris » Tue Feb 02, 2016 21:28

Do i need this enabled to run moretrees.
 

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

Re: [mod] Biome library [git][biome_lib]

by burli » Sun Jan 29, 2017 15:10

How about mgv7 support? Any progress?

Edit: I don't think so. Still palm trees on cold beaches.

Image
Attachments
screenshot_20170129_171332.jpg
screenshot_20170129_171332.jpg (262.23 KiB) Viewed 2302 times
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

Re: [mod] Biome library [git][biome_lib]

by VanessaE » Sun Jan 29, 2017 22:35

I haven't been working on this mod lately, but I'm open to reasonable pull requests. It DOES work fine on mapgen v7, it just doesn't take advantage of any mgv7-specific features or climate/biome info. There is the issue of moretrees causing shadows on the map, but that's an engine bug.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 


Return to Mod Releases

Who is online

Users browsing this forum: No registered users and 80 guests

cron