forked from mad-star-studio/Voxelis
More work being done. And... bugs.
This commit is contained in:
parent
0242488c9e
commit
a260c4a33a
20 changed files with 1102 additions and 80 deletions
152
mods/ITEMS/vox_coloring/README.md
Normal file
152
mods/ITEMS/vox_coloring/README.md
Normal file
|
@ -0,0 +1,152 @@
|
|||
# Vox Coloring Mod
|
||||
|
||||
The `vox_coloring` mod is a dynamic and robust system for adding colorable items, blocks, and decorations to your Minetest game. It enables automatic registration of dyeable variants, recipes for applying and removing dyes, and integration with other mods.
|
||||
|
||||
---
|
||||
|
||||
## Features
|
||||
|
||||
- **Dynamic Dye Registration**:
|
||||
- Automatically generates colorable variants of nodes and items.
|
||||
- Uses a neutral "template" texture for consistent colorization.
|
||||
|
||||
- **Custom Recipes**:
|
||||
- Recipes for dyeing nodes and items.
|
||||
- Recipes for reverting dyed objects to their original state.
|
||||
|
||||
- **Spraygun Tool**:
|
||||
- Dye objects directly in the world with a spraygun.
|
||||
|
||||
- **Cleaning Station**:
|
||||
- Revert dyed objects in bulk using the cleaning station.
|
||||
|
||||
- **Mod Integration**:
|
||||
- Other mods can easily register their own dyeable items.
|
||||
|
||||
---
|
||||
|
||||
## How to Use
|
||||
|
||||
### Registering Dyeable Items/Blocks
|
||||
|
||||
To register a dyeable item or block, call the `register_dyeable` function in your mod:
|
||||
|
||||
```lua
|
||||
-- List of dyeable things
|
||||
local dyeable_blocks = {"sand", "terracotta", "marble", "cobblestone", "sandstone"}
|
||||
|
||||
-- Register base things their dyeable variants
|
||||
for _, base_block in ipairs(dyeable_blocks) do
|
||||
vox_coloring.register_dyeable("vox_worldblocks", base_block)
|
||||
end
|
||||
```
|
||||
|
||||
Parameters:
|
||||
|
||||
```plaintext
|
||||
modname: The name of your mod (e.g., vox_worldblocks).
|
||||
base_item: The name of the base item/block to make dyeable.
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```lua
|
||||
vox_coloring.register_dyeable("vox_worldblocks", "sand")
|
||||
```
|
||||
|
||||
### Objects Added
|
||||
|
||||
#### Cleaning Solvent
|
||||
|
||||
```plaintext
|
||||
Soap | Bucket of Water | Salt
|
||||
Ash
|
||||
```
|
||||
|
||||
#### Cleaning Station
|
||||
|
||||
```plaintext
|
||||
Iron Ingot | Bucket of Water | Iron Ingot
|
||||
Stone | Soap | Stone
|
||||
Stone | Empty | Stone
|
||||
```
|
||||
|
||||
Our recipe expects these to exist, but you can edit things to suit your game.
|
||||
|
||||
```lua
|
||||
-- Ash
|
||||
minetest.register_craftitem("vox_mats:ash", {
|
||||
description = "Ash",
|
||||
inventory_image = "ash.png",
|
||||
groups = {crumbly = 3},
|
||||
})
|
||||
|
||||
-- Salt
|
||||
minetest.register_craftitem("vox_mats:salt", {
|
||||
description = "Salt",
|
||||
inventory_image = "salt.png",
|
||||
})
|
||||
|
||||
-- Lye
|
||||
minetest.register_craftitem("vox_mats:lye", {
|
||||
description = "Lye",
|
||||
inventory_image = "lye.png",
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "vox_mats:lye",
|
||||
recipe = {
|
||||
{"vox_mats:ash", "bucket:water_bucket"},
|
||||
},
|
||||
replacements = {{"bucket:water_bucket", "bucket:bucket"}},
|
||||
})
|
||||
|
||||
-- Soap
|
||||
minetest.register_craftitem("vox_mats:soap", {
|
||||
description = "Soap",
|
||||
inventory_image = "soap.png",
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "vox_mats:soap",
|
||||
recipe = {
|
||||
{"vox_mobdrops:fat", "vox_mats:lye", "vox_mats:salt"},
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
We also expect colors to be registered somewhere. Our personal example:
|
||||
Not full file, but vox_colors contains this part vox_coloring needs...
|
||||
|
||||
```lua
|
||||
vox_colors = {
|
||||
WHITE = "#FFFFFF",
|
||||
LIGHTGREY = "#D3D3D3",
|
||||
SILVER = "#C0C0C0",
|
||||
GREY = "#808080",
|
||||
BLACK = "#000000",
|
||||
RED = "#FF0000",
|
||||
DARK_RED = "#8B0000",
|
||||
YELLOW = "#FFFF00",
|
||||
GOLD = "#FFD700",
|
||||
ORANGE = "#FFA500",
|
||||
PUMPKIN = "#FF7518",
|
||||
CREAM = "#FFFDD0",
|
||||
TAN = "#D2B48C",
|
||||
BROWN = "#A52A2A",
|
||||
DARK_BROWN = "#8B4513",
|
||||
LIME = "#00FF00",
|
||||
MINT = "#98FF98",
|
||||
EMERALD = "#50C878",
|
||||
DARK_GREEN = "#006400",
|
||||
TURQUOISE = "#40E0D0",
|
||||
TEAL = "#008080",
|
||||
CYAN = "#00FFFF",
|
||||
BLUE = "#0000FF",
|
||||
NAVY = "#000080",
|
||||
MAGENTA = "#FF00FF",
|
||||
VIOLET = "#EE82EE",
|
||||
PURPLE = "#800080",
|
||||
INDIGO = "#4B0082",
|
||||
PINK = "#FF69B4",
|
||||
FLAMINGO = "#FC8EAC",
|
||||
}
|
||||
```
|
212
mods/ITEMS/vox_coloring/init.lua
Normal file
212
mods/ITEMS/vox_coloring/init.lua
Normal file
|
@ -0,0 +1,212 @@
|
|||
-- Vox Coloring System
|
||||
|
||||
-- Register dyes dynamically based on vox_colors
|
||||
for color_name, color_hex in pairs(vox_colors) do
|
||||
if type(color_hex) == "string" and vox_colors.validate(color_hex) then
|
||||
minetest.register_craftitem("vox_coloring:dye_" .. color_name:lower(), {
|
||||
description = color_name .. " Dye",
|
||||
inventory_image = "dye_template.png^[multiply:" .. color_hex,
|
||||
groups = {dye = 1},
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- Table to hold registered dyeable items
|
||||
local dyeable_registry = {}
|
||||
|
||||
-- Function for other mods to register colorable items or blocks
|
||||
function vox_coloring.register_dyeable(modname, base_item)
|
||||
dyeable_registry[modname] = dyeable_registry[modname] or {}
|
||||
table.insert(dyeable_registry[modname], base_item)
|
||||
|
||||
-- Get the original node definition
|
||||
local base_item_full = modname .. ":" .. base_item
|
||||
local base_def = minetest.registered_nodes[base_item_full]
|
||||
|
||||
if not base_def then
|
||||
minetest.log("error", "[vox_coloring] Failed to register dyeable item: " .. base_item_full .. " does not exist.")
|
||||
return
|
||||
end
|
||||
|
||||
-- Derive the template texture by appending `_colorize` to the base texture filename
|
||||
local base_texture = base_def.tiles and base_def.tiles[1]
|
||||
if not base_texture then
|
||||
minetest.log("error", "[vox_coloring] No texture found for " .. base_item_full)
|
||||
return
|
||||
end
|
||||
local colorize_texture = base_texture:gsub("%.png$", "_colorize.png")
|
||||
|
||||
-- Iterate over all colors and register dyeable variants
|
||||
for color_name, color_hex in pairs(vox_colors) do
|
||||
if type(color_hex) == "string" then
|
||||
local colored_item = modname .. ":" .. base_item .. "_" .. color_name:lower()
|
||||
|
||||
-- Register the colored version of the item/block
|
||||
minetest.register_node(colored_item, {
|
||||
description = base_def.description .. " (" .. color_name .. ")",
|
||||
tiles = {colorize_texture .. "^[multiply:" .. color_hex},
|
||||
groups = base_def.groups or {},
|
||||
})
|
||||
|
||||
-- Register recipe to dye the item/block
|
||||
minetest.register_craft({
|
||||
output = colored_item,
|
||||
recipe = {
|
||||
{base_item_full, "vox_coloring:dye_" .. color_name:lower()},
|
||||
},
|
||||
})
|
||||
|
||||
-- Register recipe to undye the item/block
|
||||
minetest.register_craft({
|
||||
output = base_item_full,
|
||||
recipe = {
|
||||
{colored_item, "vox_coloring:cleaning_solvent"},
|
||||
},
|
||||
replacements = {{"vox_coloring:cleaning_solvent", "bucket:bucket"}},
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Function to unregister a dyeable item or block
|
||||
function vox_coloring.unregister_dyeable(modname, base_item)
|
||||
if not dyeable_registry[modname] then return end
|
||||
for i, item in ipairs(dyeable_registry[modname]) do
|
||||
if item == base_item then
|
||||
table.remove(dyeable_registry[modname], i)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- Remove all colored variants and recipes
|
||||
for color_name, _ in pairs(vox_colors) do
|
||||
local colored_item = modname .. ":" .. base_item .. "_" .. color_name:lower()
|
||||
minetest.unregister_item(colored_item)
|
||||
end
|
||||
end
|
||||
|
||||
-- Spraygun Tool
|
||||
minetest.register_tool("vox_coloring:spraygun", {
|
||||
description = "Spraygun",
|
||||
inventory_image = "spraygun.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if pointed_thing.type == "node" then
|
||||
local node = minetest.get_node(pointed_thing.under)
|
||||
local meta = itemstack:get_meta()
|
||||
local dye_color = meta:get_string("dye_color")
|
||||
|
||||
if dye_color and vox_colors[dye_color:upper()] then
|
||||
local modname, item_base = node.name:match("^(.-):(.*)")
|
||||
if modname and item_base then
|
||||
local colored_item = modname .. ":" .. item_base .. "_" .. dye_color:lower()
|
||||
if minetest.registered_nodes[colored_item] then
|
||||
minetest.swap_node(pointed_thing.under, {name = colored_item})
|
||||
itemstack:add_wear(65535 / 100) -- Simulate durability loss
|
||||
minetest.chat_send_player(user:get_player_name(), "Dyed with " .. dye_color .. "!")
|
||||
else
|
||||
minetest.chat_send_player(user:get_player_name(), "Cannot dye this object.")
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(user:get_player_name(), "No valid target for dye.")
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(user:get_player_name(), "No valid dye loaded in the spraygun.")
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
-- Add dye to the spraygun
|
||||
minetest.register_craftitem("vox_coloring:dye_cartridge", {
|
||||
description = "Dye Cartridge",
|
||||
inventory_image = "dye_cartridge.png",
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
local wielded = user:get_wielded_item()
|
||||
if wielded:get_name() == "vox_coloring:spraygun" then
|
||||
local meta = wielded:get_meta()
|
||||
local dye_color = itemstack:get_name():match("vox_coloring:dye_(%w+)")
|
||||
if dye_color then
|
||||
meta:set_string("dye_color", dye_color)
|
||||
minetest.chat_send_player(user:get_player_name(), "Spraygun loaded with " .. dye_color .. " dye!")
|
||||
return itemstack:take_item()
|
||||
else
|
||||
minetest.chat_send_player(user:get_player_name(), "Failed to load dye into the spraygun.")
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
-- Cleaning Solvent
|
||||
minetest.register_craftitem("vox_coloring:cleaning_solvent", {
|
||||
description = "Cleaning Solvent",
|
||||
inventory_image = "cleaning_solvent.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if pointed_thing.type == "node" then
|
||||
local node = minetest.get_node(pointed_thing.under)
|
||||
local modname, item_base = node.name:match("^(.-):(.*)")
|
||||
if modname and item_base then
|
||||
local base_item = item_base:match("^(.-)_")
|
||||
if base_item then
|
||||
local original_item = modname .. ":" .. base_item
|
||||
if minetest.registered_nodes[original_item] then
|
||||
minetest.swap_node(pointed_thing.under, {name = original_item})
|
||||
itemstack:take_item()
|
||||
minetest.chat_send_player(user:get_player_name(), "Reverted to original state.")
|
||||
else
|
||||
minetest.chat_send_player(user:get_player_name(), "This block cannot be cleaned.")
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(user:get_player_name(), "No dye detected on this block.")
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(user:get_player_name(), "No dye detected on this block.")
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
-- Recipe for Cleaning Solvent
|
||||
minetest.register_craft({
|
||||
output = "vox_coloring:cleaning_solvent",
|
||||
recipe = {
|
||||
{"vox_mats:soap", "bucket:water_bucket", "vox_mats:salt"},
|
||||
{"vox_mats:ash", "", ""},
|
||||
},
|
||||
replacements = {{"bucket:water_bucket", "bucket:bucket"}},
|
||||
})
|
||||
|
||||
-- Cleaning Station
|
||||
minetest.register_node("vox_coloring:cleaning_station", {
|
||||
description = "Cleaning Station",
|
||||
tiles = {"cleaning_station_top.png", "cleaning_station_side.png"},
|
||||
groups = {cracky = 2},
|
||||
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
||||
local inv = player:get_inventory()
|
||||
if inv:contains_item("main", "vox_coloring:cleaning_solvent") then
|
||||
local node_name = minetest.get_node(pointed_thing.under).name
|
||||
local modname, item_base = node_name:match("^(.-):(.*)")
|
||||
if modname and item_base then
|
||||
local base_item = item_base:match("^(.-)_")
|
||||
if base_item then
|
||||
local original_item = modname .. ":" .. base_item
|
||||
if minetest.registered_nodes[original_item] then
|
||||
minetest.swap_node(pointed_thing.under, {name = original_item})
|
||||
inv:remove_item("main", "vox_coloring:cleaning_solvent")
|
||||
minetest.chat_send_player(player:get_player_name(), "Reverted to original state.")
|
||||
else
|
||||
minetest.chat_send_player(player:get_player_name(), "This block cannot be cleaned.")
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(player:get_player_name(), "No dye detected on this block.")
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(player:get_player_name(), "No dye detected on this block.")
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(player:get_player_name(), "You need cleaning solvent to clean blocks.")
|
||||
end
|
||||
end,
|
||||
})
|
2
mods/ITEMS/vox_coloring/mod.conf
Normal file
2
mods/ITEMS/vox_coloring/mod.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
name = vox_coloring
|
||||
description = Voxelis - coloring. Adds dynamic dyes, dynamically adds dyed (fill in the blanks) from mods that call upon the function, adds other things that are helpful.
|
0
mods/ITEMS/vox_fabric/init.lua
Normal file
0
mods/ITEMS/vox_fabric/init.lua
Normal file
2
mods/ITEMS/vox_fabric/mod.conf
Normal file
2
mods/ITEMS/vox_fabric/mod.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
name = vox_fabric
|
||||
description = Voxelis - Fabric. Allow players to use premade patterns (which can be dyed with vox_coloring), or allow them to make their own.
|
37
mods/ITEMS/vox_mats/init.lua
Normal file
37
mods/ITEMS/vox_mats/init.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
-- Ash
|
||||
minetest.register_craftitem("vox_mats:ash", {
|
||||
description = "Ash",
|
||||
inventory_image = "ash.png",
|
||||
groups = {crumbly = 3},
|
||||
})
|
||||
|
||||
-- Salt
|
||||
minetest.register_craftitem("vox_mats:salt", {
|
||||
description = "Salt",
|
||||
inventory_image = "salt.png",
|
||||
})
|
||||
|
||||
-- Lye
|
||||
minetest.register_craftitem("vox_mats:lye", {
|
||||
description = "Lye",
|
||||
inventory_image = "lye.png",
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "vox_mats:lye",
|
||||
recipe = {
|
||||
{"vox_mats:ash", "bucket:water_bucket"},
|
||||
},
|
||||
replacements = {{"bucket:water_bucket", "bucket:bucket"}},
|
||||
})
|
||||
|
||||
-- Soap
|
||||
minetest.register_craftitem("vox_mats:soap", {
|
||||
description = "Soap",
|
||||
inventory_image = "soap.png",
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "vox_mats:soap",
|
||||
recipe = {
|
||||
{"vox_mobdrops:fat", "vox_mats:lye", "vox_mats:salt"},
|
||||
},
|
||||
})
|
2
mods/ITEMS/vox_mats/mod.conf
Normal file
2
mods/ITEMS/vox_mats/mod.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
name = vox_mats
|
||||
description = Voxelis - mats. in general maps that dont need to be categorized (yet)
|
15
mods/ITEMS/vox_mobdrops/init.lua
Normal file
15
mods/ITEMS/vox_mobdrops/init.lua
Normal file
|
@ -0,0 +1,15 @@
|
|||
-- Fat
|
||||
minetest.register_craftitem("vox_mobdrops:fat", {
|
||||
description = "Fat",
|
||||
inventory_image = "fat.png",
|
||||
})
|
||||
-- Add fat drops from mobs
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
local inventory = player:get_inventory()
|
||||
if math.random(1, 5) == 1 then
|
||||
inventory:add_item("main", "vox_mobdrops:fat")
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
-- Leather
|
2
mods/ITEMS/vox_mobdrops/mod.conf
Normal file
2
mods/ITEMS/vox_mobdrops/mod.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
name = vox_mobdrops
|
||||
description = Voxelis - mob drops
|
0
mods/ITEMS/vox_structural/README.md
Normal file
0
mods/ITEMS/vox_structural/README.md
Normal file
110
mods/ITEMS/vox_structural/init.lua
Normal file
110
mods/ITEMS/vox_structural/init.lua
Normal file
|
@ -0,0 +1,110 @@
|
|||
-- Vox Structural System
|
||||
|
||||
local structural_shapes = {}
|
||||
|
||||
-- Register a new structural shape
|
||||
function vox_structural.register_shape(shape_name, shape_def)
|
||||
structural_shapes[shape_name] = shape_def
|
||||
end
|
||||
|
||||
-- Register a block with structural shapes
|
||||
function vox_structural.register_block_with_shapes(modname, base_block, options)
|
||||
for shape_name, shape_def in pairs(structural_shapes) do
|
||||
local base_node_name = modname .. ":" .. base_block
|
||||
local shape_node_name = modname .. ":" .. base_block .. "_" .. shape_name
|
||||
|
||||
-- Create the new node definition
|
||||
local new_node_def = table.copy(minetest.registered_nodes[base_node_name])
|
||||
new_node_def.description = new_node_def.description .. " (" .. shape_name:gsub("_", " ") .. ")"
|
||||
new_node_def.tiles = shape_def.tiles or new_node_def.tiles
|
||||
new_node_def.groups = table.copy(new_node_def.groups or {})
|
||||
new_node_def.groups.shape = 1 -- Add a "shape" group
|
||||
|
||||
-- Apply shape-specific overrides
|
||||
if shape_def.override then
|
||||
for key, value in pairs(shape_def.override) do
|
||||
new_node_def[key] = value
|
||||
end
|
||||
end
|
||||
|
||||
-- Register the new node
|
||||
minetest.register_node(shape_node_name, new_node_def)
|
||||
end
|
||||
end
|
||||
|
||||
-- ---------------------------- Basic Shapes -------------------------- --
|
||||
-- Slab
|
||||
vox_structural.register_shape("slab", {
|
||||
tiles = nil, -- Inherit tiles from the base block
|
||||
override = {
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Stairs
|
||||
vox_structural.register_shape("stairs", {
|
||||
tiles = nil,
|
||||
override = {
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||
{-0.5, 0, -0.5, 0.5, 0.5, 0},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- ---------------------------- Functional -------------------------- --
|
||||
-- Pressure Plate
|
||||
vox_structural.register_shape("pressure_plate", {
|
||||
tiles = nil,
|
||||
override = {
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Button
|
||||
|
||||
-- Post
|
||||
|
||||
|
||||
-- ------------------
|
||||
-- Register door shapes with variants
|
||||
vox_structural.register_shape("door_flush", {
|
||||
override = {
|
||||
drawtype = "mesh",
|
||||
mesh = "door_flush.obj",
|
||||
},
|
||||
})
|
||||
|
||||
vox_structural.register_shape("door_half_window", {
|
||||
override = {
|
||||
drawtype = "mesh",
|
||||
mesh = "door_half_window.obj",
|
||||
},
|
||||
})
|
||||
|
||||
-- Add mix-and-match for window materials
|
||||
local window_variants = {"glass", "colored_glass", "paper", "colored_paper"}
|
||||
|
||||
for _, material in ipairs(window_variants) do
|
||||
vox_structural.register_shape("door_half_window_" .. material, {
|
||||
override = {
|
||||
drawtype = "mesh",
|
||||
mesh = "door_half_window.obj",
|
||||
tiles = {"window_" .. material .. ".png"},
|
||||
},
|
||||
})
|
||||
end
|
2
mods/ITEMS/vox_structural/mod.conf
Normal file
2
mods/ITEMS/vox_structural/mod.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
name = vox_structural
|
||||
description = Voxelis - structural. Adds dynamic structure pieces and assign textures to them.
|
20
mods/ITEMS/vox_textiles/init.lua
Normal file
20
mods/ITEMS/vox_textiles/init.lua
Normal file
|
@ -0,0 +1,20 @@
|
|||
-- ---------------------------- Dyeable Nodes -------------------------- --
|
||||
-- List of dyeable things
|
||||
local dyeable_blocks = {"wool, carpet"}
|
||||
|
||||
-- Register base things their dyeable variants
|
||||
for _, base_block in ipairs(dyeable_blocks) do
|
||||
vox_coloring.register_dyeable("vox_worldblocks", base_block)
|
||||
end
|
||||
|
||||
-- ---------------------------- Basics -------------------------- --
|
||||
-- "We've got wool and wool accessories.
|
||||
|
||||
-- String
|
||||
|
||||
|
||||
-- Wool
|
||||
|
||||
|
||||
-- Carpet
|
||||
-- These are made from wool or from fabric
|
|
@ -45,15 +45,6 @@ core.register_node("vox_worldblocks:sand", {
|
|||
core.register_alias("sand", "vox_worldblocks:sand")
|
||||
core.register_alias("default:sand", "vox_worldblocks:sand")
|
||||
|
||||
-- Desert Sand
|
||||
core.register_node("vox_worldblocks:desert_sand", {
|
||||
description = "Desert Sand",
|
||||
tiles = {"vox_desert_sand.png"},
|
||||
groups = {crumbly = 3}
|
||||
})
|
||||
core.register_alias("desert_sand", "vox_worldblocks:desert_sand")
|
||||
core.register_alias("default:desert_sand", "vox_worldblocks:desert_sand")
|
||||
|
||||
-- Snow
|
||||
core.register_node("vox_worldblocks:snow", {
|
||||
description = "Snow",
|
||||
|
@ -63,6 +54,14 @@ core.register_node("vox_worldblocks:snow", {
|
|||
core.register_alias("snow", "vox_worldblocks:snow")
|
||||
core.register_alias("default:snow", "vox_worldblocks:snow")
|
||||
|
||||
-- Packed Snow
|
||||
core.register_node("vox_worldblocks:packed_snow", {
|
||||
description = "Packed Snow",
|
||||
tiles = {"vox_packed_snow.png"},
|
||||
groups = {crumbly = 2}
|
||||
})
|
||||
core.register_alias("packed_snow", "vox_worldblocks:packed_snow")
|
||||
|
||||
-- Ice
|
||||
core.register_node("vox_worldblocks:ice", {
|
||||
description = "Ice",
|
||||
|
@ -72,6 +71,14 @@ core.register_node("vox_worldblocks:ice", {
|
|||
core.register_alias("ice", "vox_worldblocks:ice")
|
||||
core.register_alias("default:ice", "vox_worldblocks:ice")
|
||||
|
||||
-- Sulfur Crust
|
||||
core.register_node("vox_worldblocks:sulfur_crust", {
|
||||
description = "Sulfur Crust",
|
||||
tiles = {"vox_sulfur_crust.png"},
|
||||
groups = {crumbly = 3}
|
||||
})
|
||||
core.register_alias("sulfur_crust", "vox_worldblocks:sulfur_crust")
|
||||
|
||||
-- ---------------------------- Terrain Subsurface --------------------------- --
|
||||
|
||||
-- Bedrock
|
||||
|
@ -83,6 +90,14 @@ core.register_node("vox_worldblocks:bedrock", {
|
|||
core.register_alias("bedrock", "vox_worldblocks:bedrock")
|
||||
core.register_alias("default:bedrock", "vox_worldblocks:bedrock")
|
||||
|
||||
-- Ash
|
||||
minetest.register_node("vox_worldblocks:ash_block", {
|
||||
description = "Ash Block",
|
||||
tiles = {"vox_ash_block.png"},
|
||||
groups = {crumbly = 3},
|
||||
drop = "vox_mats:ash", -- Drops ash when broken
|
||||
})
|
||||
|
||||
-- Gravel
|
||||
core.register_node("vox_worldblocks:gravel", {
|
||||
description = "Gravel",
|
||||
|
@ -120,15 +135,6 @@ core.register_node("vox_worldblocks:sandstone", {
|
|||
core.register_alias("sandstone", "vox_worldblocks:sandstone")
|
||||
core.register_alias("default:sandstone", "vox_worldblocks:sandstone")
|
||||
|
||||
-- Red Sandstone
|
||||
core.register_node("vox_worldblocks:red_sandstone", {
|
||||
description = "Red Sandstone",
|
||||
tiles = {"vox_red_sandstone.png"},
|
||||
groups = {cracky = 2}
|
||||
})
|
||||
core.register_alias("red_sandstone", "vox_worldblocks:red_sandstone")
|
||||
core.register_alias("default:red_sandstone", "vox_worldblocks:red_sandstone")
|
||||
|
||||
-- Clay
|
||||
core.register_node("vox_worldblocks:clay", {
|
||||
description = "Clay",
|
||||
|
@ -155,7 +161,7 @@ core.register_node("vox_worldblocks:mud", {
|
|||
})
|
||||
core.register_alias("mud", "vox_worldblocks:mud")
|
||||
|
||||
-- More stone types: Granite, Diorite, Andesite, Basalt, Obsidian, Marble, Chalk, Limestone, Shale, Slate, Gneiss, Schist, Soapstone, Tuff, Pumice
|
||||
-- Granite
|
||||
core.register_node("vox_worldblocks:granite", {
|
||||
description = "Granite",
|
||||
tiles = {"vox_granite.png"},
|
||||
|
@ -164,6 +170,7 @@ core.register_node("vox_worldblocks:granite", {
|
|||
core.register_alias("granite", "vox_worldblocks:granite")
|
||||
core.register_alias("default:granite", "vox_worldblocks:granite")
|
||||
|
||||
-- Diorite
|
||||
core.register_node("vox_worldblocks:diorite", {
|
||||
description = "Diorite",
|
||||
tiles = {"vox_diorite.png"},
|
||||
|
@ -172,6 +179,7 @@ core.register_node("vox_worldblocks:diorite", {
|
|||
core.register_alias("diorite", "vox_worldblocks:diorite")
|
||||
core.register_alias("default:diorite", "vox_worldblocks:diorite")
|
||||
|
||||
-- Andesite
|
||||
core.register_node("vox_worldblocks:andesite", {
|
||||
description = "Andesite",
|
||||
tiles = {"vox_andesite.png"},
|
||||
|
@ -180,6 +188,7 @@ core.register_node("vox_worldblocks:andesite", {
|
|||
core.register_alias("andesite", "vox_worldblocks:andesite")
|
||||
core.register_alias("default:andesite", "vox_worldblocks:andesite")
|
||||
|
||||
-- Basalt
|
||||
core.register_node("vox_worldblocks:basalt", {
|
||||
description = "Basalt",
|
||||
tiles = {"vox_basalt.png"},
|
||||
|
@ -188,6 +197,7 @@ core.register_node("vox_worldblocks:basalt", {
|
|||
core.register_alias("basalt", "vox_worldblocks:basalt")
|
||||
core.register_alias("default:basalt", "vox_worldblocks:basalt")
|
||||
|
||||
-- Obsidian
|
||||
core.register_node("vox_worldblocks:obsidian", {
|
||||
description = "Obsidian",
|
||||
tiles = {"vox_obsidian.png"},
|
||||
|
@ -196,6 +206,7 @@ core.register_node("vox_worldblocks:obsidian", {
|
|||
core.register_alias("obsidian", "vox_worldblocks:obsidian")
|
||||
core.register_alias("default:obsidian", "vox_worldblocks:obsidian")
|
||||
|
||||
-- Marble
|
||||
core.register_node("vox_worldblocks:marble", {
|
||||
description = "Marble",
|
||||
tiles = {"vox_marble.png"},
|
||||
|
@ -204,6 +215,7 @@ core.register_node("vox_worldblocks:marble", {
|
|||
core.register_alias("marble", "vox_worldblocks:marble")
|
||||
core.register_alias("default:marble", "vox_worldblocks:marble")
|
||||
|
||||
-- Chalk
|
||||
core.register_node("vox_worldblocks:chalk", {
|
||||
description = "Chalk",
|
||||
tiles = {"vox_chalk.png"},
|
||||
|
@ -212,6 +224,7 @@ core.register_node("vox_worldblocks:chalk", {
|
|||
core.register_alias("chalk", "vox_worldblocks:chalk")
|
||||
core.register_alias("default:chalk", "vox_worldblocks:chalk")
|
||||
|
||||
-- Limestone
|
||||
core.register_node("vox_worldblocks:limestone", {
|
||||
description = "Limestone",
|
||||
tiles = {"vox_limestone.png"},
|
||||
|
@ -220,6 +233,56 @@ core.register_node("vox_worldblocks:limestone", {
|
|||
core.register_alias("limestone", "vox_worldblocks:limestone")
|
||||
core.register_alias("default:limestone", "vox_worldblocks:limestone")
|
||||
|
||||
-- Glowing Moss
|
||||
core.register_node("vox_worldblocks:glowing_moss", {
|
||||
description = "Glowing Moss",
|
||||
tiles = {"vox_glowing_moss.png"},
|
||||
light_source = 8,
|
||||
groups = {crumbly = 1}
|
||||
})
|
||||
core.register_alias("glowing_moss", "vox_worldblocks:glowing_moss")
|
||||
|
||||
core.register_node("vox_worldblocks:salt_crystal", {
|
||||
description = "Salt Crystal",
|
||||
tiles = {"vox_salt_crystal.png"},
|
||||
groups = {cracky = 2}
|
||||
})
|
||||
core.register_alias("salt_crystal", "vox_worldblocks:salt_crystal")
|
||||
|
||||
core.register_node("vox_worldblocks:volcanic_rock", {
|
||||
description = "Volcanic Rock",
|
||||
tiles = {"vox_volcanic_rock.png"},
|
||||
groups = {cracky = 3}
|
||||
})
|
||||
core.register_alias("volcanic_rock", "vox_worldblocks:volcanic_rock")
|
||||
|
||||
core.register_node("vox_worldblocks:hot_spring_stone", {
|
||||
description = "Hot Spring Stone",
|
||||
tiles = {"vox_hot_spring_stone.png"},
|
||||
groups = {cracky = 2}
|
||||
})
|
||||
core.register_alias("hot_spring_stone", "vox_worldblocks:hot_spring_stone")
|
||||
|
||||
-- ------------------------------ Ocean ------------------------- --
|
||||
--
|
||||
core.register_node("vox_worldblocks:coral_red", {
|
||||
description = "Red Coral",
|
||||
tiles = {"vox_coral_red.png"},
|
||||
groups = {crumbly = 1}
|
||||
})
|
||||
core.register_alias("coral_red", "vox_worldblocks:coral_red")
|
||||
|
||||
|
||||
-- ------------------------------ Sky Island ------------------------- --
|
||||
-- Cloud Block - Only pegasus can walk on it :)
|
||||
-- Players may stand on it, but sink partway through. If multiple blocks are
|
||||
-- stacked, you fall to the lowest block and still don't fall through.
|
||||
core.register_node("vox_worldblocks:cloud", {
|
||||
description = "Cloud",
|
||||
tiles = {"vox_cloud.png"},
|
||||
groups = {crumbly = 1}
|
||||
})
|
||||
core.register_alias("cloud", "vox_worldblocks:cloud")
|
||||
|
||||
-- -------------------------------------------------------------------------- --
|
||||
-- Liquids --
|
||||
|
@ -289,6 +352,67 @@ core.register_alias("water_flowing", "vox_worldblocks:water_flowing")
|
|||
core.register_alias("default:river_water_flowing", "vox_worldblocks:water_flowing")
|
||||
core.register_alias("mapgen_water_flowing", "vox_worldblocks:water_flowing")
|
||||
|
||||
-- Hotspring Water
|
||||
core.register_node("vox_worldblocks:hotspring_water_source", {
|
||||
description = "Hotspring Water Source",
|
||||
drawtype = "liquid",
|
||||
tiles = {
|
||||
{
|
||||
name = "vox_hotspring_water.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 2.0
|
||||
}
|
||||
}
|
||||
},
|
||||
alpha = 128,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
liquidtype = "source",
|
||||
liquid_alternative_flowing = "vox_worldblocks:hotspring_water_flowing",
|
||||
liquid_alternative_source = "vox_worldblocks:hotspring_water_source",
|
||||
liquid_viscosity = 1,
|
||||
post_effect_color = {a = 103, r = 30, g = 60, b = 90}
|
||||
})
|
||||
core.register_alias("hotspring_water_source", "vox_worldblocks:hotspring_water_source")
|
||||
core.register_alias("mapgen_hotspring_water_source", "vox_worldblocks:hotspring_water_source")
|
||||
|
||||
core.register_node("vox_worldblocks:hotspring_water_flowing", {
|
||||
description = "Flowing Hotspring Water",
|
||||
drawtype = "flowingliquid",
|
||||
tiles = {"vox_hotspring_water.png"},
|
||||
special_tiles = {
|
||||
{
|
||||
name = "vox_hotspring_water.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 0.8
|
||||
}
|
||||
}
|
||||
},
|
||||
alpha = 160,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
liquidtype = "flowing",
|
||||
liquid_alternative_flowing = "vox_worldblocks:hotspring_water_flowing",
|
||||
liquid_alternative_source = "vox_worldblocks:hotspring_water_source",
|
||||
liquid_viscosity = 1,
|
||||
post_effect_color = {a = 103, r = 30, g = 60, b = 90}
|
||||
})
|
||||
core.register_alias("hotspring_water_flowing", "vox_worldblocks:hotspring_water_flowing")
|
||||
core.register_alias("mapgen_hotspring_water_flowing", "vox_worldblocks:hotspring_water_flowing")
|
||||
|
||||
-- Lava
|
||||
core.register_node("vox_worldblocks:lava_source", {
|
||||
description = "Lava Source",
|
||||
|
@ -357,7 +481,7 @@ core.register_alias("mapgen_lava_flowing", "vox_worldblocks:lava_flowing")
|
|||
-- -------------------------------------------------------------------------- --
|
||||
|
||||
|
||||
-- Fuel: Coal, Uranium
|
||||
-- Fuel: Coal, Uranium, Peat
|
||||
core.register_node("vox_worldblocks:coal_ore", {
|
||||
description = "Coal Ore",
|
||||
tiles = {"vox_coal_ore.png"},
|
||||
|
@ -374,7 +498,14 @@ core.register_node("vox_worldblocks:uranium_ore", {
|
|||
core.register_alias("uranium_ore", "vox_worldblocks:uranium_ore")
|
||||
core.register_alias("default:stone_with_uranium", "vox_worldblocks:uranium_ore")
|
||||
|
||||
-- Minerals: Bone, Sulfur, Salt
|
||||
core.register_node("vox_worldblocks:peat", {
|
||||
description = "Peat",
|
||||
tiles = {"vox_peat.png"},
|
||||
groups = {crumbly = 2, flammable = 1}
|
||||
})
|
||||
core.register_alias("peat", "vox_worldblocks:peat")
|
||||
|
||||
-- Bone
|
||||
core.register_node("vox_worldblocks:bone_ore", {
|
||||
description = "Bone Ore",
|
||||
tiles = {"vox_bone_ore.png"},
|
||||
|
@ -383,6 +514,7 @@ core.register_node("vox_worldblocks:bone_ore", {
|
|||
core.register_alias("bone_ore", "vox_worldblocks:bone_ore")
|
||||
core.register_alias("default:stone_with_bone", "vox_worldblocks:bone_ore")
|
||||
|
||||
-- Sulfur
|
||||
core.register_node("vox_worldblocks:sulfur_ore", {
|
||||
description = "Sulfur Ore",
|
||||
tiles = {"vox_sulfur_ore.png"},
|
||||
|
@ -391,15 +523,16 @@ core.register_node("vox_worldblocks:sulfur_ore", {
|
|||
core.register_alias("sulfur_ore", "vox_worldblocks:sulfur_ore")
|
||||
core.register_alias("default:stone_with_sulfur", "vox_worldblocks:sulfur_ore")
|
||||
|
||||
-- Salt
|
||||
core.register_node("vox_worldblocks:salt_ore", {
|
||||
description = "Salt Ore",
|
||||
tiles = {"vox_salt_ore.png"},
|
||||
groups = {cracky = 2}
|
||||
groups = {crumbly = 2},
|
||||
drop = "vox_mats:salt"
|
||||
})
|
||||
core.register_alias("salt_ore", "vox_worldblocks:salt_ore")
|
||||
core.register_alias("default:stone_with_salt", "vox_worldblocks:salt_ore")
|
||||
|
||||
|
||||
-- Metals: Copper, Tin, Iron, Gold, Silver, Platinum, Lead, Zinc, Nickel, Cobalt, Titanium, Tungsten
|
||||
core.register_node("vox_worldblocks:copper_ore", {
|
||||
description = "Copper Ore",
|
||||
|
@ -730,3 +863,43 @@ core.register_node("vox_worldblocks:carnelian_ore", {
|
|||
})
|
||||
core.register_alias("carnelian_ore", "vox_worldblocks:carnelian_ore")
|
||||
core.register_alias("default:stone_with_carnelian", "vox_worldblocks:carnelian_ore")
|
||||
|
||||
|
||||
-- ---------------------------- Blocks with Multiple Colors -------------------------- --
|
||||
-- Register colored (fill in the blank) dynamically
|
||||
for color_name, color_hex in pairs(vox_colors) do
|
||||
-- Skip any non-color functions or keys
|
||||
if type(color_hex) == "string" and vox_colors.validate(color_hex) then
|
||||
-- Register Colored Stone variant
|
||||
core.register_node("vox_worldblocks:stone_" .. color_name:lower(), {
|
||||
description = color_name .. " Stone",
|
||||
tiles = {"vox_stone_colorize.png^[multiply:" .. color_hex},
|
||||
groups = {cracky = 2},
|
||||
})
|
||||
core.register_alias("stone_" .. color_name:lower(), "vox_worldblocks:stone_" .. color_name:lower())
|
||||
|
||||
-- Register Terracotta variant
|
||||
core.register_node("vox_worldblocks:terracotta_" .. color_name:lower(), {
|
||||
description = color_name .. " Terracotta",
|
||||
tiles = {"vox_terracotta_colorize.png^[multiply:" .. color_hex},
|
||||
groups = {cracky = 2},
|
||||
})
|
||||
core.register_alias("terracotta_" .. color_name:lower(), "vox_worldblocks:terracotta_" .. color_name:lower())
|
||||
end
|
||||
end
|
||||
|
||||
-- ---------------------------- Dyeable Nodes -------------------------- --
|
||||
-- List of dyeable things
|
||||
local dyeable_blocks = {"sand", "terracotta", "marble", "cobblestone", "sandstone"}
|
||||
|
||||
-- Debug: Check if dyeable_blocks is defined correctly
|
||||
assert(type(dyeable_blocks) == "table", "[vox_worldblocks] 'dyeable_blocks' must be a table!")
|
||||
|
||||
-- Register base things and their dyeable variants
|
||||
for _, base_block in pairs(dyeable_blocks) do
|
||||
if type(base_block) == "string" then
|
||||
vox_coloring.register_dyeable("vox_worldblocks", base_block)
|
||||
else
|
||||
minetest.log("error", "[vox_worldblocks] Invalid block name in dyeable_blocks: " .. tostring(base_block))
|
||||
end
|
||||
end
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 132 B After Width: | Height: | Size: 619 B |
|
@ -11,58 +11,145 @@
|
|||
-- with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
vox_mapgen_core = { }
|
||||
vox_mapgen_core = {}
|
||||
|
||||
-- Also run...
|
||||
dofile(minetest.get_modpath("vox_mapgen_core").."/ores.lua")
|
||||
-- -------------------------------------------------------------- --
|
||||
-- Configuration: Noise Parameters
|
||||
-- -------------------------------------------------------------- --
|
||||
local noise_heat = {
|
||||
offset = 50,
|
||||
scale = 50,
|
||||
spread = {x = 1000, y = 1000, z = 1000},
|
||||
seed = 1234,
|
||||
octaves = 3,
|
||||
persistence = 0.5,
|
||||
lacunarity = 2.0,
|
||||
}
|
||||
|
||||
-- Disable minetest dungeons. We're making our own with blackjack and hookers.
|
||||
minetest.set_mapgen_setting("mg_flags", "dungeons", false)
|
||||
local noise_humidity = {
|
||||
offset = 50,
|
||||
scale = 50,
|
||||
spread = {x = 1000, y = 1000, z = 1000},
|
||||
seed = 5678,
|
||||
octaves = 3,
|
||||
persistence = 0.5,
|
||||
lacunarity = 2.0,
|
||||
}
|
||||
|
||||
-- Some adjustments based on different generators.
|
||||
-- For now we allow v7, and haven't looked at the other generators.
|
||||
if mg_name == "v7" then
|
||||
minetest.set_mapgen_setting("mg7_cavern_threshold", 0.2, true)
|
||||
minetest.set_mapgen_setting("mg_flags", "dungeons", false)
|
||||
local noise_altitude = {
|
||||
offset = 50,
|
||||
scale = 50,
|
||||
spread = {x = 1000, y = 1000, z = 1000},
|
||||
seed = 91011,
|
||||
octaves = 3,
|
||||
persistence = 0.5,
|
||||
lacunarity = 2.0,
|
||||
}
|
||||
|
||||
local biome_size_noise = {
|
||||
offset = 0,
|
||||
scale = 10,
|
||||
spread = {x = 2000, y = 2000, z = 2000},
|
||||
seed = 78910,
|
||||
octaves = 2,
|
||||
persistence = 0.4,
|
||||
lacunarity = 2.0,
|
||||
}
|
||||
|
||||
-- Apply noise parameters to the map generator
|
||||
minetest.register_on_mapgen_init(function(mapgen_params)
|
||||
minetest.set_mapgen_setting_noiseparams("heat", noise_heat, true)
|
||||
minetest.set_mapgen_setting_noiseparams("humidity", noise_humidity, true)
|
||||
minetest.set_mapgen_setting_noiseparams("altitude", noise_altitude, true)
|
||||
end)
|
||||
|
||||
-- -------------------------------------------------------------- --
|
||||
-- Biome Assignment Logic
|
||||
-- -------------------------------------------------------------- --
|
||||
local function get_biome(heat, humidity, altitude)
|
||||
if heat > 70 and humidity < 30 then
|
||||
return "desert"
|
||||
elseif heat > 70 and humidity > 50 then
|
||||
if altitude > 100 then
|
||||
return "volcanic_fields"
|
||||
end
|
||||
return "savannah"
|
||||
elseif heat > 50 and humidity > 70 then
|
||||
return "tropical_rainforest"
|
||||
elseif heat < 30 and humidity > 60 then
|
||||
return "boreal_forest"
|
||||
elseif heat < 10 and humidity > 40 then
|
||||
return "frozen_tundra"
|
||||
elseif altitude > 256 then
|
||||
return "jade_cliffs"
|
||||
else
|
||||
return "grassland" -- Default biome
|
||||
end
|
||||
end
|
||||
|
||||
-- And some superflat tweaks.
|
||||
if superflat then
|
||||
-- Disable caves
|
||||
minetest.set_mapgen_setting("mg_flags", "caves", false)
|
||||
-- Disable dungeons
|
||||
minetest.set_mapgen_setting("mg_flags", "dungeons", false)
|
||||
-- Disable decorations
|
||||
minetest.set_mapgen_setting("mg_flags", "decoration", false)
|
||||
minetest.set_mapgen_setting("mgflat_spflags", "nocaves,nohills", true)
|
||||
local function blend_biomes(current_biome, neighbor_biome, distance)
|
||||
if distance < 10 and math.random() < 0.5 then
|
||||
return neighbor_biome
|
||||
end
|
||||
return current_biome
|
||||
end
|
||||
|
||||
-- -------------------------------------------------------------- --
|
||||
-- Map Generation Logic
|
||||
-- -------------------------------------------------------------- --
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||
local area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
|
||||
local data = vm:get_data()
|
||||
|
||||
-- Generate noise maps
|
||||
local heat_map = minetest.get_perlin_map(noise_heat, {x = maxp.x - minp.x + 1, y = maxp.z - minp.z + 1})
|
||||
local humidity_map = minetest.get_perlin_map(noise_humidity, {x = maxp.x - minp.x + 1, y = maxp.z - minp.z + 1})
|
||||
local altitude_map = minetest.get_perlin_map(noise_altitude, {x = maxp.x - minp.x + 1, y = maxp.z - minp.z + 1})
|
||||
local biome_size_map = minetest.get_perlin_map(biome_size_noise, {x = maxp.x - minp.x + 1, y = maxp.z - minp.z + 1})
|
||||
|
||||
local heat = heat_map:get_2d_map_flat({x = minp.x, y = minp.z})
|
||||
local humidity = humidity_map:get_2d_map_flat({x = minp.x, y = minp.z})
|
||||
local altitude = altitude_map:get_2d_map_flat({x = minp.x, y = minp.z})
|
||||
local biome_sizes = biome_size_map:get_2d_map_flat({x = minp.x, y = minp.z})
|
||||
|
||||
-- Generate flat bedrock at the lowest point of the world, -10000.
|
||||
local function generate_bedrock(minp, maxp, data)
|
||||
local vi = 0
|
||||
for z = minp.z, maxp.z do
|
||||
for x = minp.x, maxp.x do
|
||||
for y = -10000, -10000 do
|
||||
local c_air = minetest.get_content_id("air")
|
||||
data[vi] = c_air
|
||||
vi = vi + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local index2d = (z - minp.z) * (maxp.x - minp.x + 1) + (x - minp.x + 1)
|
||||
local h = heat[index2d]
|
||||
local hum = humidity[index2d]
|
||||
local alt = altitude[index2d]
|
||||
local biome_size = biome_sizes[index2d]
|
||||
|
||||
-- Put air/void beneath bedrock
|
||||
local function generate_void(minp, maxp, data)
|
||||
local vi = 0
|
||||
for z = minp.z, maxp.z do
|
||||
for x = minp.x, maxp.x do
|
||||
for y = -10001, -31000 do
|
||||
local c_air = minetest.get_content_id("air")
|
||||
data[vi] = c_air
|
||||
vi = vi + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local current_biome = get_biome(h, hum, alt)
|
||||
local neighbor_biome = get_biome(h + 5, hum + 5, alt)
|
||||
current_biome = blend_biomes(current_biome, neighbor_biome, biome_size)
|
||||
|
||||
-- Fetch biome properties
|
||||
local node_top = core.get_biome_top_node(current_biome) or "vox_worldblocks:grass"
|
||||
local node_filler = core.get_biome_filler_node(current_biome) or "vox_worldblocks:dirt"
|
||||
local depth_top = core.get_biome_depth_top(current_biome) or 1
|
||||
local depth_filler = core.get_biome_depth_filler(current_biome) or 3
|
||||
|
||||
for y = minp.y, maxp.y do
|
||||
local vi = area:index(x, y, z)
|
||||
|
||||
if y == minp.y then
|
||||
data[vi] = minetest.get_content_id("vox_worldblocks:bedrock")
|
||||
elseif y < -10001 then
|
||||
data[vi] = minetest.get_content_id("air")
|
||||
elseif y <= minp.y + depth_top then
|
||||
data[vi] = minetest.get_content_id(node_top)
|
||||
elseif y <= minp.y + depth_top + depth_filler then
|
||||
data[vi] = minetest.get_content_id(node_filler)
|
||||
else
|
||||
data[vi] = minetest.get_content_id("air")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vm:set_data(data)
|
||||
vm:write_to_map()
|
||||
end)
|
||||
|
|
42
mods/MAPGEN/vox_overworld/README.md
Normal file
42
mods/MAPGEN/vox_overworld/README.md
Normal file
|
@ -0,0 +1,42 @@
|
|||
|
||||
# Biome Registry Template
|
||||
|
||||
```lua
|
||||
core.register_biome({
|
||||
name = "temperate_forest",
|
||||
node_top = "vox_worldblocks:grass", -- Top surface block
|
||||
depth_top = 1, -- Depth of the top block
|
||||
node_filler = "vox_worldblocks:dirt", -- Subsurface block
|
||||
depth_filler = 3, -- Depth of filler layer
|
||||
node_stone = "vox_worldblocks:stone", -- Base stone layer
|
||||
node_riverbed = "vox_worldblocks:sand", -- Riverbed material
|
||||
depth_riverbed = 2, -- Depth of riverbed material
|
||||
node_river_water = "vox_worldblocks:water_source", -- Water source
|
||||
heat_point = 45, -- Climate heat level
|
||||
humidity_point = 70, -- Climate humidity level
|
||||
height_min = 1, -- Minimum height for the biome
|
||||
height_max = 128, -- Maximum height for the biome
|
||||
decorations = {"flowers:rose", "flowers:tulip"}, -- Decoration nodes
|
||||
biome_group = "temperate", -- Biome category (for climate/weather)
|
||||
})
|
||||
```
|
||||
|
||||
OLD:
|
||||
|
||||
```lua
|
||||
core.register_biome({
|
||||
name = "grassland",
|
||||
node_top = "grass",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_main:dirt",
|
||||
node_stone = "vox_main:stone",
|
||||
depth_filler = 3,
|
||||
node_riverbed = "vox_main:sand",
|
||||
node_river_water = "vox_main:water_source",
|
||||
depth_riverbed = 2,
|
||||
height_min = 1,
|
||||
height_max = 256,
|
||||
heat_point = 35,
|
||||
humidity_point = 50
|
||||
})
|
||||
```
|
|
@ -15,4 +15,5 @@ vox_overworld = {}
|
|||
|
||||
dofile(core.get_modpath(core.get_current_modname()) .. "/registry.lua")
|
||||
|
||||
|
||||
-- Ensure vox_mapgen_core is loaded
|
||||
--local mapgen_core = assert(vox_mapgen_core, "vox_mapgen_core must be loaded before vox_overworld")
|
||||
|
|
|
@ -2,27 +2,190 @@
|
|||
-- Voxelis - Voxel survival sandbox for Luanti
|
||||
-- Copyright (C) 2024 Mad Star Studio LLC
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License along
|
||||
-- with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
core.register_biome({
|
||||
-- -------------------------------------------------------------- --
|
||||
-- BIOMES
|
||||
-- -------------------------------------------------------------- --
|
||||
|
||||
-- Helper Function: Register Default Biome Properties
|
||||
local function register_biome(params)
|
||||
-- Set defaults for biome parameters
|
||||
params.node_river_water = params.node_river_water or "vox_worldblocks:water_source"
|
||||
params.depth_riverbed = params.depth_riverbed or 2
|
||||
params.height_min = params.height_min or 1
|
||||
params.height_max = params.height_max or 256
|
||||
params.node_stone = params.node_stone or "vox_worldblocks:stone"
|
||||
|
||||
core.register_biome(params)
|
||||
end
|
||||
|
||||
-- Grasslands
|
||||
register_biome({
|
||||
name = "grassland",
|
||||
node_top = "grass",
|
||||
node_top = "vox_worldblocks:grass",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_main:dirt",
|
||||
node_stone = "vox_main:stone",
|
||||
node_filler = "vox_worldblocks:dirt",
|
||||
depth_filler = 3,
|
||||
node_riverbed = "vox_main:sand",
|
||||
node_river_water = "vox_main:water_source",
|
||||
depth_riverbed = 2,
|
||||
height_min = 1,
|
||||
height_max = 256,
|
||||
heat_point = 35,
|
||||
humidity_point = 50
|
||||
humidity_point = 50,
|
||||
})
|
||||
|
||||
-- Desert
|
||||
register_biome({
|
||||
name = "desert",
|
||||
node_top = "vox_worldblocks:sand",
|
||||
depth_top = 2,
|
||||
node_filler = "vox_worldblocks:sandstone",
|
||||
depth_filler = 5,
|
||||
heat_point = 80,
|
||||
humidity_point = 20,
|
||||
})
|
||||
|
||||
-- Boreal Forest
|
||||
register_biome({
|
||||
name = "boreal_forest",
|
||||
node_top = "vox_worldblocks:grass",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_worldblocks:dirt",
|
||||
depth_filler = 4,
|
||||
heat_point = 20,
|
||||
humidity_point = 60,
|
||||
})
|
||||
|
||||
-- Frozen Tundra
|
||||
register_biome({
|
||||
name = "frozen_tundra",
|
||||
node_top = "vox_worldblocks:snow",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_worldblocks:packed_snow",
|
||||
depth_filler = 3,
|
||||
node_riverbed = "vox_worldblocks:ice",
|
||||
heat_point = 5,
|
||||
humidity_point = 40,
|
||||
height_max = 150,
|
||||
})
|
||||
|
||||
-- Rocky Badlands
|
||||
register_biome({
|
||||
name = "rocky_badlands",
|
||||
node_top = "vox_worldblocks:stone",
|
||||
depth_top = 2,
|
||||
node_filler = "vox_worldblocks:gravel",
|
||||
depth_filler = 4,
|
||||
heat_point = 50,
|
||||
humidity_point = 30,
|
||||
height_min = 50,
|
||||
height_max = 180,
|
||||
})
|
||||
|
||||
-- Savannah
|
||||
register_biome({
|
||||
name = "savannah",
|
||||
node_top = "vox_worldblocks:grass",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_worldblocks:dirt",
|
||||
depth_filler = 3,
|
||||
heat_point = 70,
|
||||
humidity_point = 30,
|
||||
height_max = 512,
|
||||
})
|
||||
|
||||
-- Mangrove Forest
|
||||
register_biome({
|
||||
name = "mangrove_forest",
|
||||
node_top = "vox_worldblocks:grass",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_worldblocks:mud",
|
||||
depth_filler = 3,
|
||||
node_riverbed = "vox_worldblocks:mud",
|
||||
heat_point = 75,
|
||||
humidity_point = 80,
|
||||
height_min = -5,
|
||||
height_max = 100,
|
||||
})
|
||||
|
||||
-- Volcanic Fields
|
||||
register_biome({
|
||||
name = "volcanic_fields",
|
||||
node_top = "vox_worldblocks:volcanic_rock",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_worldblocks:basalt",
|
||||
depth_filler = 5,
|
||||
node_riverbed = "vox_worldblocks:lava_source",
|
||||
node_river_water = "vox_worldblocks:lava_source",
|
||||
heat_point = 90,
|
||||
humidity_point = 10,
|
||||
height_min = 50,
|
||||
height_max = 512,
|
||||
})
|
||||
|
||||
-- Salt Flats
|
||||
register_biome({
|
||||
name = "salt_flats",
|
||||
node_top = "vox_worldblocks:salt_crystal",
|
||||
depth_top = 2,
|
||||
node_filler = "vox_worldblocks:sand",
|
||||
depth_filler = 3,
|
||||
heat_point = 80,
|
||||
humidity_point = 20,
|
||||
height_max = 100,
|
||||
})
|
||||
|
||||
-- Jade Cliffs
|
||||
register_biome({
|
||||
name = "jade_cliffs",
|
||||
node_top = "vox_worldblocks:grass",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_worldblocks:stone",
|
||||
depth_filler = 5,
|
||||
node_stone = "vox_worldblocks:granite",
|
||||
node_riverbed = "vox_worldblocks:gravel",
|
||||
heat_point = 55,
|
||||
humidity_point = 65,
|
||||
height_min = 128,
|
||||
height_max = 1024,
|
||||
})
|
||||
|
||||
-- Painted Canyons
|
||||
register_biome({
|
||||
name = "painted_canyons",
|
||||
node_top = "vox_worldblocks:terracotta_red",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_worldblocks:terracotta_orange",
|
||||
depth_filler = 4,
|
||||
node_riverbed = "vox_worldblocks:terracotta_yellow",
|
||||
heat_point = 65,
|
||||
humidity_point = 25,
|
||||
height_min = 10,
|
||||
height_max = 256,
|
||||
})
|
||||
|
||||
-- Iceberg Fields
|
||||
register_biome({
|
||||
name = "iceberg_fields",
|
||||
node_top = "vox_worldblocks:ice",
|
||||
depth_top = 1,
|
||||
node_filler = "vox_worldblocks:snow",
|
||||
depth_filler = 3,
|
||||
node_riverbed = "vox_worldblocks:ice",
|
||||
heat_point = -10,
|
||||
humidity_point = 50,
|
||||
height_min = -100,
|
||||
height_max = 100,
|
||||
})
|
||||
|
||||
-- Black Sand Beach
|
||||
register_biome({
|
||||
name = "black_sand_beach",
|
||||
node_top = "vox_worldblocks:basalt",
|
||||
depth_top = 2,
|
||||
node_filler = "vox_worldblocks:sand",
|
||||
depth_filler = 3,
|
||||
heat_point = 65,
|
||||
humidity_point = 80,
|
||||
height_min = -5,
|
||||
height_max = 5,
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue