make subterrane cross-compatible with minetest_game and mineclone2

master
FaceDeer 2021-05-06 20:28:37 -06:00
parent 1f385fc84a
commit 331d08b156
3 changed files with 42 additions and 13 deletions

28
dependencies.lua Normal file
View File

@ -0,0 +1,28 @@
subterrane.dependencies = {}
local default_modpath = minetest.get_modpath("default")
local mcl_core_modpath = minetest.get_modpath("mcl_core")
assert(default_modpath or mcl_core_modpath, "[subterrane] This mod requires either minetest_game (default) or Mineclone2 (mcl_core) to be installed")
if default_modpath then
subterrane.dependencies.stone = "default:stone"
subterrane.dependencies.clay = "default:clay"
subterrane.dependencies.desert_stone = "default:desert_stone"
subterrane.dependencies.sandstone = "default:sandstone"
subterrane.dependencies.water = "default:water_source"
subterrane.dependencies.obsidian = "default:obsidian"
elseif mcl_core_modpath then
subterrane.dependencies.stone = "mcl_core:stone"
subterrane.dependencies.clay = "mcl_core:clay"
subterrane.dependencies.desert_stone = "mcl_core:redsandstone"
subterrane.dependencies.sandstone = "mcl_core:sandstone"
subterrane.dependencies.water = "mcl_core:water_source"
subterrane.dependencies.obsidian = "mcl_core:obsidian"
end
minetest.after(0, function() subterrane.dependencies = nil end) -- ensure these are only used during initialization, to avoid polluting the global namespace with irrelevancies

View File

@ -4,15 +4,21 @@
-- Depends default
-- License: code MIT
local c_stone = minetest.get_content_id("default:stone")
local c_clay = minetest.get_content_id("default:clay")
local c_desert_stone = minetest.get_content_id("default:desert_stone")
local c_sandstone = minetest.get_content_id("default:sandstone")
subterrane = {} --create a container for functions and constants
local modpath = minetest.get_modpath(minetest.get_current_modname())
dofile(modpath.."/dependencies.lua")
local c_stone = minetest.get_content_id(subterrane.dependencies.stone)
local c_clay = minetest.get_content_id(subterrane.dependencies.clay)
local c_desert_stone = minetest.get_content_id(subterrane.dependencies.desert_stone)
local c_sandstone = minetest.get_content_id(subterrane.dependencies.sandstone)
local c_air = minetest.get_content_id("air")
local c_water = minetest.get_content_id("default:water_source")
local c_water = minetest.get_content_id(subterrane.dependencies.water)
local c_obsidian = minetest.get_content_id("default:obsidian")
local c_obsidian = minetest.get_content_id(subterrane.dependencies.obsidian)
local c_cavern_air = c_air
local c_warren_air = c_air
@ -28,14 +34,8 @@ local c_lava_set -- will be populated with a set of nodes that count as lava
-- Performance instrumentation
local t_start = os.clock()
subterrane = {} --create a container for functions and constants
subterrane.registered_layers = {}
--grab a shorthand for the filepath of the mod
local modpath = minetest.get_modpath(minetest.get_current_modname())
--load companion lua files
dofile(modpath.."/defaults.lua")
dofile(modpath.."/features.lua") -- some generic cave features useful for a variety of mapgens
dofile(modpath.."/player_spawn.lua") -- Function for spawning a player in a giant cavern

View File

@ -1,3 +1,4 @@
name = subterrane
description = A mapgen helper mod that facilitates the creation of vast underground caverns
depends = default, mapgen_helper
optional_depends = default, mcl_core
depends = mapgen_helper