wip
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
-- Imports -----------------------------------------------------------------------------------------
|
||||
|
||||
local api = _G["jvmi_biomes"]
|
||||
|
||||
|
||||
-- Functions ---------------------------------------------------------------------------------------
|
||||
|
||||
--[[
|
||||
Apply biomes to the base terrain provided.
|
||||
|
||||
Args:
|
||||
region:jvmi_mapgen:Region - the region currently being generated
|
||||
]]--
|
||||
function api.apply_biomes(region) end
|
||||
@@ -0,0 +1,82 @@
|
||||
-- Imports -----------------------------------------------------------------------------------------
|
||||
|
||||
-- Since we're in the mapgen environment, we can't count on the mod loading process. Instead, we
|
||||
-- have to load everything we need from other mods manually.
|
||||
|
||||
local core = _G["core"]
|
||||
local api = _G["jvmi_biomes"]
|
||||
|
||||
local path = core.get_modpath("jvmi_constants")
|
||||
dofile(path.."/constants.lua")
|
||||
local C = _G["jvmi_constants"]
|
||||
|
||||
path = core.get_modpath("jvmi_mapgen")
|
||||
dofile(path.."/init.lua")
|
||||
local mapgen = _G["jvmi_mapgen"]
|
||||
local Region = mapgen.Region
|
||||
|
||||
|
||||
-- Private -----------------------------------------------------------------------------------------
|
||||
|
||||
local private = {}
|
||||
|
||||
--[[
|
||||
Assigns a specific biome to each position in the region.
|
||||
|
||||
Args:
|
||||
region:Region - the region currently being generated
|
||||
]]--
|
||||
function private.assign_biomes(region)
|
||||
region.iterate_columns(function(x, z)
|
||||
local terrain_type = region:get_meta(Region.META.TERRAIN_TYPE, x, z)
|
||||
local terrain = C.TERRAIN_TYPES[terrain_type]
|
||||
region:set_meta(Region.META.BIOME, x, z, core.get_biome_id(terrain.name))
|
||||
end)
|
||||
end
|
||||
|
||||
--[[
|
||||
Replace the upper layers of stone with biome-specific top and filler nodes.
|
||||
|
||||
Args:
|
||||
region:Region - the region currently being generated
|
||||
]]--
|
||||
function private.fill_surface(region)
|
||||
region.iterate_columns(function(x, z)
|
||||
local biome_id = region:get_meta(Region.META.BIOME, x, z)
|
||||
local biome_name = core.get_biome_name(biome_id)
|
||||
local biome = core.registered_biomes[biome_name]
|
||||
|
||||
local y = region:get_meta(Region.META.ALTITUDE)
|
||||
local top_count = biome.depth_top or 0
|
||||
local filler_count = biome.depth_filler or 0
|
||||
|
||||
while y >= region.fill_min.y do
|
||||
if top_count > 0 then
|
||||
local content_id = core.get_content_id(biome.node_top)
|
||||
if content_id then
|
||||
region:set_content_id(x, y, z, content_id)
|
||||
end
|
||||
top_count = top_count - 1
|
||||
elseif filler_count > 0 then
|
||||
local content_id = core.get_content_id(biome.node_filler)
|
||||
if content_id then
|
||||
region:set_content_id(x, y, z, content_id)
|
||||
end
|
||||
filler_count = filler_count - 1
|
||||
else
|
||||
break
|
||||
end
|
||||
|
||||
y = y - 1
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
-- API Implementations -----------------------------------------------------------------------------
|
||||
|
||||
function api.apply_biomes(region)
|
||||
private.assign_biomes(region)
|
||||
|
||||
private.fill_surface(region)
|
||||
end
|
||||
@@ -0,0 +1,52 @@
|
||||
-- Imports -----------------------------------------------------------------------------------------
|
||||
|
||||
local core = _G["core"]
|
||||
|
||||
|
||||
-- Registrations -----------------------------------------------------------------------------------
|
||||
|
||||
core.register_biome({
|
||||
name = "ocean_floor",
|
||||
node_top = "jvmi_nodes:clay", depth_top = 4,
|
||||
})
|
||||
|
||||
core.register_biome({
|
||||
name = "ocean_abyss",
|
||||
node_top = "jvmi_nodes:clay", depth_top = 2,
|
||||
node_filler = "jvmi_nodes:gravel", depth_filler = 2,
|
||||
})
|
||||
|
||||
core.register_biome({
|
||||
name = "ocean_shelf",
|
||||
node_top = "jvmi_nodes:sand", depth_top = 2,
|
||||
node_filler = "jvmi_nodes:gravel", depth_filler = 2,
|
||||
})
|
||||
|
||||
core.register_biome({
|
||||
name = "ocean_surface",
|
||||
node_top = "jvmi_nodes:sand", depth_top = 2,
|
||||
node_filler = "jvmi_nodes:gravel", depth_filler = 2,
|
||||
})
|
||||
|
||||
core.register_biome({
|
||||
name = "land_plains",
|
||||
node_top = "jvmi_nodes:turf", depth_top = 1,
|
||||
node_filler = "jvmi_nodes:dirt", depth_filler = 3,
|
||||
})
|
||||
|
||||
core.register_biome({
|
||||
name = "land_hills",
|
||||
node_top = "jvmi_nodes:turf", depth_top = 1,
|
||||
node_filler = "jvmi_nodes:dirt", depth_filler = 2,
|
||||
})
|
||||
|
||||
core.register_biome({
|
||||
name = "land_moors",
|
||||
node_top = "jvmi_nodes:turf", depth_top = 1,
|
||||
node_filler = "jvmi_nodes:dirt", depth_filler = 1,
|
||||
})
|
||||
|
||||
core.register_biome({
|
||||
name = "land_mountains",
|
||||
node_top = "jvmi_nodes:gravel", depth_top = 1,
|
||||
})
|
||||
@@ -0,0 +1,23 @@
|
||||
-- Imports -----------------------------------------------------------------------------------------
|
||||
|
||||
local core = _G["core"]
|
||||
|
||||
|
||||
-- Public ------------------------------------------------------------------------------------------
|
||||
|
||||
jvmi_biomes = {} -- luacheck: globals jvmi_biomes
|
||||
|
||||
local path = core.get_modpath("jvmi_biomes")
|
||||
dofile(path.."/api.lua")
|
||||
dofile(path.."/apply.lua")
|
||||
|
||||
|
||||
-- Registrations -----------------------------------------------------------------------------------
|
||||
|
||||
core.clear_registered_biomes()
|
||||
dofile(path.."/definitions.lua")
|
||||
|
||||
|
||||
-- Script ------------------------------------------------------------------------------------------
|
||||
|
||||
core.log("info", "jvmi_biomes loaded")
|
||||
@@ -0,0 +1,4 @@
|
||||
name = jvmi_biomes
|
||||
title = Jules Verne's Mysterious Island / Biomes
|
||||
description = define biomes and decoration/generation functions for them
|
||||
author = tungstonminer
|
||||
Reference in New Issue
Block a user