wip
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
-- Import ------------------------------------------------------------------------------------------
|
-- Private -----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
local C = _G["jvmi_constants"]
|
local C = {}
|
||||||
local core = _G["core"]
|
|
||||||
|
|
||||||
|
|
||||||
-- Node Definition Constants -----------------------------------------------------------------------
|
-- Node Definition Constants -----------------------------------------------------------------------
|
||||||
@@ -77,7 +76,7 @@ C.TERRAIN_BLEND = 0.15
|
|||||||
C.TERRAIN_RADIUS = 3096
|
C.TERRAIN_RADIUS = 3096
|
||||||
|
|
||||||
--[[ The noise generator that decides which terrain type is active at a given x,z location. ]]--
|
--[[ The noise generator that decides which terrain type is active at a given x,z location. ]]--
|
||||||
C.TERRAIN_TYPE_NOISE = core.get_value_noise({
|
C.TERRAIN_TYPE_NOISE_PARAMS = {
|
||||||
flags = "eased",
|
flags = "eased",
|
||||||
lacunarity = 2,
|
lacunarity = 2,
|
||||||
octaves = 1,
|
octaves = 1,
|
||||||
@@ -86,7 +85,7 @@ C.TERRAIN_TYPE_NOISE = core.get_value_noise({
|
|||||||
scale = 1.0,
|
scale = 1.0,
|
||||||
seed = 8381909047,
|
seed = 8381909047,
|
||||||
spread = { x = 512, y = 512, z = 0 },
|
spread = { x = 512, y = 512, z = 0 },
|
||||||
})
|
}
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
A table defining the terrain types used in generating the base terrain.
|
A table defining the terrain types used in generating the base terrain.
|
||||||
@@ -110,3 +109,8 @@ C.TERRAIN_TYPES = {
|
|||||||
{ name = "land_moors", lowest = A.MOOR - 16, highest = A.MOOR, weight = 15 },
|
{ name = "land_moors", lowest = A.MOOR - 16, highest = A.MOOR, weight = 15 },
|
||||||
{ name = "land_mountains", lowest = A.MOUNTAIN - 80, highest = A.MOUNTAIN, weight = 5 },
|
{ name = "land_mountains", lowest = A.MOUNTAIN - 80, highest = A.MOUNTAIN, weight = 5 },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
-- Export ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return C
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
-- Private -----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local private = {}
|
||||||
|
|
||||||
|
function private.dump(value, depth, indent, seen)
|
||||||
|
depth = depth or -1
|
||||||
|
indent = indent or ""
|
||||||
|
seen = seen or {}
|
||||||
|
|
||||||
|
if depth == 0 then return "<too deep: "..tostring(value)..">" end
|
||||||
|
|
||||||
|
if seen[value] == true then return "<already seen: "..tostring(value)..">" end
|
||||||
|
seen[value] = true
|
||||||
|
|
||||||
|
local result = ""
|
||||||
|
if type(value) == "table" then
|
||||||
|
result = result.."{\n"
|
||||||
|
local inner_indent = indent.." "
|
||||||
|
for inner_key, inner_value in pairs(value) do
|
||||||
|
local inner_text = private.dump(inner_value, depth - 1, inner_indent, seen)
|
||||||
|
result = result..inner_indent..inner_key.." = "..inner_text.."\n"
|
||||||
|
end
|
||||||
|
result = result..indent.."}"
|
||||||
|
else
|
||||||
|
result = tostring(value)
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Export -----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return private.dump
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
-- Import ------------------------------------------------------------------------------------------
|
-- Import ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
local jvmi_mapgen = _G["jvmi_mapgen"]
|
|
||||||
local math = _G["math"]
|
local math = _G["math"]
|
||||||
local VoxelArea = _G["VoxelArea"]
|
local VoxelArea = _G["VoxelArea"]
|
||||||
|
|
||||||
@@ -23,7 +22,6 @@ local Region = {
|
|||||||
TERRAIN_TYPE = "terrain_type",
|
TERRAIN_TYPE = "terrain_type",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jvmi_mapgen.Region = Region
|
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Create a new Region object to manage the generation of a part of the map.
|
Create a new Region object to manage the generation of a part of the map.
|
||||||
@@ -40,7 +38,7 @@ function Region:new()
|
|||||||
_meta = {},
|
_meta = {},
|
||||||
_voxels = nil,
|
_voxels = nil,
|
||||||
}
|
}
|
||||||
setmetatable(result, Region)
|
setmetatable(result, { __index = Region })
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -93,17 +91,17 @@ end
|
|||||||
doOperation:function(x:int,y:int,z:int) - the callback to be invoked for each voxel
|
doOperation:function(x:int,y:int,z:int) - the callback to be invoked for each voxel
|
||||||
]]--
|
]]--
|
||||||
function Region:iterate(x_min, x_max, y_min, y_max, z_min, z_max, doOperation)
|
function Region:iterate(x_min, x_max, y_min, y_max, z_min, z_max, doOperation)
|
||||||
x_min = math.max(x_min, self._fill_min.x)
|
x_min = math.floor(math.max(x_min, self._fill_min.x))
|
||||||
x_max = math.min(x_max, self._fill_max.x)
|
x_max = math.floor(math.min(x_max, self._fill_max.x))
|
||||||
y_min = math.max(y_min, self._fill_min.y)
|
y_min = math.floor(math.max(y_min, self._fill_min.y))
|
||||||
y_max = math.min(y_max, self._fill_max.y)
|
y_max = math.floor(math.min(y_max, self._fill_max.y))
|
||||||
z_min = math.max(z_min, self._fill_min.z)
|
z_min = math.floor(math.max(z_min, self._fill_min.z))
|
||||||
z_max = math.min(z_max, self._fill_max.z)
|
z_max = math.floor(math.min(z_max, self._fill_max.z))
|
||||||
|
|
||||||
for z = z_min, z_max do
|
for z = z_min, z_max do
|
||||||
for y = y_min, y_max do
|
for y = y_min, y_max do
|
||||||
for x = x_min, x_max do
|
for x = x_min, x_max do
|
||||||
doOperation(self, x, y, z)
|
doOperation(x, y, z)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -270,3 +268,8 @@ function Region:save_voxels()
|
|||||||
self._fill_min = nil
|
self._fill_min = nil
|
||||||
self._voxels = nil
|
self._voxels = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Export ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return Region
|
||||||
@@ -1,10 +1,26 @@
|
|||||||
-- Imports -----------------------------------------------------------------------------------------
|
-- Import ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
local api = _G["jvmi_table"]
|
local table = _G.table
|
||||||
local table = _G["table"]
|
|
||||||
|
|
||||||
|
|
||||||
-- API Functions -----------------------------------------------------------------------------------
|
-- Private -----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local private = {}
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Add a value to the end of an array-like table.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
target:array - a table which is being used like an array (i.e., contiguous integer keys)
|
||||||
|
value:any - the value to be appeneded to the array
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
the target table
|
||||||
|
]]--
|
||||||
|
function private.append(target, value)
|
||||||
|
target[#target] = value
|
||||||
|
return target
|
||||||
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Performs a deep clone of a given table.
|
Performs a deep clone of a given table.
|
||||||
@@ -18,12 +34,12 @@ local table = _G["table"]
|
|||||||
Returns:
|
Returns:
|
||||||
a new table which the same keys and deeply copied values
|
a new table which the same keys and deeply copied values
|
||||||
]]--
|
]]--
|
||||||
function api.clone(source)
|
function private.clone(source)
|
||||||
if type(source) ~= "table" then return source end
|
if type(source) ~= "table" then return source end
|
||||||
|
|
||||||
local target = {}
|
local target = {}
|
||||||
for key, value in pairs(source) do
|
for key, value in pairs(source) do
|
||||||
target[key] = api.clone(value)
|
target[key] = private.clone(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
return target
|
return target
|
||||||
@@ -42,23 +58,8 @@ end
|
|||||||
a new table with the same keys and values as the original
|
a new table with the same keys and values as the original
|
||||||
|
|
||||||
]]--
|
]]--
|
||||||
function api.copy(source)
|
function private.copy(source)
|
||||||
return api.merge({}, source)
|
return private.merge({}, source)
|
||||||
end
|
|
||||||
|
|
||||||
--[[
|
|
||||||
Add a value to the end of an array-like table.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
target:array - a table which is being used like an array (i.e., contiguous integer keys)
|
|
||||||
value:any - the value to be appeneded to the array
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
the target table
|
|
||||||
]]--
|
|
||||||
function api.append(target, value)
|
|
||||||
target[#target] = value
|
|
||||||
return target
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@@ -77,10 +78,10 @@ end
|
|||||||
Returns:
|
Returns:
|
||||||
the target table
|
the target table
|
||||||
]]--
|
]]--
|
||||||
function api.merge(target, ...)
|
function private.merge(target, ...)
|
||||||
target = target or nil
|
target = target or nil
|
||||||
|
|
||||||
for _, source in ipairs(arg) do
|
for _, source in ipairs({...}) do
|
||||||
for key, value in pairs(source) do
|
for key, value in pairs(source) do
|
||||||
target[key] = value
|
target[key] = value
|
||||||
end
|
end
|
||||||
@@ -88,3 +89,8 @@ function api.merge(target, ...)
|
|||||||
|
|
||||||
return target
|
return target
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Export ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return private.merge({}, table, private)
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
-- 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
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
-- Imports -----------------------------------------------------------------------------------------
|
-- Imports -----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
local core = _G["core"]
|
local core = _G.core
|
||||||
|
|
||||||
|
|
||||||
-- Registrations -----------------------------------------------------------------------------------
|
-- Registrations -----------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1,21 +1,12 @@
|
|||||||
-- Imports -----------------------------------------------------------------------------------------
|
-- Imports -----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
local core = _G["core"]
|
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 -----------------------------------------------------------------------------------
|
-- Registrations -----------------------------------------------------------------------------------
|
||||||
|
|
||||||
core.clear_registered_biomes()
|
core.clear_registered_biomes()
|
||||||
dofile(path.."/definitions.lua")
|
dofile(core.get_modpath("jvmi_biomes").."/definitions.lua")
|
||||||
|
|
||||||
|
|
||||||
-- Script ------------------------------------------------------------------------------------------
|
-- Script ------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1,25 +1,31 @@
|
|||||||
-- Imports -----------------------------------------------------------------------------------------
|
-- Imports -----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- Since we're in the mapgen environment, we can't count on the mod loading process. Instead, we
|
local core = _G.core
|
||||||
-- have to load everything we need from other mods manually.
|
|
||||||
|
|
||||||
local core = _G["core"]
|
local path = core.get_game_info().path
|
||||||
local api = _G["jvmi_biomes"]
|
local C = dofile(path.."/common/constants.lua")
|
||||||
|
local Region = dofile(path.."/common/region.lua")
|
||||||
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 -----------------------------------------------------------------------------------------
|
-- Private -----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
local private = {}
|
local private = {}
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Apply biomes to the given region.
|
||||||
|
|
||||||
|
This function will both update the `Region.META..BIOME` table so that each x,z column has an
|
||||||
|
assigned biome, but it will also update the data within the region to have that biome fully
|
||||||
|
applied from decorations to fill material.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
region:Region - the region currently being generated
|
||||||
|
]]--
|
||||||
|
function private.apply(region)
|
||||||
|
private.assign_biomes(region)
|
||||||
|
private.fill_surface(region)
|
||||||
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Assigns a specific biome to each position in the region.
|
Assigns a specific biome to each position in the region.
|
||||||
|
|
||||||
@@ -73,10 +79,8 @@ function private.fill_surface(region)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- API Implementations -----------------------------------------------------------------------------
|
-- Export ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
function api.apply_biomes(region)
|
return {
|
||||||
private.assign_biomes(region)
|
apply_to = private.apply
|
||||||
|
}
|
||||||
private.fill_surface(region)
|
|
||||||
end
|
|
||||||
@@ -2,3 +2,4 @@ name = jvmi_biomes
|
|||||||
title = Jules Verne's Mysterious Island / Biomes
|
title = Jules Verne's Mysterious Island / Biomes
|
||||||
description = define biomes and decoration/generation functions for them
|
description = define biomes and decoration/generation functions for them
|
||||||
author = tungstonminer
|
author = tungstonminer
|
||||||
|
depends = jvmi_nodes
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
-- Imports & Exports -------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
local core = _G["core"]
|
|
||||||
|
|
||||||
|
|
||||||
-- Script ------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
jvmi_constants = {} -- luacheck: globals jvmi_constants
|
|
||||||
local path = core.get_modpath("jvmi_constants")
|
|
||||||
dofile(path.."/api.lua")
|
|
||||||
|
|
||||||
core.log("info", "jvmi_constants loaded")
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
name = jvmi_constants
|
|
||||||
title = Jules Verne's Mysterious Island / Constants
|
|
||||||
description = defined shared values across mods
|
|
||||||
author = tungstonminer
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
-- Imports & Exports -------------------------------------------------------------------------------
|
-- Imports & Exports -------------------------------------------------------------------------------
|
||||||
|
|
||||||
local core = _G["core"]
|
local core = _G.core
|
||||||
|
|
||||||
|
|
||||||
-- Script ------------------------------------------------------------------------------------------
|
-- Script ------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
-- Imports & Exports -------------------------------------------------------------------------------
|
-- Imports & Exports -------------------------------------------------------------------------------
|
||||||
|
|
||||||
local core = _G["core"]
|
local core = _G.core
|
||||||
|
|
||||||
|
|
||||||
-- Script ------------------------------------------------------------------------------------------
|
-- Script ------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
-- Imports & Exports -------------------------------------------------------------------------------
|
-- Imports & Exports -------------------------------------------------------------------------------
|
||||||
|
|
||||||
local core = _G["core"]
|
local core = _G.core
|
||||||
|
|
||||||
|
|
||||||
-- Registrations -----------------------------------------------------------------------------------
|
-- Registrations -----------------------------------------------------------------------------------
|
||||||
|
|||||||
+45
-40
@@ -1,37 +1,34 @@
|
|||||||
-- Imports & Exports -------------------------------------------------------------------------------
|
-- Imports & Exports -------------------------------------------------------------------------------
|
||||||
|
|
||||||
local biomes = _G["jvmi_biomes"]
|
local core = _G.core
|
||||||
local core = _G["core"]
|
local vector = _G.vector
|
||||||
local math = _G["math"]
|
|
||||||
local mapgen = _G["mapgen"]
|
|
||||||
local table = _G["jvmi_table"]
|
|
||||||
local vector = _G["vector"]
|
|
||||||
|
|
||||||
-- Since this script runs inside the mapgen environment, we can't count on the jvmi_constants mod
|
local path = core.get_game_info().path
|
||||||
-- to have been loaded. Instead, we just need to load the constants manually.
|
local C = dofile(path.."/common/constants.lua")
|
||||||
local jvmi_constants_path = core.get_modpath("jvmi_constants")
|
local Region = dofile(path.."/common/region.lua")
|
||||||
dofile(jvmi_constants_path.."/constants.lua")
|
local table = dofile(path.."/common/table.lua")
|
||||||
local C = _G["jvmi_constants"]
|
|
||||||
local A = C.ALTITUDE
|
|
||||||
|
|
||||||
local Region = mapgen.Region
|
local biomes = dofile(core.get_modpath("jvmi_biomes").."/mapenv.lua")
|
||||||
|
|
||||||
|
|
||||||
-- Constants ---------------------------------------------------------------------------------------
|
-- Constants ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local A = C.ALTITUDE
|
||||||
|
local TERRAIN_TYPES = nil
|
||||||
|
local TERRAIN_TYPE_NOISE = nil
|
||||||
|
|
||||||
|
-- Common Node Content Ids -----------------------------------------------------
|
||||||
|
|
||||||
local AIR_ID = core.CONTENT_AIR
|
local AIR_ID = core.CONTENT_AIR
|
||||||
local BEDROCK_ID = core.get_content_id("jvmi_nodes:bedrock")
|
local BEDROCK_ID = core.get_content_id("jvmi_nodes:bedrock")
|
||||||
local STONE_ID = core.get_content_id("jvmi_nodes:stone")
|
local STONE_ID = core.get_content_id("jvmi_nodes:stone")
|
||||||
local WATER_ID = core.get_content_id("jvmi_nodes:water_source")
|
local WATER_ID = core.get_content_id("jvmi_nodes:water_source")
|
||||||
|
|
||||||
--[[ Create a deep clone of the shared terrain types as we need to augment the entries. ]]--
|
|
||||||
local TERRAIN_TYPES = nil
|
|
||||||
|
|
||||||
|
|
||||||
-- Private -----------------------------------------------------------------------------------------
|
-- Private -----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
local private = {
|
local private = {
|
||||||
--[[ A share object which assists in generating regions of the map. ]]--
|
--[[ A shared object which assists in generating regions of the map. ]]--
|
||||||
region = Region:new()
|
region = Region:new()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,31 +40,27 @@ local private = {
|
|||||||
written back to the same map.
|
written back to the same map.
|
||||||
]]--
|
]]--
|
||||||
function private.assign_altitudes(region)
|
function private.assign_altitudes(region)
|
||||||
local pos = vector:new()
|
local pos = vector:new(0, 0, 0)
|
||||||
|
|
||||||
region.iterate_columns(function(x, z)
|
region:iterate_columns(function(x, z)
|
||||||
local altitude = 0
|
local altitude = 0
|
||||||
pos.x, pos.y = x, z
|
pos.x, pos.y = x, z -- odd, but as required by get_2d
|
||||||
|
|
||||||
for _, blend in ipairs(region:get_meta(Region.META.TERRAIN_BLEND)) do
|
for _, blend in ipairs(region:get_meta(Region.META.TERRAIN_BLEND, x, z)) do
|
||||||
local terrain = TERRAIN_TYPES[blend.terrain_type]
|
local terrain = TERRAIN_TYPES[blend.terrain_type]
|
||||||
local contribution = blend.weight * terrain.noise:get_2d(pos)
|
local contribution = blend.weight * terrain.noise:get_2d(pos)
|
||||||
altitude = altitude + contribution
|
altitude = altitude + contribution
|
||||||
end
|
end
|
||||||
|
|
||||||
|
region:set_meta(Region.META.ALTITUDE, x, z, altitude)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
|
||||||
]]--
|
|
||||||
function private.assign_biomes(region)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Compute the combination of terrain types which contribute to each map location.
|
Compute the combination of terrain types which contribute to each map location.
|
||||||
|
|
||||||
This function uses a set of individual terrain types defined by `C.TERRAIN_TYPES`. An overall
|
This function uses a set of individual terrain types defined by `TERRAIN_TYPES`. An overall
|
||||||
terrain noise generator, `C.TERRAIN_TYPE_NOISE`, is used to determine which terrain type should
|
terrain noise generator, `TERRAIN_TYPE_NOISE`, is used to determine which terrain type should
|
||||||
appear at a given location.
|
appear at a given location.
|
||||||
|
|
||||||
To avoid abrupt lines where we shift from one terrain type to another, the `C.TERRAIN_BLEND`
|
To avoid abrupt lines where we shift from one terrain type to another, the `C.TERRAIN_BLEND`
|
||||||
@@ -76,7 +69,7 @@ end
|
|||||||
|
|
||||||
Finally, we want the map to make up an island with a smooth transition from higher-altitude
|
Finally, we want the map to make up an island with a smooth transition from higher-altitude
|
||||||
terrain in the center to deep ocean terrain at the edges. So, we modify the values from
|
terrain in the center to deep ocean terrain at the edges. So, we modify the values from
|
||||||
`C.TERRAIN_TYPE_NOISE` to force them lower and lower as you move toward `C.TERRAIN_RADIUS`. By
|
`TERRAIN_TYPE_NOISE` to force them lower and lower as you move toward `C.TERRAIN_RADIUS`. By
|
||||||
the time you reach that distance from the center of the islands, the terrain selection will be
|
the time you reach that distance from the center of the islands, the terrain selection will be
|
||||||
pinned to the lowest possible terrain type.
|
pinned to the lowest possible terrain type.
|
||||||
|
|
||||||
@@ -91,12 +84,12 @@ function private.assign_terrain_meta(region)
|
|||||||
local radius_squared = C.TERRAIN_RADIUS * C.TERRAIN_RADIUS
|
local radius_squared = C.TERRAIN_RADIUS * C.TERRAIN_RADIUS
|
||||||
local pos = { x = 0, y = 0, z = 0 }
|
local pos = { x = 0, y = 0, z = 0 }
|
||||||
|
|
||||||
region.iterate_columns(function(x, z)
|
region:iterate_columns(function(x, z)
|
||||||
local radius_weight = ((x * x) + (z * z)) / radius_squared
|
local radius_weight = ((x * x) + (z * z)) / radius_squared
|
||||||
radius_weight = math.max(0, math.min(1, 1.0 - radius_weight))
|
radius_weight = math.max(0, math.min(1, 1.0 - radius_weight))
|
||||||
|
|
||||||
pos.x, pos.y = x, z
|
pos.x, pos.y = x, z
|
||||||
local raw_index = (C.TERRAIN_TYPE_NOISE:get_2d(pos) + 2) / 2
|
local raw_index = (TERRAIN_TYPE_NOISE:get_2d(pos) + 2) / 2
|
||||||
raw_index = math.max(0, math.min(1, raw_index))
|
raw_index = math.max(0, math.min(1, raw_index))
|
||||||
raw_index = raw_index * radius_weight
|
raw_index = raw_index * radius_weight
|
||||||
|
|
||||||
@@ -120,7 +113,7 @@ function private.assign_terrain_meta(region)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
region:set_meta(Region.META_TERRAIN_BLEND, x, z, blend)
|
region:set_meta(Region.META.TERRAIN_BLEND, x, z, blend)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -132,7 +125,7 @@ end
|
|||||||
region:Region - the portion of the world currently being generated
|
region:Region - the portion of the world currently being generated
|
||||||
]]--
|
]]--
|
||||||
function private.fill_bedrock(region)
|
function private.fill_bedrock(region)
|
||||||
region.iterate_plane(A.BEDROCK, function(x, y, z)
|
region:iterate_plane(A.BEDROCK, function(x, y, z)
|
||||||
region:set_content_id(x, y, z, BEDROCK_ID)
|
region:set_content_id(x, y, z, BEDROCK_ID)
|
||||||
region:set_content_id(x, y + 1, z, STONE_ID)
|
region:set_content_id(x, y + 1, z, STONE_ID)
|
||||||
end)
|
end)
|
||||||
@@ -145,7 +138,7 @@ end
|
|||||||
region:Region - the portion of the world currently being generated
|
region:Region - the portion of the world currently being generated
|
||||||
]]--
|
]]--
|
||||||
function private.fill_ocean(region)
|
function private.fill_ocean(region)
|
||||||
region.iterate_below(A.SURFACE, function(x, y, z)
|
region:iterate_below(A.SURFACE, function(x, y, z)
|
||||||
if region:get_content_id(x, y, z) == AIR_ID then
|
if region:get_content_id(x, y, z) == AIR_ID then
|
||||||
region:set_content_id(x, y, z, WATER_ID)
|
region:set_content_id(x, y, z, WATER_ID)
|
||||||
end
|
end
|
||||||
@@ -160,7 +153,13 @@ end
|
|||||||
]]--
|
]]--
|
||||||
function private.fill_terrain(region)
|
function private.fill_terrain(region)
|
||||||
region:iterate_fill(function(x, y, z)
|
region:iterate_fill(function(x, y, z)
|
||||||
local altitude = region:get_meta(Region.META.ALTITUDE)
|
local altitude = region:get_meta(Region.META.ALTITUDE, x, z)
|
||||||
|
if type(altitude) ~= "number" then
|
||||||
|
error(
|
||||||
|
"expected altitude at ("..x..","..z..") to be a number, "..
|
||||||
|
"but was a "..type(altitude)
|
||||||
|
)
|
||||||
|
end
|
||||||
if y > altitude then return end
|
if y > altitude then return end
|
||||||
region:set_content_id(x, y, z, STONE_ID)
|
region:set_content_id(x, y, z, STONE_ID)
|
||||||
end)
|
end)
|
||||||
@@ -189,6 +188,12 @@ function private.make_noise_in_range(lowest, highest)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[ Perform any setup this module requires when it first loads. ]]--
|
||||||
|
function private.on_load()
|
||||||
|
private.prepare_terrain_table()
|
||||||
|
TERRAIN_TYPE_NOISE = core.get_value_noise(C.TERRAIN_TYPE_NOISE_PARAMS)
|
||||||
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Clone the `C.TERRAIN_TYPES` table and add pre-computed values to it.
|
Clone the `C.TERRAIN_TYPES` table and add pre-computed values to it.
|
||||||
|
|
||||||
@@ -227,7 +232,7 @@ end
|
|||||||
|
|
||||||
core.register_on_generated(function(voxels, fill_min, fill_max)
|
core.register_on_generated(function(voxels, fill_min, fill_max)
|
||||||
local region = private.region
|
local region = private.region
|
||||||
region:read(voxels, fill_min, fill_max)
|
region:read_voxels(voxels, fill_min, fill_max)
|
||||||
|
|
||||||
private.assign_terrain_meta(region)
|
private.assign_terrain_meta(region)
|
||||||
private.assign_altitudes(region)
|
private.assign_altitudes(region)
|
||||||
@@ -236,12 +241,12 @@ core.register_on_generated(function(voxels, fill_min, fill_max)
|
|||||||
private.fill_bedrock(region)
|
private.fill_bedrock(region)
|
||||||
private.fill_ocean(region)
|
private.fill_ocean(region)
|
||||||
|
|
||||||
biomes.apply_biomes(region)
|
biomes.apply_to(region)
|
||||||
|
|
||||||
region:save()
|
region:save_voxels()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
-- Script ------------------------------------------------------------------------------------------
|
-- Script ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
private.prepare_terrain_table()
|
private.on_load()
|
||||||
|
|||||||
@@ -2,4 +2,4 @@ name = jvmi_mapgen
|
|||||||
title = Jules Verne's Mysterious Island / Map Generation
|
title = Jules Verne's Mysterious Island / Map Generation
|
||||||
description = do the work of actually generating the map
|
description = do the work of actually generating the map
|
||||||
author = tungstonminer
|
author = tungstonminer
|
||||||
depends = jvmi_nodes
|
depends = jvmi_nodes, jvmi_biomes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
-- Imports & Exports -------------------------------------------------------------------------------
|
-- Imports & Exports -------------------------------------------------------------------------------
|
||||||
|
|
||||||
local core = _G["core"]
|
local core = _G.core
|
||||||
|
|
||||||
|
|
||||||
-- Constants ---------------------------------------------------------------------------------------
|
-- Constants ---------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
-- Imports & Exports -------------------------------------------------------------------------------
|
-- Imports & Exports -------------------------------------------------------------------------------
|
||||||
|
|
||||||
local core = _G["core"]
|
local core = _G.core
|
||||||
|
|
||||||
|
|
||||||
-- Script ------------------------------------------------------------------------------------------
|
-- Script ------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
-- Imports & Exports -------------------------------------------------------------------------------
|
-- Imports & Exports -------------------------------------------------------------------------------
|
||||||
|
|
||||||
local core = _G["core"]
|
local core = _G["core"]
|
||||||
local jvmi_constants = _G["jvmi_constants"]
|
|
||||||
|
|
||||||
|
|
||||||
-- Constants ---------------------------------------------------------------------------------------
|
-- Constants ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local C = dofile(core.get_game_info().path.."/common/constants.lua")
|
||||||
local S = core.get_translator("jvmi_nodes")
|
local S = core.get_translator("jvmi_nodes")
|
||||||
|
|
||||||
|
|
||||||
@@ -13,11 +13,11 @@ local S = core.get_translator("jvmi_nodes")
|
|||||||
|
|
||||||
core.register_node("jvmi_nodes:water_flowing", {
|
core.register_node("jvmi_nodes:water_flowing", {
|
||||||
description = S("Flowing Water"),
|
description = S("Flowing Water"),
|
||||||
drawtype = jvmi_constants.DRAW_TYPE.FLOWING_LIQUID,
|
drawtype = C.DRAW_TYPE.FLOWING_LIQUID,
|
||||||
tiles = {{
|
tiles = {{
|
||||||
name = "jvmi_nodes_water_flowing_animated.png",
|
name = "jvmi_nodes_water_flowing_animated.png",
|
||||||
animation = {
|
animation = {
|
||||||
type = jvmi_constants.ANIMATION_TYPE.VERTICAL_FRAMES,
|
type = C.ANIMATION_TYPE.VERTICAL_FRAMES,
|
||||||
aspect_w = 16,
|
aspect_w = 16,
|
||||||
aspect_h = 16,
|
aspect_h = 16,
|
||||||
length = 5.0,
|
length = 5.0,
|
||||||
@@ -34,12 +34,12 @@ core.register_node("jvmi_nodes:water_flowing", {
|
|||||||
buildable_to = true,
|
buildable_to = true,
|
||||||
drop = "",
|
drop = "",
|
||||||
drowning = 4,
|
drowning = 4,
|
||||||
liquidtype = jvmi_constants.LIQUID_TYPE.FLOWING,
|
liquidtype = C.LIQUID_TYPE.FLOWING,
|
||||||
liquid_alternative_flowing = "jvmi_nodes:water_flowing",
|
liquid_alternative_flowing = "jvmi_nodes:water_flowing",
|
||||||
liquid_alternative_source = "jvmi_nodes:water_source",
|
liquid_alternative_source = "jvmi_nodes:water_source",
|
||||||
liquid_viscosity = jvmi_constants.VISCOSITY.XX_FAST,
|
liquid_viscosity = C.VISCOSITY.XX_FAST,
|
||||||
liquid_range = 7,
|
liquid_range = 7,
|
||||||
waving = jvmi_constants.WAVING.LIQUID_LIKE,
|
waving = C.WAVING.LIQUID_LIKE,
|
||||||
post_effect_color = "#033C5CCC",
|
post_effect_color = "#033C5CCC",
|
||||||
groups = {},
|
groups = {},
|
||||||
})
|
})
|
||||||
@@ -47,7 +47,7 @@ core.register_node("jvmi_nodes:water_flowing", {
|
|||||||
core.register_node("jvmi_nodes:water_source", {
|
core.register_node("jvmi_nodes:water_source", {
|
||||||
description = S("Water"),
|
description = S("Water"),
|
||||||
drawtype = "liquid",
|
drawtype = "liquid",
|
||||||
waving = jvmi_constants.WAVING.LIQUID_LIKE,
|
waving = C.WAVING.LIQUID_LIKE,
|
||||||
tiles = {{
|
tiles = {{
|
||||||
name = "jvmi_nodes_water_source_animated.png",
|
name = "jvmi_nodes_water_source_animated.png",
|
||||||
animation = {
|
animation = {
|
||||||
@@ -59,7 +59,7 @@ core.register_node("jvmi_nodes:water_source", {
|
|||||||
}},
|
}},
|
||||||
sounds = { footstep = { name = "jvmi_nodes_water_footstep" } },
|
sounds = { footstep = { name = "jvmi_nodes_water_footstep" } },
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
use_texture_alpha = jvmi_constants.TEXTURE_ALPHA.BLEND,
|
use_texture_alpha = C.TEXTURE_ALPHA.BLEND,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
walkable = false,
|
walkable = false,
|
||||||
pointable = false,
|
pointable = false,
|
||||||
@@ -70,7 +70,7 @@ core.register_node("jvmi_nodes:water_source", {
|
|||||||
liquidtype = "source",
|
liquidtype = "source",
|
||||||
liquid_alternative_flowing = "jvmi_nodes:water_flowing",
|
liquid_alternative_flowing = "jvmi_nodes:water_flowing",
|
||||||
liquid_alternative_source = "jvmi_nodes:water_source",
|
liquid_alternative_source = "jvmi_nodes:water_source",
|
||||||
liquid_viscosity = jvmi_constants.VISCOSITY.XX_FAST,
|
liquid_viscosity = C.VISCOSITY.XX_FAST,
|
||||||
liquid_renewable = true,
|
liquid_renewable = true,
|
||||||
liquid_range = 7,
|
liquid_range = 7,
|
||||||
post_effect_color = "#033C5CCC",
|
post_effect_color = "#033C5CCC",
|
||||||
|
|||||||
@@ -2,4 +2,3 @@ name = jvmi_nodes
|
|||||||
title = Jules Verne's Mysterious Island / Nodes
|
title = Jules Verne's Mysterious Island / Nodes
|
||||||
description = define the nodes which make up the world
|
description = define the nodes which make up the world
|
||||||
author = tungstonminer
|
author = tungstonminer
|
||||||
depends = jvmi_constants
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
-- Imports & Exports -------------------------------------------------------------------------------
|
-- Imports & Exports -------------------------------------------------------------------------------
|
||||||
|
|
||||||
local core = _G["core"]
|
local core = _G.core
|
||||||
local dump = _G["dump"]
|
|
||||||
local C = _G["jvmi_constants"]
|
|
||||||
|
|
||||||
-- Constants ---------------------------------------------------------------------------------------
|
-- Constants ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local C = dofile(core.get_game_info().path.."/common/constants.lua")
|
||||||
|
|
||||||
local SINGLEPLAYER_PRIVS = {
|
local SINGLEPLAYER_PRIVS = {
|
||||||
debug = true,
|
debug = true,
|
||||||
fast = true,
|
fast = true,
|
||||||
@@ -91,7 +92,6 @@ function private.set_starting_pos(player_name, delays)
|
|||||||
if floor_node and node.name == "air" then
|
if floor_node and node.name == "air" then
|
||||||
local floor_def = core.registered_nodes[floor_node.name]
|
local floor_def = core.registered_nodes[floor_node.name]
|
||||||
if floor_def.walkable then
|
if floor_def.walkable then
|
||||||
core.log("info", "Moved player to "..dump(pos, ""))
|
|
||||||
player:set_pos(pos)
|
player:set_pos(pos)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,4 +2,3 @@ name = jvmi_player
|
|||||||
title = Jules Verne's Mysterious Island / Player
|
title = Jules Verne's Mysterious Island / Player
|
||||||
description = configuring the player and his abilities
|
description = configuring the player and his abilities
|
||||||
author = tungstonminer
|
author = tungstonminer
|
||||||
depends = jvmi_constants
|
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
-- Imports -----------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
local core = _G["core"]
|
|
||||||
|
|
||||||
|
|
||||||
-- Public ------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
jvmi_table = {} -- luacheck: globals jvmi_table
|
|
||||||
local path = core.get_modpath("jvmi_table")
|
|
||||||
dofile(path.."/api.lua")
|
|
||||||
|
|
||||||
|
|
||||||
-- Script ------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
core.log("info", "jvmi_tables ready")
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
name = jvmi_table
|
|
||||||
title = Jules Verne's Mysterious Island / Table
|
|
||||||
description = helpers for table manipulation
|
|
||||||
author = tungstonminer
|
|
||||||
Reference in New Issue
Block a user