2021-03-30 01:53:26 +02:00
-- Biome library mod by VanessaE
2015-08-09 16:15:16 +02:00
--
-- I got the temperature map idea from "hmmmm", values used for it came from
-- Splizard's snow mod.
--
2021-04-07 13:04:36 +02:00
biome_lib = { }
2021-04-20 23:56:43 +02:00
biome_lib.modpath = minetest.get_modpath ( " biome_lib " )
2021-04-07 13:04:36 +02:00
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if minetest.global_exists ( " intllib " ) then
if intllib.make_gettext_pair then
S = intllib.make_gettext_pair ( )
else
S = intllib.Getter ( )
end
else
S = function ( s ) return s end
end
biome_lib.intllib = S
2021-04-05 17:21:22 +02:00
local c1 = minetest.settings : get ( " biome_lib_default_grow_through_nodes " )
2021-03-30 03:10:41 +02:00
biome_lib.default_grow_through_nodes = { [ " air " ] = true }
if c1 then
for _ , i in ipairs ( tableize ( c1 ) ) do
biome_lib.default_grow_through_nodes [ i ] = true
end
else
biome_lib.default_grow_through_nodes [ " default:snow " ] = true
end
2021-04-05 17:21:22 +02:00
local c2 = minetest.settings : get ( " biome_lib_default_water_nodes " )
2021-03-30 03:10:41 +02:00
biome_lib.default_water_nodes = { }
if c2 then
for _ , i in ipairs ( tableize ( c2 ) ) do
biome_lib.default_water_nodes [ i ] = true
end
else
biome_lib.default_water_nodes [ " default:water_source " ] = true
biome_lib.default_water_nodes [ " default:water_flowing " ] = true
biome_lib.default_water_nodes [ " default:river_water_source " ] = true
biome_lib.default_water_nodes [ " default:river_water_flowing " ] = true
end
local c3 = minetest.settings : get ( " biome_lib_default_wet_surfaces " )
local c4 = minetest.settings : get ( " biome_lib_default_ground_nodes " )
local c5 = minetest.settings : get ( " biome_lib_default_grow_nodes " )
biome_lib.default_wet_surfaces = c3 and tableize ( c3 ) or { " default:dirt " , " default:dirt_with_grass " , " default:sand " }
biome_lib.default_ground_nodes = c4 and tableize ( c4 ) or { " default:dirt_with_grass " }
biome_lib.default_grow_nodes = c5 and tableize ( c5 ) or { " default:dirt_with_grass " }
2021-04-07 13:30:58 +02:00
biome_lib.debug_log_level = tonumber ( minetest.settings : get ( " biome_lib_debug_log_level " ) ) or 0
2015-08-09 16:15:16 +02:00
2021-04-16 16:41:38 +02:00
local rr = tonumber ( minetest.settings : get ( " biome_lib_queue_ratio " ) ) or - 200
biome_lib.queue_ratio = 100 - rr
2021-04-07 13:04:36 +02:00
biome_lib.entries_per_step = math.max ( - rr , 1 )
2021-04-08 12:33:43 +02:00
-- the timer that manages the block timeout is in microseconds, but the timer
-- that manages the queue wakeup call has to be in seconds, and works best if
2021-04-09 19:04:28 +02:00
-- it takes a fraction of the block timeout interval.
2021-04-08 12:33:43 +02:00
2021-04-08 14:09:59 +02:00
local t = tonumber ( minetest.settings : get ( " biome_lib_block_timeout " ) ) or 300
2021-04-08 12:33:43 +02:00
biome_lib.block_timeout = t * 1000000
2021-04-09 19:04:28 +02:00
-- we don't want the wakeup function to trigger TOO often,
-- in case the user's block timeout setting is really low
2019-01-02 20:35:39 +01:00
2021-04-20 23:56:43 +02:00
biome_lib.block_queue_wakeup_time = math.min ( t / 2 , math.max ( 20 , t / 10 ) )
2015-08-09 16:15:16 +02:00
2021-04-20 23:56:43 +02:00
-- the actual important stuff starts here ;-)
2015-08-09 16:15:16 +02:00
2021-04-20 23:56:43 +02:00
dofile ( biome_lib.modpath .. " /api.lua " )
2019-01-02 20:35:39 +01:00
dofile ( biome_lib.modpath .. " /search_functions.lua " )
2021-04-20 23:56:43 +02:00
dofile ( biome_lib.modpath .. " /growth.lua " )
2021-04-20 22:27:17 +02:00
dofile ( biome_lib.modpath .. " /compat.lua " )
-- and report the final registration results:
2021-04-07 11:16:11 +02:00
minetest.after ( 0 , function ( )
biome_lib.dbg ( " Registered a total of " .. ( # biome_lib.surfaceslist_aircheck ) + ( # biome_lib.surfaceslist_no_aircheck ) .. " surface types to be evaluated, spread " , 0 )
biome_lib.dbg ( " across " .. # biome_lib.actionslist_aircheck .. " actions with air-checking and " .. # biome_lib.actionslist_no_aircheck .. " actions without. " , 0 )
2021-04-16 18:58:02 +02:00
biome_lib.dbg ( " within an elevation range of " .. biome_lib.mapgen_elevation_limit . min .. " and " .. biome_lib.mapgen_elevation_limit . max .. " meters. " , 0 )
2021-04-07 11:16:11 +02:00
end )
biome_lib.dbg ( " [Biome Lib] Loaded " , 0 )