add caverealms mod
16
worldmods/caverealms/README.md
Normal file
@ -0,0 +1,16 @@
|
||||
# minetest-caverealms
|
||||
|
||||
A mod for Minetest to add underground realms
|
||||
|
||||
## Forum Topic
|
||||
For more information, view the official forum topic at:
|
||||
- https://forum.minetest.net/viewtopic.php?f=9&t=9522
|
||||
|
||||
## Contributors
|
||||
- HeroOfTheWinds - everything
|
||||
- Zeno - additional ideas and fine tuning
|
||||
|
||||
##Licensing
|
||||
- WTFPL
|
||||
|
||||
Also be sure to check out VanessaE's texturepack "HDX", which supports this mod!
|
68
worldmods/caverealms/abms.lua
Normal file
@ -0,0 +1,68 @@
|
||||
--grab schematics
|
||||
local fortress = minetest.get_modpath("caverealms").."/schems/DMFort.mts"
|
||||
local fountain = minetest.get_modpath("caverealms").."/schems/DMFountain.mts"
|
||||
|
||||
local DM_TOP = caverealms.config.dm_top -- -4000 --level at which Dungeon Master Realms start to appear
|
||||
|
||||
--place Dungeon Master Statue fountains
|
||||
minetest.register_abm({
|
||||
nodenames = {"caverealms:s_fountain"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if pos.y > DM_TOP then
|
||||
minetest.remove_node(pos)
|
||||
return
|
||||
end
|
||||
minetest.place_schematic(pos, fountain, "random", {}, true)
|
||||
end,
|
||||
})
|
||||
|
||||
--place Dungeon Master Fortresses
|
||||
minetest.register_abm({
|
||||
nodenames = {"caverealms:s_fortress"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if pos.y > DM_TOP then
|
||||
minetest.remove_node(pos)
|
||||
return
|
||||
end
|
||||
npos = {x=pos.x,y=pos.y-7,z=pos.z}
|
||||
minetest.place_schematic(npos, fortress, "random", {}, true)
|
||||
end,
|
||||
})
|
||||
|
||||
local MIN_ITEMS = caverealms.config.min_items--2 --minimum number of items to put in chests - do not set to greater than MAX_ITEMS
|
||||
local MAX_ITEMS = caverealms.config.max_items--5 --maximum number of items to put in chests - do not set to less than MIN_ITEMS
|
||||
|
||||
--table of itemstrings
|
||||
local ITEMS = {
|
||||
"default:diamond",
|
||||
"default:obsidian 33",
|
||||
"default:mese",
|
||||
"default:pick_diamond",
|
||||
"default:stonebrick 50",
|
||||
"default:sandstone 75",
|
||||
"default:torch 99",
|
||||
"default:water_source 4",
|
||||
}
|
||||
|
||||
--spawn and fill chests
|
||||
minetest.register_abm({
|
||||
nodenames = {"caverealms:s_chest"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
oldparam = minetest.get_node(pos).param2
|
||||
minetest.set_node(pos, {name="default:chest", param2=oldparam})
|
||||
minetest.after(1.0, function()
|
||||
local inv = minetest.get_inventory({type="node", pos=pos})
|
||||
local item_num = math.random(MIN_ITEMS, MAX_ITEMS)
|
||||
for i = 1, item_num do
|
||||
item_i = math.random(8) --if you add or subtract items from ITEMS, be sure to change this value to reflect it
|
||||
inv:add_item("main", ITEMS[item_i])
|
||||
end
|
||||
end)
|
||||
end,
|
||||
})
|
65
worldmods/caverealms/config.lua
Normal file
@ -0,0 +1,65 @@
|
||||
|
||||
local CONFIG_FILE_PREFIX = "caverealms."
|
||||
|
||||
caverealms.config = {}
|
||||
|
||||
-- This function based on kaeza/minetest-irc/config.lua and used under the
|
||||
-- terms of BSD 2-clause license.
|
||||
local function setting(stype, name, default)
|
||||
local value
|
||||
if stype == "bool" then
|
||||
value = minetest.setting_getbool(CONFIG_FILE_PREFIX..name)
|
||||
elseif stype == "string" then
|
||||
value = minetest.setting_get(CONFIG_FILE_PREFIX..name)
|
||||
elseif stype == "number" then
|
||||
value = tonumber(minetest.setting_get(CONFIG_FILE_PREFIX..name))
|
||||
end
|
||||
if value == nil then
|
||||
value = default
|
||||
end
|
||||
caverealms.config[name] = value
|
||||
end
|
||||
|
||||
--generation settings
|
||||
setting("number", "ymin", -33000) --bottom realm limit
|
||||
setting("number", "ymax", -700) --top realm limit
|
||||
setting("number", "tcave", 0.5) --cave threshold
|
||||
|
||||
--should player spawn in caves?
|
||||
setting("bool", "cavespawn", false)
|
||||
|
||||
--falling icicles
|
||||
setting("bool", "falling_icicles", true) --enable/disable falling icicles
|
||||
setting("number", "fallcha", 0.33) --chance of icicles falling when dug
|
||||
|
||||
--decoration chances
|
||||
setting("number", "stagcha", 0.002) --chance of stalagmites
|
||||
setting("number", "stalcha", 0.003) --chance of stalactites
|
||||
setting("number", "h_lag", 15) --max height for stalagmites
|
||||
setting("number", "h_lac", 20) --...stalactites
|
||||
setting("number", "crystal", 0.007) --chance of glow crystal formations
|
||||
setting("number", "h_cry", 9) --max height of glow crystals
|
||||
setting("number", "h_clac", 13) --max height of glow crystal stalactites
|
||||
setting("number", "gemcha", 0.03) --chance of small glow gems
|
||||
setting("number", "mushcha", 0.04) --chance of mushrooms
|
||||
setting("number", "myccha", 0.03) --chance of mycena mushrooms
|
||||
setting("number", "wormcha", 0.02) --chance of glow worms
|
||||
setting("number", "giantcha", 0.001) --chance of giant mushrooms
|
||||
setting("number", "icicha", 0.035) --chance of icicles
|
||||
setting("number", "flacha", 0.04) --chance of constant flames
|
||||
setting("number", "founcha", 0.001) --chance of fountains
|
||||
setting("number", "fortcha", 0.0003) --chance of fortresses
|
||||
|
||||
--realm limits for Dungeon Masters' Lair
|
||||
setting("number", "dm_top", -4000) --upper limit
|
||||
setting("number", "dm_bot", -5000) --lower limit
|
||||
--should fortresses and fountains spawn?
|
||||
setting("bool", "fortresses", true)
|
||||
setting("bool", "fountains", true)
|
||||
--Deep cave settings
|
||||
setting("number", "deep_cave", -7000) -- upper limit
|
||||
|
||||
--minimum number of items in chests found in fortresses
|
||||
setting("number", "min_items", 2)
|
||||
--maximum number of items in chests found in fortresses
|
||||
setting("number", "max_items", 5)
|
53
worldmods/caverealms/crafting.lua
Normal file
@ -0,0 +1,53 @@
|
||||
--CaveRealms crafting.lua
|
||||
|
||||
--CRAFT ITEMS--
|
||||
|
||||
--mycena powder
|
||||
minetest.register_craftitem("caverealms:mycena_powder", {
|
||||
description = "Mycena Powder",
|
||||
inventory_image = "caverealms_mycena_powder.png",
|
||||
})
|
||||
|
||||
--CRAFT RECIPES--
|
||||
|
||||
--mycena powder
|
||||
minetest.register_craft({
|
||||
output = "caverealms:mycena_powder",
|
||||
type = "shapeless",
|
||||
recipe = {"caverealms:mycena"}
|
||||
})
|
||||
|
||||
|
||||
--glow mese block
|
||||
minetest.register_craft({
|
||||
output = "caverealms:glow_mese",
|
||||
recipe = {
|
||||
{"default:mese_crystal_fragment","default:mese_crystal_fragment","default:mese_crystal_fragment"},
|
||||
{"default:mese_crystal_fragment","caverealms:mycena_powder","default:mese_crystal_fragment"},
|
||||
{"default:mese_crystal_fragment","default:mese_crystal_fragment","default:mese_crystal_fragment"}
|
||||
}
|
||||
})
|
||||
|
||||
--reverse craft for glow mese
|
||||
minetest.register_craft({
|
||||
output = "default:mese_crystal_fragment 8",
|
||||
type = "shapeless",
|
||||
recipe = {"caverealms:glow_mese"}
|
||||
})
|
||||
|
||||
--thin ice to water
|
||||
minetest.register_craft({
|
||||
output = "default:water_source",
|
||||
type = "shapeless",
|
||||
recipe = {"caverealms:thin_ice"}
|
||||
})
|
||||
|
||||
--use for coal dust
|
||||
minetest.register_craft({
|
||||
output = "default:coalblock",
|
||||
recipe = {
|
||||
{"caverealms:coal_dust","caverealms:coal_dust","caverealms:coal_dust"},
|
||||
{"caverealms:coal_dust","caverealms:coal_dust","caverealms:coal_dust"},
|
||||
{"caverealms:coal_dust","caverealms:coal_dust","caverealms:coal_dust"}
|
||||
}
|
||||
})
|
1
worldmods/caverealms/depends.txt
Normal file
@ -0,0 +1 @@
|
||||
default
|
1
worldmods/caverealms/description.txt
Normal file
@ -0,0 +1 @@
|
||||
A mod for Minetest to add underground realms.
|
210
worldmods/caverealms/falling_ice.lua
Normal file
@ -0,0 +1,210 @@
|
||||
-- CaveRealms: falling icicles
|
||||
-- borrowed from base MineTest game's falling.lua
|
||||
|
||||
--
|
||||
-- Falling ice
|
||||
--
|
||||
|
||||
minetest.register_entity("caverealms:falling_ice", {
|
||||
initial_properties = {
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
||||
visual = "wielditem",
|
||||
textures = {},
|
||||
visual_size = {x=0.667, y=0.667},
|
||||
},
|
||||
|
||||
node = {},
|
||||
|
||||
set_node = function(self, node)
|
||||
self.node = node
|
||||
local stack = ItemStack(node.name)
|
||||
local itemtable = stack:to_table()
|
||||
local itemname = nil
|
||||
if itemtable then
|
||||
itemname = stack:to_table().name
|
||||
end
|
||||
local item_texture = nil
|
||||
local item_type = ""
|
||||
if minetest.registered_items[itemname] then
|
||||
item_texture = minetest.registered_items[itemname].inventory_image
|
||||
item_type = minetest.registered_items[itemname].type
|
||||
end
|
||||
prop = {
|
||||
is_visible = true,
|
||||
textures = {node.name},
|
||||
}
|
||||
self.object:set_properties(prop)
|
||||
end,
|
||||
|
||||
get_staticdata = function(self)
|
||||
return self.node.name
|
||||
end,
|
||||
|
||||
on_activate = function(self, staticdata)
|
||||
self.object:set_armor_groups({immortal=1})
|
||||
--self.object:setacceleration({x=0, y=-10, z=0})
|
||||
self:set_node({name=staticdata})
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
-- Set gravity
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
-- Destroy when collides to ground or just move
|
||||
local pos = self.object:getpos()
|
||||
local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point
|
||||
local bcn = minetest.get_node(bcp)
|
||||
local bcd = minetest.registered_nodes[bcn.name]
|
||||
--check for players next to this and hurt them >:D
|
||||
local all_objects = minetest.get_objects_inside_radius(pos, 1)
|
||||
local _,obj
|
||||
for _,obj in ipairs(all_objects) do
|
||||
if obj:is_player() then
|
||||
obj:set_hp(obj:get_hp() - 8)
|
||||
end
|
||||
end
|
||||
-- Note: walkable is in the node definition, not in item groups
|
||||
if not bcd or
|
||||
(bcd.walkable or
|
||||
(minetest.get_item_group(self.node.name, "float") ~= 0 and
|
||||
bcd.liquidtype ~= "none")) then
|
||||
if bcd and bcd.leveled and
|
||||
bcn.name == self.node.name then
|
||||
local addlevel = self.node.level
|
||||
if addlevel == nil or addlevel <= 0 then
|
||||
addlevel = bcd.leveled
|
||||
end
|
||||
if minetest.add_node_level(bcp, addlevel) == 0 then
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
elseif bcd and bcd.buildable_to and
|
||||
(minetest.get_item_group(self.node.name, "float") == 0 or
|
||||
bcd.liquidtype == "none") then
|
||||
minetest.remove_node(bcp)
|
||||
return
|
||||
end
|
||||
local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
|
||||
-- Check what's here
|
||||
local n2 = minetest.get_node(np)
|
||||
-- remove node and replace it with it's drops
|
||||
local drops = minetest.get_node_drops(n2.name, "")
|
||||
minetest.remove_node(np)
|
||||
local _, dropped_item
|
||||
for _, dropped_item in ipairs(drops) do
|
||||
minetest.add_item(np, dropped_item)
|
||||
end
|
||||
-- Run script hook
|
||||
local _, callback
|
||||
for _, callback in ipairs(minetest.registered_on_dignodes) do
|
||||
callback(np, n2, nil)
|
||||
end
|
||||
-- remove entity
|
||||
--minetest.add_node(np, self.node)
|
||||
self.object:remove()
|
||||
caverealms:nodeupdate(np)
|
||||
else
|
||||
-- Do nothing
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
function caverealms:spawn_falling_node(p, node)
|
||||
obj = minetest.add_entity(p, "caverealms:falling_ice")
|
||||
obj:get_luaentity():set_node(node)
|
||||
end
|
||||
|
||||
function caverealms:drop_attached_node(p)
|
||||
local nn = minetest.get_node(p).name
|
||||
minetest.remove_node(p)
|
||||
for _,item in ipairs(minetest.get_node_drops(nn, "")) do
|
||||
local pos = {
|
||||
x = p.x + math.random()/2 - 0.25,
|
||||
y = p.y + math.random()/2 - 0.25,
|
||||
z = p.z + math.random()/2 - 0.25,
|
||||
}
|
||||
minetest.add_item(pos, item)
|
||||
end
|
||||
end
|
||||
|
||||
function caverealms:check_attached_node(p, n)
|
||||
local def = minetest.registered_nodes[n.name]
|
||||
local d = {x=0, y=0, z=0}
|
||||
if def.paramtype2 == "wallmounted" then
|
||||
if n.param2 == 0 then
|
||||
d.y = 1
|
||||
elseif n.param2 == 1 then
|
||||
d.y = -1
|
||||
elseif n.param2 == 2 then
|
||||
d.x = 1
|
||||
elseif n.param2 == 3 then
|
||||
d.x = -1
|
||||
elseif n.param2 == 4 then
|
||||
d.z = 1
|
||||
elseif n.param2 == 5 then
|
||||
d.z = -1
|
||||
end
|
||||
else
|
||||
d.y = -1
|
||||
end
|
||||
local p2 = {x=p.x+d.x, y=p.y+d.y, z=p.z+d.z}
|
||||
local nn = minetest.get_node(p2).name
|
||||
local def2 = minetest.registered_nodes[nn]
|
||||
if def2 and not def2.walkable then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
--
|
||||
-- Some common functions
|
||||
--
|
||||
|
||||
function caverealms:nodeupdate_single(p, delay)
|
||||
n = minetest.get_node(p)
|
||||
if minetest.get_item_group(n.name, "falling_node") ~= 0 then
|
||||
p_bottom = {x=p.x, y=p.y-1, z=p.z}
|
||||
n_bottom = minetest.get_node(p_bottom)
|
||||
-- Note: walkable is in the node definition, not in item groups
|
||||
if minetest.registered_nodes[n_bottom.name] and
|
||||
(minetest.get_item_group(n.name, "float") == 0 or
|
||||
minetest.registered_nodes[n_bottom.name].liquidtype == "none") and
|
||||
(n.name ~= n_bottom.name or (minetest.registered_nodes[n_bottom.name].leveled and
|
||||
minetest.get_node_level(p_bottom) < minetest.get_node_max_level(p_bottom))) and
|
||||
(not minetest.registered_nodes[n_bottom.name].walkable or
|
||||
minetest.registered_nodes[n_bottom.name].buildable_to) then
|
||||
if delay then
|
||||
minetest.after(0.1, caverealms.nodeupdate_single, {x=p.x, y=p.y, z=p.z}, false)
|
||||
else
|
||||
n.level = minetest.env:get_node_level(p)
|
||||
minetest.remove_node(p)
|
||||
caverealms:spawn_falling_node(p, n)
|
||||
caverealms:nodeupdate(p)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_item_group(n.name, "attached_node") ~= 0 then
|
||||
if not check_attached_node(p, n) then
|
||||
caverealms:drop_attached_node(p)
|
||||
caverealms:nodeupdate(p)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function caverealms:nodeupdate(p, delay)
|
||||
-- Round p to prevent falling entities to get stuck
|
||||
p.x = math.floor(p.x+0.5)
|
||||
p.y = math.floor(p.y+0.5)
|
||||
p.z = math.floor(p.z+0.5)
|
||||
|
||||
for x = -1,1 do
|
||||
for y = -1,1 do
|
||||
for z = -1,1 do
|
||||
caverealms:nodeupdate_single({x=p.x+x, y=p.y+y, z=p.z+z}, delay or not (x==0 and y==0 and z==0))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
624
worldmods/caverealms/functions.lua
Normal file
@ -0,0 +1,624 @@
|
||||
--CaveRealms functions.lua
|
||||
|
||||
--FUNCTIONS--
|
||||
|
||||
local H_LAG = caverealms.config.h_lag --15 --max height for stalagmites
|
||||
local H_LAC = caverealms.config.h_lac --20 --...stalactites
|
||||
local H_CRY = caverealms.config.h_cry --9 --max height of glow crystals
|
||||
local H_CLAC = caverealms.config.h_clac --13 --max height of glow crystal stalactites
|
||||
|
||||
function caverealms:above_solid(x,y,z,area,data)
|
||||
local c_air = minetest.get_content_id("air")
|
||||
|
||||
local c_vac
|
||||
if (minetest.get_modpath("moontest")) then
|
||||
c_vac = minetest.get_content_id("moontest:vacuum")
|
||||
else
|
||||
c_vac = minetest.get_content_id("air")
|
||||
end
|
||||
|
||||
local ai = area:index(x,y+1,z-3)
|
||||
if data[ai] == c_air or data[ai] == c_vac then
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
function caverealms:below_solid(x,y,z,area,data)
|
||||
local c_air = minetest.get_content_id("air")
|
||||
|
||||
local c_vac
|
||||
if (minetest.get_modpath("moontest")) then
|
||||
c_vac = minetest.get_content_id("moontest:vacuum")
|
||||
else
|
||||
c_vac = minetest.get_content_id("air")
|
||||
end
|
||||
|
||||
local ai = area:index(x,y-1,z-3)
|
||||
if data[ai] == c_air or data[ai] == c_vac then
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
--stalagmite spawner
|
||||
function caverealms:stalagmite(x,y,z, area, data)
|
||||
|
||||
if not caverealms:below_solid(x,y,z,area,data) then
|
||||
return
|
||||
end
|
||||
|
||||
--contest ids
|
||||
local c_stone = minetest.get_content_id("default:stone")
|
||||
|
||||
local top = math.random(6,H_LAG) --grab a random height for the stalagmite
|
||||
for j = 0, top do --y
|
||||
for k = -3, 3 do
|
||||
for l = -3, 3 do
|
||||
if j == 0 then
|
||||
if k*k + l*l <= 9 then
|
||||
local vi = area:index(x+k, y+j, z+l-3)
|
||||
data[vi] = c_stone
|
||||
end
|
||||
elseif j <= top/5 then
|
||||
if k*k + l*l <= 4 then
|
||||
local vi = area:index(x+k, y+j, z+l-3)
|
||||
data[vi] = c_stone
|
||||
end
|
||||
elseif j <= top/5 * 3 then
|
||||
if k*k + l*l <= 1 then
|
||||
local vi = area:index(x+k, y+j, z+l-3)
|
||||
data[vi] = c_stone
|
||||
end
|
||||
else
|
||||
local vi = area:index(x, y+j, z-3)
|
||||
data[vi] = c_stone
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--stalactite spawner
|
||||
function caverealms:stalactite(x,y,z, area, data)
|
||||
|
||||
if not caverealms:above_solid(x,y,z,area,data) then
|
||||
return
|
||||
end
|
||||
|
||||
--contest ids
|
||||
local c_stone = minetest.get_content_id("default:stone")--("caverealms:limestone")
|
||||
|
||||
local bot = math.random(-H_LAC, -6) --grab a random height for the stalagmite
|
||||
for j = bot, 0 do --y
|
||||
for k = -3, 3 do
|
||||
for l = -3, 3 do
|
||||
if j >= -1 then
|
||||
if k*k + l*l <= 9 then
|
||||
local vi = area:index(x+k, y+j, z+l-3)
|
||||
data[vi] = c_stone
|
||||
end
|
||||
elseif j >= bot/5 then
|
||||
if k*k + l*l <= 4 then
|
||||
local vi = area:index(x+k, y+j, z+l-3)
|
||||
data[vi] = c_stone
|
||||
end
|
||||
elseif j >= bot/5 * 3 then
|
||||
if k*k + l*l <= 1 then
|
||||
local vi = area:index(x+k, y+j, z+l-3)
|
||||
data[vi] = c_stone
|
||||
end
|
||||
else
|
||||
local vi = area:index(x, y+j, z-3)
|
||||
data[vi] = c_stone
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--glowing crystal stalagmite spawner
|
||||
function caverealms:crystal_stalagmite(x,y,z, area, data, biome)
|
||||
|
||||
if not caverealms:below_solid(x,y,z,area,data) then
|
||||
return
|
||||
end
|
||||
|
||||
--contest ids
|
||||
local c_stone = minetest.get_content_id("default:stone")
|
||||
local c_crystal = minetest.get_content_id("caverealms:glow_crystal")
|
||||
local c_crystore = minetest.get_content_id("caverealms:glow_ore")
|
||||
local c_emerald = minetest.get_content_id("caverealms:glow_emerald")
|
||||
local c_emore = minetest.get_content_id("caverealms:glow_emerald_ore")
|
||||
local c_mesecry = minetest.get_content_id("caverealms:glow_mese")
|
||||
local c_meseore = minetest.get_content_id("default:stone_with_mese")
|
||||
local c_ruby = minetest.get_content_id("caverealms:glow_ruby")
|
||||
local c_rubore = minetest.get_content_id("caverealms:glow_ruby_ore")
|
||||
local c_ameth = minetest.get_content_id("caverealms:glow_amethyst")
|
||||
local c_amethore = minetest.get_content_id("caverealms:glow_amethyst_ore")
|
||||
local c_ice = minetest.get_content_id("default:ice")
|
||||
local c_thinice = minetest.get_content_id("caverealms:thin_ice")
|
||||
|
||||
--for randomness
|
||||
local mode = 1
|
||||
if math.random(15) == 1 then
|
||||
mode = 2
|
||||
end
|
||||
if biome == 3 then
|
||||
if math.random(25) == 1 then
|
||||
mode = 2
|
||||
else
|
||||
mode = 1
|
||||
end
|
||||
end
|
||||
if biome == 4 or biome == 5 then
|
||||
if math.random(3) == 1 then
|
||||
mode = 2
|
||||
end
|
||||
end
|
||||
|
||||
local stalids = {
|
||||
{ {c_crystore, c_crystal}, {c_emore, c_emerald} },
|
||||
{ {c_emore, c_emerald}, {c_crystore, c_crystal} },
|
||||
{ {c_emore, c_emerald}, {c_meseore, c_mesecry} },
|
||||
{ {c_ice, c_thinice}, {c_crystore, c_crystal}},
|
||||
{ {c_ice, c_thinice}, {c_crystore, c_crystal}},
|
||||
{ {c_rubore, c_ruby}, {c_meseore, c_mesecry}},
|
||||
{ {c_crystore, c_crystal}, {c_rubore, c_ruby} },
|
||||
{ {c_rubore, c_ruby}, {c_emore, c_emerald}},
|
||||
{ {c_amethore, c_ameth}, {c_meseore, c_mesecry} },
|
||||
}
|
||||
|
||||
local nid_a
|
||||
local nid_b
|
||||
local nid_s = c_stone --stone base, will be rewritten to ice in certain biomes
|
||||
|
||||
if biome > 3 and biome < 6 then
|
||||
if mode == 1 then
|
||||
nid_a = c_ice
|
||||
nid_b = c_thinice
|
||||
nid_s = c_ice
|
||||
else
|
||||
nid_a = c_crystore
|
||||
nid_b = c_crystal
|
||||
end
|
||||
elseif mode == 1 then
|
||||
nid_a = stalids[biome][1][1]
|
||||
nid_b = stalids[biome][1][2]
|
||||
else
|
||||
nid_a = stalids[biome][2][1]
|
||||
nid_b = stalids[biome][2][2]
|
||||
end
|
||||
|
||||
local top = math.random(5,H_CRY) --grab a random height for the stalagmite
|
||||
for j = 0, top do --y
|
||||
for k = -3, 3 do
|
||||
for l = -3, 3 do
|
||||
if j == 0 then
|
||||
if k*k + l*l <= 9 then
|
||||
local vi = area:index(x+k, y+j, z+l-3)
|
||||
data[vi] = nid_s
|
||||
end
|
||||
elseif j <= top/5 then
|
||||
if k*k + l*l <= 4 then
|
||||
local vi = area:index(x+k, y+j, z+l-3)
|
||||
data[vi] = nid_a
|
||||
end
|
||||
elseif j <= top/5 * 3 then
|
||||
if k*k + l*l <= 1 then
|
||||
local vi = area:index(x+k, y+j, z+l-3)
|
||||
data[vi] = nid_b
|
||||
end
|
||||
else
|
||||
local vi = area:index(x, y+j, z-3)
|
||||
data[vi] = nid_b
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--crystal stalactite spawner
|
||||
function caverealms:crystal_stalactite(x,y,z, area, data, biome)
|
||||
|
||||
if not caverealms:above_solid(x,y,z,area,data) then
|
||||
return
|
||||
end
|
||||
|
||||
--contest ids
|
||||
local c_stone = minetest.get_content_id("default:stone")
|
||||
local c_crystore = minetest.get_content_id("caverealms:glow_ore")
|
||||
local c_crystal = minetest.get_content_id("caverealms:glow_crystal")
|
||||
local c_emerald = minetest.get_content_id("caverealms:glow_emerald")
|
||||
local c_emore = minetest.get_content_id("caverealms:glow_emerald_ore")
|
||||
local c_mesecry = minetest.get_content_id("caverealms:glow_mese")
|
||||
local c_meseore = minetest.get_content_id("default:stone_with_mese")
|
||||
local c_ruby = minetest.get_content_id("caverealms:glow_ruby")
|
||||
local c_rubore = minetest.get_content_id("caverealms:glow_ruby_ore")
|
||||
local c_ameth = minetest.get_content_id("caverealms:glow_amethyst")
|
||||
local c_amethore = minetest.get_content_id("caverealms:glow_amethyst_ore")
|
||||
local c_ice = minetest.get_content_id("default:ice")
|
||||
local c_thinice = minetest.get_content_id("caverealms:hanging_thin_ice")
|
||||
|
||||
--for randomness
|
||||
local mode = 1
|
||||
if math.random(15) == 1 then
|
||||
mode = 2
|
||||
end
|
||||
if biome == 3 then
|
||||
if math.random(25) == 1 then
|
||||
mode = 2
|
||||
else
|
||||
mode = 1
|
||||
end
|
||||
end
|
||||
if biome == 4 or biome == 5 then
|
||||
if math.random(3) == 1 then
|
||||
mode = 2
|
||||
end
|
||||
end
|
||||
|
||||
local stalids = {
|
||||
{ {c_crystore, c_crystal}, {c_emore, c_emerald} },
|
||||
{ {c_emore, c_emerald}, {c_crystore, c_crystal} },
|
||||
{ {c_emore, c_emerald}, {c_meseore, c_mesecry} },
|
||||
{ {c_ice, c_thinice}, {c_crystore, c_crystal}},
|
||||
{ {c_ice, c_thinice}, {c_crystore, c_crystal}},
|
||||
{ {c_rubore, c_ruby}, {c_meseore, c_mesecry}},
|
||||
{ {c_crystore, c_crystal}, {c_rubore, c_ruby} },
|
||||
{ {c_rubore, c_ruby}, {c_emore, c_emerald}},
|
||||
{ {c_amethore, c_ameth}, {c_meseore, c_mesecry} },
|
||||
}
|
||||
|
||||
local nid_a
|
||||
local nid_b
|
||||
local nid_s = c_stone --stone base, will be rewritten to ice in certain biomes
|
||||
|
||||
if biome > 3 and biome < 6 then
|
||||
if mode == 1 then
|
||||
nid_a = c_ice
|
||||
nid_b = c_thinice
|
||||
nid_s = c_ice
|
||||
else
|
||||
nid_a = c_crystore
|
||||
nid_b = c_crystal
|
||||
end
|
||||
elseif mode == 1 then
|
||||
nid_a = stalids[biome][1][1]
|
||||
nid_b = stalids[biome][1][2]
|
||||
else
|
||||
nid_a = stalids[biome][2][1]
|
||||
nid_b = stalids[biome][2][2]
|
||||
end
|
||||
|
||||
local bot = math.random(-H_CLAC, -6) --grab a random height for the stalagmite
|
||||
for j = bot, 0 do --y
|
||||
for k = -3, 3 do
|
||||
for l = -3, 3 do
|
||||
if j >= -1 then
|
||||
if k*k + l*l <= 9 then
|
||||
local vi = area:index(x+k, y+j, z+l-3)
|
||||
data[vi] = nid_s
|
||||
end
|
||||
elseif j >= bot/5 then
|
||||
if k*k + l*l <= 4 then
|
||||
local vi = area:index(x+k, y+j, z+l-3)
|
||||
data[vi] = nid_a
|
||||
end
|
||||
elseif j >= bot/5 * 3 then
|
||||
if k*k + l*l <= 1 then
|
||||
local vi = area:index(x+k, y+j, z+l-3)
|
||||
data[vi] = nid_b
|
||||
end
|
||||
else
|
||||
local vi = area:index(x, y+j, z-3)
|
||||
data[vi] = nid_b
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--glowing crystal stalagmite spawner
|
||||
function caverealms:salt_stalagmite(x,y,z, area, data, biome)
|
||||
|
||||
if not caverealms:below_solid(x,y,z,area,data) then
|
||||
return
|
||||
end
|
||||
|
||||
--contest ids
|
||||
local c_stone = minetest.get_content_id("default:stone")
|
||||
local c_salt = minetest.get_content_id("caverealms:salt_crystal")
|
||||
|
||||
local scale = math.random(2, 4)
|
||||
if scale == 2 then
|
||||
for j = -3, 3 do
|
||||
for k = -3, 3 do
|
||||
local vi = area:index(x+j, y, z+k)
|
||||
data[vi] = c_stone
|
||||
if math.abs(j) ~= 3 and math.abs(k) ~= 3 then
|
||||
local vi = area:index(x+j, y+1, z+k)
|
||||
data[vi] = c_stone
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
for j = -4, 4 do
|
||||
for k = -4, 4 do
|
||||
local vi = area:index(x+j, y, z+k)
|
||||
data[vi] = c_stone
|
||||
if math.abs(j) ~= 4 and math.abs(k) ~= 4 then
|
||||
local vi = area:index(x+j, y+1, z+k)
|
||||
data[vi] = c_stone
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for j = 2, scale + 2 do --y
|
||||
for k = -2, scale - 2 do
|
||||
for l = -2, scale - 2 do
|
||||
local vi = area:index(x+k, y+j, z+l)
|
||||
data[vi] = c_salt -- make cube
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--function to create giant 'shrooms
|
||||
function caverealms:giant_shroom(x, y, z, area, data)
|
||||
|
||||
if not caverealms:below_solid(x,y,z,area,data) then
|
||||
return
|
||||
end
|
||||
|
||||
--as usual, grab the content ID's
|
||||
local c_stem = minetest.get_content_id("caverealms:mushroom_stem")
|
||||
local c_cap = minetest.get_content_id("caverealms:mushroom_cap")
|
||||
local c_gills = minetest.get_content_id("caverealms:mushroom_gills")
|
||||
|
||||
z = z - 5
|
||||
--cap
|
||||
for k = -5, 5 do
|
||||
for l = -5, 5 do
|
||||
if k*k + l*l <= 25 then
|
||||
local vi = area:index(x+k, y+5, z+l)
|
||||
data[vi] = c_cap
|
||||
end
|
||||
if k*k + l*l <= 16 then
|
||||
local vi = area:index(x+k, y+6, z+l)
|
||||
data[vi] = c_cap
|
||||
vi = area:index(x+k, y+5, z+l)
|
||||
data[vi] = c_gills
|
||||
end
|
||||
if k*k + l*l <= 9 then
|
||||
local vi = area:index(x+k, y+7, z+l)
|
||||
data[vi] = c_cap
|
||||
end
|
||||
if k*k + l*l <= 4 then
|
||||
local vi = area:index(x+k, y+8, z+l)
|
||||
data[vi] = c_cap
|
||||
end
|
||||
end
|
||||
end
|
||||
--stem
|
||||
for j = 0, 5 do
|
||||
for k = -1,1 do
|
||||
local vi = area:index(x+k, y+j, z)
|
||||
data[vi] = c_stem
|
||||
if k == 0 then
|
||||
local ai = area:index(x, y+j, z+1)
|
||||
data[ai] = c_stem
|
||||
ai = area:index(x, y+j, z-1)
|
||||
data[ai] = c_stem
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function caverealms:legacy_giant_shroom(x, y, z, area, data) --leftovers :P
|
||||
--as usual, grab the content ID's
|
||||
local c_stem = minetest.get_content_id("caverealms:mushroom_stem")
|
||||
local c_cap = minetest.get_content_id("caverealms:mushroom_cap")
|
||||
|
||||
z = z - 4
|
||||
--cap
|
||||
for k = -4, 4 do
|
||||
for l = -4, 4 do
|
||||
if k*k + l*l <= 16 then
|
||||
local vi = area:index(x+k, y+5, z+l)
|
||||
data[vi] = c_cap
|
||||
end
|
||||
if k*k + l*l <= 9 then
|
||||
local vi = area:index(x+k, y+4, z+l)
|
||||
data[vi] = c_cap
|
||||
vi = area:index(x+k, y+6, z+l)
|
||||
data[vi] = c_cap
|
||||
end
|
||||
if k*k + l*l <= 4 then
|
||||
local vi = area:index(x+k, y+7, z+l)
|
||||
data[vi] = c_cap
|
||||
end
|
||||
end
|
||||
end
|
||||
--stem
|
||||
for j = 0, 4 do
|
||||
for k = -1,1 do
|
||||
local vi = area:index(x+k, y+j, z)
|
||||
data[vi] = c_stem
|
||||
if k == 0 then
|
||||
local ai = area:index(x, y+j, z+1)
|
||||
data[ai] = c_stem
|
||||
ai = area:index(x, y+j, z-1)
|
||||
data[ai] = c_stem
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Experimental and very geometric function to create giant octagonal crystals in a variety of random directions
|
||||
-- Uses calculations for points on a sphere, lines in geometric space
|
||||
-- CURRENTLY USELESS, NOT LIKELY TO BE IMPLEMENTED SOON
|
||||
function caverealms:octagon(x, y, z, area, data)
|
||||
--Grab content id's... diamond is a placeholder
|
||||
local c_crys = minetest.get_content_id("default:diamondblock")
|
||||
|
||||
local MAX_LEN = 25 --placeholder for a config file constant
|
||||
local MIN_LEN = 10 --ditto
|
||||
|
||||
local target = {x=0, y=MAX_LEN, z=0} -- 3D space coordinate of the crystal's endpoint
|
||||
|
||||
local length = math.random(MIN_LEN, MAX_LEN) --get a random length for the crystal
|
||||
local dir1 = math.random(0, 359) -- Random direction in degrees around a circle
|
||||
local dir2 = math.random(0, 180) -- Random direction in a semicircle, for 3D location
|
||||
|
||||
--OK, so now make a 3D point out of those spherical coordinates...
|
||||
target.x = math.ceil(length * math.cos(dir1 * 3.14/180)) --Round it up to make sure it's a nice integer for the coordinate system
|
||||
target.z = math.ceil(length * math.sin(dir1 * 3.14/180))
|
||||
--Y is also simple, just use dir2. Note that, due to how these calculations are carried out, this is not a coordinate on a perfect sphere. This is OK for our purposes.
|
||||
target.y = math.ceil(length * math.sin(dir2 * 3.14/180))
|
||||
|
||||
-- Now, determine if the crystal should go up or down, based on where it is
|
||||
if (caverealms:above_solid(x,y,z,area,data)) then
|
||||
target.y = target.y * -1
|
||||
end
|
||||
|
||||
--Bring the coordinates near the area you're generating
|
||||
target.x = target.x + x
|
||||
target.y = target.y + y
|
||||
target.z = target.z + z
|
||||
|
||||
|
||||
end
|
||||
|
||||
local CAVESPAWN = caverealms.config.cavespawn --false by default. Change to true in order to spawn in the caves when joining as a new player or respawning after death
|
||||
local spawned = false;
|
||||
local ydepth = -960;
|
||||
|
||||
if (CAVESPAWN) then
|
||||
minetest.register_on_newplayer(function(player)
|
||||
while spawned ~= true do
|
||||
player:setpos({x=0,y=ydepth,z=0})
|
||||
--minetest.after(2, function(player, ydepth)
|
||||
spawnplayer(player, ydepth)
|
||||
--end, player, ydepth)
|
||||
ydepth = ydepth - 80
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
while spawned ~= true do
|
||||
player:setpos({x=0,y=ydepth,z=0})
|
||||
--minetest.after(2, function(player, ydepth)
|
||||
spawnplayer(player, ydepth)
|
||||
--end, player, ydepth)
|
||||
ydepth = ydepth - 80
|
||||
end
|
||||
return true
|
||||
end)
|
||||
end
|
||||
|
||||
-- Spawn player underground
|
||||
function spawnplayer(player, ydepth)
|
||||
|
||||
local xsp
|
||||
local ysp
|
||||
local zsp
|
||||
-- 3D noise for caves
|
||||
|
||||
local np_cave = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=512, y=256, z=512}, -- squashed 2:1
|
||||
seed = 59033,
|
||||
octaves = 6,
|
||||
persist = 0.63
|
||||
}
|
||||
|
||||
-- 3D noise for wave
|
||||
|
||||
local np_wave = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=256, y=256, z=256},
|
||||
seed = -400000000089,
|
||||
octaves = 3,
|
||||
persist = 0.67
|
||||
}
|
||||
|
||||
local YMIN = caverealms.config.ymin -- Approximate realm limits.
|
||||
local YMAX = caverealms.config.ymax
|
||||
local TCAVE = caverealms.config.tcave --0.5 -- Cave threshold. 1 = small rare caves, 0.5 = 1/3rd ground volume, 0 = 1/2 ground volume
|
||||
local BLEND = 128 -- Cave blend distance near YMIN, YMAX
|
||||
|
||||
local yblmin = YMIN + BLEND * 1.5
|
||||
local yblmax = YMAX - BLEND * 1.5
|
||||
|
||||
for chunk = 1, 64 do
|
||||
print ("[caverealms] searching for spawn "..chunk)
|
||||
local x0 = 80 * math.random(-32, 32) - 32
|
||||
local z0 = 80 * math.random(-32, 32) - 32
|
||||
local y0 = ydepth-32
|
||||
local x1 = x0 + 79
|
||||
local z1 = z0 + 79
|
||||
local y1 = ydepth+47
|
||||
|
||||
local sidelen = 80
|
||||
local chulens = {x=sidelen, y=sidelen, z=sidelen}
|
||||
local minposxyz = {x=x0, y=y0, z=z0}
|
||||
local minposxz = {x=x0, y=z0}
|
||||
|
||||
local nvals_cave = minetest.get_perlin_map(np_cave, chulens):get3dMap_flat(minposxyz) --cave noise for structure
|
||||
local nvals_wave = minetest.get_perlin_map(np_wave, chulens):get3dMap_flat(minposxyz) --wavy structure of cavern ceilings and floors
|
||||
|
||||
local nixz = 1
|
||||
local nixyz = 1
|
||||
for z = z0, z1 do
|
||||
for y = y0, y1 do
|
||||
for x = x0, x1 do
|
||||
local n_abscave = math.abs(nvals_cave[nixyz])
|
||||
local n_abswave = math.abs(nvals_wave[nixyz])
|
||||
|
||||
local tcave --declare variable
|
||||
--determine the overal cave threshold
|
||||
if y < yblmin then
|
||||
tcave = TCAVE + ((yblmin - y) / BLEND) ^ 2
|
||||
elseif y > yblmax then
|
||||
tcave = TCAVE + ((y - yblmax) / BLEND) ^ 2
|
||||
else
|
||||
tcave = TCAVE
|
||||
end
|
||||
|
||||
--if y >= 1 and density > -0.01 and density < 0 then
|
||||
if (nvals_cave[nixyz] + nvals_wave[nixyz])/2 > tcave + 0.005 and (nvals_cave[nixyz] + nvals_wave[nixyz])/2 < tcave + 0.015 then --if node falls within cave threshold
|
||||
ysp = y + 1
|
||||
xsp = x
|
||||
zsp = z
|
||||
break
|
||||
end
|
||||
nixz = nixz + 1
|
||||
nixyz = nixyz + 1
|
||||
end
|
||||
if ysp then
|
||||
break
|
||||
end
|
||||
nixz = nixz - 80
|
||||
end
|
||||
if ysp then
|
||||
break
|
||||
end
|
||||
nixz = nixz + 80
|
||||
end
|
||||
if ysp then
|
||||
break
|
||||
end
|
||||
end
|
||||
print ("[caverealms] spawn player ("..xsp.." "..ysp.." "..zsp..")")
|
||||
player:setpos({x=xsp, y=ysp, z=zsp})
|
||||
spawned = true
|
||||
end
|
||||
|
||||
--minetest.register_on_newplayer(function(player)
|
||||
--spawnplayer(player)
|
||||
--end)
|
||||
|
418
worldmods/caverealms/init.lua
Normal file
@ -0,0 +1,418 @@
|
||||
-- caverealms v.0.8 by HeroOfTheWinds
|
||||
-- original cave code modified from paramat's subterrain
|
||||
-- For Minetest 0.4.8 stable
|
||||
-- Depends default
|
||||
-- License: code WTFPL
|
||||
|
||||
|
||||
caverealms = {} --create a container for functions and constants
|
||||
|
||||
--grab a shorthand for the filepath of the mod
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
--load companion lua files
|
||||
dofile(modpath.."/config.lua") --configuration file; holds various constants
|
||||
dofile(modpath.."/crafting.lua") --crafting recipes
|
||||
dofile(modpath.."/nodes.lua") --node definitions
|
||||
dofile(modpath.."/functions.lua") --function definitions
|
||||
dofile(modpath.."/abms.lua") --abm definitions
|
||||
|
||||
if caverealms.config.falling_icicles == true then
|
||||
dofile(modpath.."/falling_ice.lua") --complicated function for falling icicles
|
||||
print("[caverealms] falling icicles enabled.")
|
||||
end
|
||||
|
||||
local FORTRESSES = caverealms.config.fortresses --true | Should fortresses spawn?
|
||||
local FOUNTAINS = caverealms.config.fountains --true | Should fountains spawn?
|
||||
|
||||
-- Parameters
|
||||
|
||||
local YMIN = caverealms.config.ymin -- Approximate realm limits.
|
||||
local YMAX = caverealms.config.ymax
|
||||
local TCAVE = caverealms.config.tcave --0.5 -- Cave threshold. 1 = small rare caves, 0.5 = 1/3rd ground volume, 0 = 1/2 ground volume
|
||||
local BLEND = 128 -- Cave blend distance near YMIN, YMAX
|
||||
|
||||
local STAGCHA = caverealms.config.stagcha --0.002 --chance of stalagmites
|
||||
local STALCHA = caverealms.config.stalcha --0.003 --chance of stalactites
|
||||
local CRYSTAL = caverealms.config.crystal --0.007 --chance of glow crystal formations
|
||||
local GEMCHA = caverealms.config.gemcha --0.03 --chance of small glow gems
|
||||
local MUSHCHA = caverealms.config.mushcha --0.04 --chance of mushrooms
|
||||
local MYCCHA = caverealms.config.myccha --0.03 --chance of mycena mushrooms
|
||||
local WORMCHA = caverealms.config.wormcha --0.03 --chance of glow worms
|
||||
local GIANTCHA = caverealms.config.giantcha --0.001 -- chance of giant mushrooms
|
||||
local ICICHA = caverealms.config.icicha --0.035 -- chance of icicles
|
||||
local FLACHA = caverealms.config.flacha --0.04 --chance of constant flames
|
||||
local FOUNCHA = caverealms.config.founcha --0.001 --chance of statue + fountain
|
||||
local FORTCHA = caverealms.config.fortcha --0.0003 --chance of DM Fortresses
|
||||
|
||||
local DM_TOP = caverealms.config.dm_top -- -4000 --level at which Dungeon Master Realms start to appear
|
||||
local DM_BOT = caverealms.config.dm_bot -- -5000 --level at which "" ends
|
||||
local DEEP_CAVE = caverealms.config.deep_cave -- -7000 --level at which deep cave biomes take over
|
||||
|
||||
-- 3D noise for caves
|
||||
|
||||
local np_cave = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=512, y=256, z=512}, -- squashed 2:1
|
||||
seed = 59033,
|
||||
octaves = 6,
|
||||
persist = 0.63
|
||||
}
|
||||
|
||||
-- 3D noise for wave
|
||||
|
||||
local np_wave = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=256, y=256, z=256},
|
||||
seed = -400000000089,
|
||||
octaves = 3,
|
||||
persist = 0.67
|
||||
}
|
||||
|
||||
-- 2D noise for biome
|
||||
|
||||
local np_biome = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x=250, y=250, z=250},
|
||||
seed = 9130,
|
||||
octaves = 3,
|
||||
persist = 0.5
|
||||
}
|
||||
|
||||
-- Stuff
|
||||
|
||||
subterrain = {}
|
||||
|
||||
local yblmin = YMIN + BLEND * 1.5
|
||||
local yblmax = YMAX - BLEND * 1.5
|
||||
|
||||
-- On generated function
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
--if out of range of caverealms limits
|
||||
if minp.y > YMAX or maxp.y < YMIN then
|
||||
return --quit; otherwise, you'd have stalagmites all over the place
|
||||
end
|
||||
|
||||
--easy reference to commonly used values
|
||||
local t1 = os.clock()
|
||||
local x1 = maxp.x
|
||||
local y1 = maxp.y
|
||||
local z1 = maxp.z
|
||||
local x0 = minp.x
|
||||
local y0 = minp.y
|
||||
local z0 = minp.z
|
||||
|
||||
print ("[caverealms] chunk minp ("..x0.." "..y0.." "..z0..")") --tell people you are generating a chunk
|
||||
|
||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||
local data = vm:get_data()
|
||||
|
||||
--grab content IDs
|
||||
local c_air = minetest.get_content_id("air")
|
||||
local c_stone = minetest.get_content_id("default:stone")
|
||||
|
||||
if (minetest.get_modpath("moontest")) then
|
||||
c_air = minetest.get_content_id("moontest:vacuum")
|
||||
c_stone = minetest.get_content_id("moontest:stone")
|
||||
end
|
||||
|
||||
local c_water = minetest.get_content_id("default:water_source")
|
||||
local c_lava = minetest.get_content_id("default:lava_source")
|
||||
local c_ice = minetest.get_content_id("default:ice")
|
||||
local c_thinice = minetest.get_content_id("caverealms:thin_ice")
|
||||
local c_crystal = minetest.get_content_id("caverealms:glow_crystal")
|
||||
local c_gem1 = minetest.get_content_id("caverealms:glow_gem")
|
||||
local c_gem2 = minetest.get_content_id("caverealms:glow_gem_2")
|
||||
local c_gem3 = minetest.get_content_id("caverealms:glow_gem_3")
|
||||
local c_gem4 = minetest.get_content_id("caverealms:glow_gem_4")
|
||||
local c_gem5 = minetest.get_content_id("caverealms:glow_gem_5")
|
||||
local c_saltgem1 = minetest.get_content_id("caverealms:salt_gem")
|
||||
local c_saltgem2 = minetest.get_content_id("caverealms:salt_gem_2")
|
||||
local c_saltgem3 = minetest.get_content_id("caverealms:salt_gem_3")
|
||||
local c_saltgem4 = minetest.get_content_id("caverealms:salt_gem_4")
|
||||
local c_saltgem5 = minetest.get_content_id("caverealms:salt_gem_5")
|
||||
local c_spike1 = minetest.get_content_id("caverealms:spike")
|
||||
local c_spike2 = minetest.get_content_id("caverealms:spike_2")
|
||||
local c_spike3 = minetest.get_content_id("caverealms:spike_3")
|
||||
local c_spike4 = minetest.get_content_id("caverealms:spike_4")
|
||||
local c_spike5 = minetest.get_content_id("caverealms:spike_5")
|
||||
local c_moss = minetest.get_content_id("caverealms:stone_with_moss")
|
||||
local c_lichen = minetest.get_content_id("caverealms:stone_with_lichen")
|
||||
local c_algae = minetest.get_content_id("caverealms:stone_with_algae")
|
||||
local c_salt = minetest.get_content_id("caverealms:stone_with_salt")
|
||||
local c_hcobble = minetest.get_content_id("caverealms:hot_cobble")
|
||||
local c_gobsidian = minetest.get_content_id("caverealms:glow_obsidian")
|
||||
local c_gobsidian2 = minetest.get_content_id("caverealms:glow_obsidian_2")
|
||||
local c_coalblock = minetest.get_content_id("default:coalblock")
|
||||
local c_desand = minetest.get_content_id("default:desert_sand")
|
||||
local c_coaldust = minetest.get_content_id("caverealms:coal_dust")
|
||||
local c_fungus = minetest.get_content_id("caverealms:fungus")
|
||||
local c_mycena = minetest.get_content_id("caverealms:mycena")
|
||||
local c_worm = minetest.get_content_id("caverealms:glow_worm")
|
||||
local c_iciu = minetest.get_content_id("caverealms:icicle_up")
|
||||
local c_icid = minetest.get_content_id("caverealms:icicle_down")
|
||||
local c_flame = minetest.get_content_id("caverealms:constant_flame")
|
||||
local c_fountain = minetest.get_content_id("caverealms:s_fountain")
|
||||
local c_fortress = minetest.get_content_id("caverealms:s_fortress")
|
||||
|
||||
--mandatory values
|
||||
local sidelen = x1 - x0 + 1 --length of a mapblock
|
||||
local chulens = {x=sidelen, y=sidelen, z=sidelen} --table of chunk edges
|
||||
local chulens2D = {x=sidelen, y=sidelen, z=1}
|
||||
local minposxyz = {x=x0, y=y0, z=z0} --bottom corner
|
||||
local minposxz = {x=x0, y=z0} --2D bottom corner
|
||||
|
||||
local nvals_cave = minetest.get_perlin_map(np_cave, chulens):get3dMap_flat(minposxyz) --cave noise for structure
|
||||
local nvals_wave = minetest.get_perlin_map(np_wave, chulens):get3dMap_flat(minposxyz) --wavy structure of cavern ceilings and floors
|
||||
local nvals_biome = minetest.get_perlin_map(np_biome, chulens2D):get2dMap_flat({x=x0+150, y=z0+50}) --2D noise for biomes (will be 3D humidity/temp later)
|
||||
|
||||
local nixyz = 1 --3D node index
|
||||
local nixz = 1 --2D node index
|
||||
local nixyz2 = 1 --second 3D index for second loop
|
||||
|
||||
for z = z0, z1 do -- for each xy plane progressing northwards
|
||||
--structure loop
|
||||
for y = y0, y1 do -- for each x row progressing upwards
|
||||
local tcave --declare variable
|
||||
--determine the overal cave threshold
|
||||
if y < yblmin then
|
||||
tcave = TCAVE + ((yblmin - y) / BLEND) ^ 2
|
||||
elseif y > yblmax then
|
||||
tcave = TCAVE + ((y - yblmax) / BLEND) ^ 2
|
||||
else
|
||||
tcave = TCAVE
|
||||
end
|
||||
local vi = area:index(x0, y, z) --current node index
|
||||
for x = x0, x1 do -- for each node do
|
||||
if (nvals_cave[nixyz] + nvals_wave[nixyz])/2 > tcave then --if node falls within cave threshold
|
||||
data[vi] = c_air --hollow it out to make the cave
|
||||
end
|
||||
--increment indices
|
||||
nixyz = nixyz + 1
|
||||
vi = vi + 1
|
||||
end
|
||||
end
|
||||
|
||||
--decoration loop
|
||||
for y = y0, y1 do -- for each x row progressing upwards
|
||||
|
||||
local is_deep = false
|
||||
if y < DEEP_CAVE then
|
||||
is_deep = true
|
||||
end
|
||||
|
||||
local tcave --same as above
|
||||
if y < yblmin then
|
||||
tcave = TCAVE + ((yblmin - y) / BLEND) ^ 2
|
||||
elseif y > yblmax then
|
||||
tcave = TCAVE + ((y - yblmax) / BLEND) ^ 2
|
||||
else
|
||||
tcave = TCAVE
|
||||
end
|
||||
local vi = area:index(x0, y, z)
|
||||
for x = x0, x1 do -- for each node do
|
||||
|
||||
--determine biome
|
||||
local biome = false --preliminary declaration
|
||||
local n_biome = nvals_biome[nixz] --make an easier reference to the noise
|
||||
--compare noise values to determine a biome
|
||||
if n_biome >= 0 and n_biome < 0.5 then
|
||||
biome = 1 --moss
|
||||
if is_deep then
|
||||
biome = 7 --salt crystal
|
||||
end
|
||||
elseif n_biome <= -0.5 then
|
||||
biome = 2 --fungal
|
||||
if is_deep then
|
||||
biome = 8 --glow obsidian
|
||||
end
|
||||
elseif n_biome >= 0.5 then
|
||||
if n_biome >= 0.7 then
|
||||
biome = 5 --deep glaciated
|
||||
else
|
||||
biome = 4 --glaciated
|
||||
end
|
||||
else
|
||||
biome = 3 --algae
|
||||
if is_deep then
|
||||
biome = 9 --coal dust
|
||||
end
|
||||
end
|
||||
|
||||
if y <= DM_TOP and y >= DM_BOT then
|
||||
biome = 6 --DUNGEON MASTER'S LAIR
|
||||
end
|
||||
--if y <= -1000 then
|
||||
--biome = 6 --DUNGEON MASTER'S LAIR
|
||||
--end
|
||||
|
||||
if math.floor(((nvals_cave[nixyz2] + nvals_wave[nixyz2])/2)*100) == math.floor(tcave*100) then
|
||||
--ceiling
|
||||
local ai = area:index(x,y+1,z) --above index
|
||||
if data[ai] == c_stone and data[vi] == c_air then --ceiling
|
||||
if math.random() < ICICHA and (biome == 4 or biome == 5) then
|
||||
data[vi] = c_icid
|
||||
end
|
||||
if math.random() < WORMCHA then
|
||||
data[vi] = c_worm
|
||||
local bi = area:index(x,y-1,z)
|
||||
data[bi] = c_worm
|
||||
if math.random(2) == 1 then
|
||||
local bbi = area:index(x,y-2,z)
|
||||
data[bbi] = c_worm
|
||||
if math.random(2) ==1 then
|
||||
local bbbi = area:index(x,y-3,z)
|
||||
data[bbbi] = c_worm
|
||||
end
|
||||
end
|
||||
end
|
||||
if math.random() < STALCHA then
|
||||
caverealms:stalactite(x,y,z, area, data)
|
||||
end
|
||||
if math.random() < CRYSTAL then
|
||||
caverealms:crystal_stalactite(x,y,z, area, data, biome)
|
||||
end
|
||||
end
|
||||
--ground
|
||||
local bi = area:index(x,y-1,z) --below index
|
||||
if data[bi] == c_stone and data[vi] == c_air then --ground
|
||||
local ai = area:index(x,y+1,z)
|
||||
--place floor material, add plants/decorations
|
||||
if biome == 1 then
|
||||
data[vi] = c_moss
|
||||
if math.random() < GEMCHA then
|
||||
-- gems of random size
|
||||
local gems = { c_gem1, c_gem2, c_gem3, c_gem4, c_gem5 }
|
||||
local gidx = math.random(1, 12)
|
||||
if gidx > 5 then
|
||||
gidx = 1
|
||||
end
|
||||
data[ai] = gems[gidx]
|
||||
end
|
||||
elseif biome == 2 then
|
||||
data[vi] = c_lichen
|
||||
if math.random() < MUSHCHA then --mushrooms
|
||||
data[ai] = c_fungus
|
||||
end
|
||||
if math.random() < MYCCHA then --mycena mushrooms
|
||||
data[ai] = c_mycena
|
||||
end
|
||||
if math.random() < GIANTCHA then --giant mushrooms
|
||||
caverealms:giant_shroom(x, y, z, area, data)
|
||||
end
|
||||
elseif biome == 3 then
|
||||
data[vi] = c_algae
|
||||
elseif biome == 4 then
|
||||
data[vi] = c_thinice
|
||||
local bi = area:index(x,y-1,z)
|
||||
data[bi] = c_thinice
|
||||
if math.random() < ICICHA then --if glaciated, place icicles
|
||||
data[ai] = c_iciu
|
||||
end
|
||||
elseif biome == 5 then
|
||||
data[vi] = c_ice
|
||||
local bi = area:index(x,y-1,z)
|
||||
data[bi] = c_ice
|
||||
if math.random() < ICICHA then --if glaciated, place icicles
|
||||
data[ai] = c_iciu
|
||||
end
|
||||
elseif biome == 6 then
|
||||
data[vi] = c_hcobble
|
||||
if math.random() < FLACHA then --neverending flames
|
||||
data[ai] = c_flame
|
||||
end
|
||||
if math.random() < FOUNCHA and FOUNTAINS then --DM FOUNTAIN
|
||||
data[ai] = c_fountain
|
||||
end
|
||||
if math.random() < FORTCHA and FORTRESSES then --DM FORTRESS
|
||||
data[ai] = c_fortress
|
||||
end
|
||||
elseif biome == 7 then
|
||||
local bi = area:index(x,y-1,z)
|
||||
data[vi] = c_salt
|
||||
data[bi] = c_salt
|
||||
if math.random() < GEMCHA then
|
||||
-- gems of random size
|
||||
local gems = { c_saltgem1, c_saltgem2, c_saltgem3, c_saltgem4, c_saltgem5 }
|
||||
local gidx = math.random(1, 12)
|
||||
if gidx > 5 then
|
||||
gidx = 1
|
||||
end
|
||||
data[ai] = gems[gidx]
|
||||
end
|
||||
if math.random() < STAGCHA then
|
||||
caverealms:salt_stalagmite(x,y,z, area, data)
|
||||
end
|
||||
elseif biome == 8 then
|
||||
local bi = area:index(x,y-1,z)
|
||||
if math.random() < 0.5 then
|
||||
data[vi] = c_gobsidian
|
||||
data[bi] = c_gobsidian
|
||||
else
|
||||
data[vi] = c_gobsidian2
|
||||
data[bi] = c_gobsidian2
|
||||
end
|
||||
if math.random() < FLACHA then --neverending flames
|
||||
data[ai] = c_flame
|
||||
end
|
||||
elseif biome == 9 then
|
||||
local bi = area:index(x,y-1,z)
|
||||
if math.random() < 0.05 then
|
||||
data[vi] = c_coalblock
|
||||
data[bi] = c_coalblock
|
||||
elseif math.random() < 0.15 then
|
||||
data[vi] = c_coaldust
|
||||
data[bi] = c_coaldust
|
||||
else
|
||||
data[vi] = c_desand
|
||||
data[bi] = c_desand
|
||||
end
|
||||
if math.random() < FLACHA * 0.75 then --neverending flames
|
||||
data[ai] = c_flame
|
||||
end
|
||||
if math.random() < GEMCHA then
|
||||
-- spikes of random size
|
||||
local spikes = { c_spike1, c_spike2, c_spike3, c_spike4, c_spike5 }
|
||||
local sidx = math.random(1, 12)
|
||||
if sidx > 5 then
|
||||
sidx = 1
|
||||
end
|
||||
data[ai] = spikes[sidx]
|
||||
end
|
||||
end
|
||||
|
||||
if math.random() < STAGCHA then
|
||||
caverealms:stalagmite(x,y,z, area, data)
|
||||
end
|
||||
if math.random() < CRYSTAL then
|
||||
caverealms:crystal_stalagmite(x,y,z, area, data, biome)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
nixyz2 = nixyz2 + 1
|
||||
nixz = nixz + 1
|
||||
vi = vi + 1
|
||||
end
|
||||
nixz = nixz - sidelen --shift the 2D index back
|
||||
end
|
||||
nixz = nixz + sidelen --shift the 2D index up a layer
|
||||
end
|
||||
|
||||
--send data back to voxelmanip
|
||||
vm:set_data(data)
|
||||
--calc lighting
|
||||
vm:set_lighting({day=0, night=0})
|
||||
vm:calc_lighting()
|
||||
--write it to world
|
||||
vm:write_to_map(data)
|
||||
|
||||
local chugent = math.ceil((os.clock() - t1) * 1000) --grab how long it took
|
||||
print ("[caverealms] "..chugent.." ms") --tell people how long
|
||||
end)
|
||||
print("[caverealms] loaded!")
|
616
worldmods/caverealms/nodes.lua
Normal file
@ -0,0 +1,616 @@
|
||||
-- CaveRealms nodes.lua
|
||||
|
||||
--NODES--
|
||||
|
||||
local FALLING_ICICLES = caverealms.config.falling_icicles --true --toggle to turn on or off falling icicles in glaciated biome
|
||||
local FALLCHA = caverealms.config.fallcha --0.33 --chance of causing the structure to fall
|
||||
local DM_TOP = caverealms.config.dm_top -- -4000 --level at which Dungeon Master Realms start to appear
|
||||
|
||||
|
||||
--glowing crystal
|
||||
minetest.register_node("caverealms:glow_crystal", {
|
||||
description = "Glow Crystal",
|
||||
tiles = {"caverealms_glow_crystal.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
light_source = 13,
|
||||
paramtype = "light",
|
||||
use_texture_alpha = true,
|
||||
drawtype = "glasslike",
|
||||
sunlight_propagates = true,
|
||||
})
|
||||
|
||||
--glowing emerald
|
||||
minetest.register_node("caverealms:glow_emerald", {
|
||||
description = "Glow Emerald",
|
||||
tiles = {"caverealms_glow_emerald.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
light_source = 13,
|
||||
paramtype = "light",
|
||||
use_texture_alpha = true,
|
||||
drawtype = "glasslike",
|
||||
sunlight_propagates = true,
|
||||
})
|
||||
|
||||
--glowing mese crystal blocks
|
||||
minetest.register_node("caverealms:glow_mese", {
|
||||
description = "Mese Crystal Block",
|
||||
tiles = {"caverealms_glow_mese.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
light_source = 13,
|
||||
paramtype = "light",
|
||||
use_texture_alpha = true,
|
||||
drawtype = "glasslike",
|
||||
sunlight_propagates = true,
|
||||
})
|
||||
|
||||
--glowing ruby
|
||||
minetest.register_node("caverealms:glow_ruby", {
|
||||
description = "Glow Ruby",
|
||||
tiles = {"caverealms_glow_ruby.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
light_source = 13,
|
||||
paramtype = "light",
|
||||
use_texture_alpha = true,
|
||||
drawtype = "glasslike",
|
||||
sunlight_propagates = true,
|
||||
})
|
||||
|
||||
--glowing amethyst
|
||||
minetest.register_node("caverealms:glow_amethyst", {
|
||||
description = "Glow Amethyst",
|
||||
tiles = {"caverealms_glow_amethyst.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
light_source = 13,
|
||||
paramtype = "light",
|
||||
use_texture_alpha = true,
|
||||
drawtype = "glasslike",
|
||||
sunlight_propagates = true,
|
||||
})
|
||||
|
||||
--embedded crystal
|
||||
minetest.register_node("caverealms:glow_ore", {
|
||||
description = "Glow Crystal Ore",
|
||||
tiles = {"caverealms_glow_ore.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=2},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
light_source = 10,
|
||||
paramtype = "light",
|
||||
})
|
||||
|
||||
--embedded emerald
|
||||
minetest.register_node("caverealms:glow_emerald_ore", {
|
||||
description = "Glow Emerald Ore",
|
||||
tiles = {"caverealms_glow_emerald_ore.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=2},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
light_source = 10,
|
||||
paramtype = "light",
|
||||
})
|
||||
|
||||
--embedded ruby
|
||||
minetest.register_node("caverealms:glow_ruby_ore", {
|
||||
description = "Glow Ruby Ore",
|
||||
tiles = {"caverealms_glow_ruby_ore.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=2},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
light_source = 10,
|
||||
paramtype = "light",
|
||||
})
|
||||
|
||||
--embedded amethyst
|
||||
minetest.register_node("caverealms:glow_amethyst_ore", {
|
||||
description = "Glow Amethyst Ore",
|
||||
tiles = {"caverealms_glow_amethyst_ore.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=2},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
light_source = 10,
|
||||
paramtype = "light",
|
||||
})
|
||||
|
||||
--thin (transparent) ice
|
||||
minetest.register_node("caverealms:thin_ice", {
|
||||
description = "Thin Ice",
|
||||
tiles = {"caverealms_thin_ice.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
use_texture_alpha = true,
|
||||
drawtype = "glasslike",
|
||||
sunlight_propagates = true,
|
||||
freezemelt = "default:water_source",
|
||||
paramtype = "light",
|
||||
})
|
||||
|
||||
--salt crystal
|
||||
minetest.register_node("caverealms:salt_crystal", {
|
||||
description = "Salt Crystal",
|
||||
tiles = {"caverealms_salt_crystal.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
light_source = 11,
|
||||
paramtype = "light",
|
||||
use_texture_alpha = true,
|
||||
drawtype = "glasslike",
|
||||
sunlight_propagates = true,
|
||||
})
|
||||
|
||||
--alternate version for stalactites
|
||||
minetest.register_node("caverealms:hanging_thin_ice", {
|
||||
description = "Thin Ice",
|
||||
tiles = {"caverealms_thin_ice.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
use_texture_alpha = true,
|
||||
drawtype = "glasslike",
|
||||
sunlight_propagates = true,
|
||||
drop = "caverealms:thin_ice",
|
||||
freezemelt = "default:water_flowing",
|
||||
paramtype = "light",
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
if FALLING_ICICLES then
|
||||
if math.random() <= FALLCHA then
|
||||
obj = minetest.add_entity(pos, "caverealms:falling_ice")
|
||||
obj:get_luaentity():set_node(oldnode)
|
||||
for y = -13, 13 do
|
||||
for x = -3, 3 do
|
||||
for z = -3, 3 do
|
||||
local npos = {x=pos.x+x, y=pos.y+y, z=pos.z+z}
|
||||
if minetest.get_node(npos).name == "caverealms:hanging_thin_ice" then
|
||||
nobj = minetest.add_entity(npos, "caverealms:falling_ice")
|
||||
nobj:get_luaentity():set_node(oldnode)
|
||||
minetest.remove_node(npos)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
minetest.remove_node(pos)
|
||||
else
|
||||
return 1
|
||||
end
|
||||
else
|
||||
return 1
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--glowing crystal gem
|
||||
local glow_gem_size = { 1.0, 1.2, 1.4, 1.6, 1.7 }
|
||||
|
||||
for i in ipairs(glow_gem_size) do
|
||||
if i == 1 then
|
||||
nodename = "caverealms:glow_gem"
|
||||
else
|
||||
nodename = "caverealms:glow_gem_"..i
|
||||
end
|
||||
|
||||
vs = glow_gem_size[i]
|
||||
|
||||
minetest.register_node(nodename, {
|
||||
description = "Glow Gem",
|
||||
tiles = {"caverealms_glow_gem.png"},
|
||||
inventory_image = "caverealms_glow_gem.png",
|
||||
wield_image = "caverealms_glow_gem.png",
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3, oddly_breakable_by_hand=1},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
light_source = 11,
|
||||
paramtype = "light",
|
||||
drawtype = "plantlike",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
visual_scale = vs,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5*vs, -0.5*vs, -0.5*vs, 0.5*vs, -5/16*vs, 0.5*vs},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
--glowing salt gem
|
||||
local salt_gem_size = { 1.0, 1.2, 1.4, 1.6, 1.7 }
|
||||
|
||||
for i in ipairs(salt_gem_size) do
|
||||
if i == 1 then
|
||||
nodename = "caverealms:salt_gem"
|
||||
else
|
||||
nodename = "caverealms:salt_gem_"..i
|
||||
end
|
||||
|
||||
vs = salt_gem_size[i]
|
||||
|
||||
minetest.register_node(nodename, {
|
||||
description = "Salt Gem",
|
||||
tiles = {"caverealms_salt_gem.png"},
|
||||
inventory_image = "caverealms_salt_gem.png",
|
||||
wield_image = "caverealms_salt_gem.png",
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3, oddly_breakable_by_hand=1},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
light_source = 11,
|
||||
paramtype = "light",
|
||||
drawtype = "plantlike",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
visual_scale = vs,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5*vs, -0.5*vs, -0.5*vs, 0.5*vs, -5/16*vs, 0.5*vs},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
--stone spike
|
||||
local spike_size = { 1.0, 1.2, 1.4, 1.6, 1.7 }
|
||||
|
||||
for i in ipairs(spike_size) do
|
||||
if i == 1 then
|
||||
nodename = "caverealms:spike"
|
||||
else
|
||||
nodename = "caverealms:spike_"..i
|
||||
end
|
||||
|
||||
vs = spike_size[i]
|
||||
|
||||
minetest.register_node(nodename, {
|
||||
description = "Stone Spike",
|
||||
tiles = {"caverealms_spike.png"},
|
||||
inventory_image = "caverealms_spike.png",
|
||||
wield_image = "caverealms_spike.png",
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3, oddly_breakable_by_hand=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
light_source = 3,
|
||||
paramtype = "light",
|
||||
drawtype = "plantlike",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
visual_scale = vs,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5*vs, -0.5*vs, -0.5*vs, 0.5*vs, -5/16*vs, 0.5*vs},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
--upward pointing icicle
|
||||
minetest.register_node("caverealms:icicle_up", {
|
||||
description = "Icicle",
|
||||
tiles = {"caverealms_icicle_up.png"},
|
||||
inventory_image = "caverealms_icicle_up.png",
|
||||
wield_image = "caverealms_icicle_up.png",
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3, oddly_breakable_by_hand=1},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
light_source = 8,
|
||||
paramtype = "light",
|
||||
drawtype = "plantlike",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
visual_scale = 1.0,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
|
||||
},
|
||||
})
|
||||
|
||||
--downward pointing icicle
|
||||
minetest.register_node("caverealms:icicle_down", {
|
||||
description = "Icicle",
|
||||
tiles = {"caverealms_icicle_down.png"},
|
||||
inventory_image = "caverealms_icicle_down.png",
|
||||
wield_image = "caverealms_icicle_down.png",
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3, oddly_breakable_by_hand=1},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
light_source = 8,
|
||||
paramtype = "light",
|
||||
drawtype = "plantlike",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
visual_scale = 1.0,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
|
||||
},
|
||||
})
|
||||
|
||||
--cave mossy cobble - bluish?
|
||||
minetest.register_node("caverealms:stone_with_moss", {
|
||||
description = "Cave Stone with Moss",
|
||||
tiles = {"default_cobble.png^caverealms_moss.png", "default_cobble.png", "default_cobble.png^caverealms_moss_side.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
drop = 'default:cobble',
|
||||
sounds = default.node_sound_dirt_defaults({
|
||||
footstep = {name="default_grass_footstep", gain=0.25},
|
||||
}),
|
||||
})
|
||||
|
||||
--cave lichen-covered cobble - purple-ish
|
||||
minetest.register_node("caverealms:stone_with_lichen", {
|
||||
description = "Cave Stone with Lichen",
|
||||
tiles = {"default_cobble.png^caverealms_lichen.png", "default_cobble.png", "default_cobble.png^caverealms_lichen_side.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
drop = 'default:cobble',
|
||||
sounds = default.node_sound_dirt_defaults({
|
||||
footstep = {name="default_grass_footstep", gain=0.25},
|
||||
}),
|
||||
})
|
||||
|
||||
--cave algae-covered cobble - yellow-ish
|
||||
minetest.register_node("caverealms:stone_with_algae", {
|
||||
description = "Cave Stone with Algae",
|
||||
tiles = {"default_cobble.png^caverealms_algae.png", "default_cobble.png", "default_cobble.png^caverealms_algae_side.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
drop = 'default:cobble',
|
||||
sounds = default.node_sound_dirt_defaults({
|
||||
footstep = {name="default_grass_footstep", gain=0.25},
|
||||
}),
|
||||
})
|
||||
|
||||
--tiny-salt-crystal-covered cobble - pink-ish
|
||||
minetest.register_node("caverealms:stone_with_salt", {
|
||||
description = "Cave Stone with Salt",
|
||||
tiles = {"caverealms_salty2.png"},--{"caverealms_salty2.png^caverealms_salty.png", "caverealms_salty2.png", "caverealms_salty2.png^caverealms_salty_side.png"},
|
||||
light_source = 9,
|
||||
paramtype = "light",
|
||||
use_texture_alpha = true,
|
||||
drawtype = "glasslike",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
})
|
||||
|
||||
--Hot Cobble - cobble with lava instead of mortar XD
|
||||
minetest.register_node("caverealms:hot_cobble", {
|
||||
description = "Hot Cobble",
|
||||
tiles = {"caverealms_hot_cobble.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=2, hot=1},
|
||||
damage_per_second = 1,
|
||||
light_source = 3,
|
||||
sounds = default.node_sound_stone_defaults({
|
||||
footstep = {name="default_stone_footstep", gain=0.25},
|
||||
}),
|
||||
})
|
||||
|
||||
--Glow Obsidian
|
||||
minetest.register_node("caverealms:glow_obsidian", {
|
||||
description = "Glowing Obsidian",
|
||||
tiles = {"caverealms_glow_obsidian.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=1},
|
||||
light_source = 7,
|
||||
sounds = default.node_sound_stone_defaults({
|
||||
footstep = {name="default_stone_footstep", gain=0.25},
|
||||
}),
|
||||
})
|
||||
|
||||
--Glow Obsidian 2 - has traces of lava
|
||||
minetest.register_node("caverealms:glow_obsidian_2", {
|
||||
description = "Hot Glow Obsidian",
|
||||
tiles = {"caverealms_glow_obsidian2.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=1, hot=1},
|
||||
damage_per_second = 1,
|
||||
light_source = 9,
|
||||
sounds = default.node_sound_stone_defaults({
|
||||
footstep = {name="default_stone_footstep", gain=0.25},
|
||||
}),
|
||||
})
|
||||
|
||||
--Coal Dust
|
||||
minetest.register_node("caverealms:coal_dust", {
|
||||
description = "Coal Dust",
|
||||
tiles = {"caverealms_coal_dust.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3, falling_node=1, sand=1},
|
||||
sounds = default.node_sound_sand_defaults(),
|
||||
})
|
||||
|
||||
--glow worms
|
||||
minetest.register_node("caverealms:glow_worm", {
|
||||
description = "Glow Worms",
|
||||
tiles = {"caverealms_glow_worm.png"},
|
||||
inventory_image = "caverealms_glow_worm.png",
|
||||
wield_image = "caverealms_glow_worm.png",
|
||||
is_ground_content = true,
|
||||
groups = {oddly_breakable_by_hand=3},
|
||||
light_source = 9,
|
||||
paramtype = "light",
|
||||
drawtype = "plantlike",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
visual_scale = 1.0,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -0.5, 0.5},
|
||||
},
|
||||
})
|
||||
|
||||
--cave plants go here
|
||||
|
||||
--glowing fungi
|
||||
minetest.register_node("caverealms:fungus", {
|
||||
description = "Glowing Fungus",
|
||||
tiles = {"caverealms_fungi.png"},
|
||||
inventory_image = "caverealms_fungi.png",
|
||||
wield_image = "caverealms_fungi.png",
|
||||
is_ground_content = true,
|
||||
groups = {oddly_breakable_by_hand=3},
|
||||
light_source = 5,
|
||||
paramtype = "light",
|
||||
drawtype = "plantlike",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
visual_scale = 1.0,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
|
||||
},
|
||||
})
|
||||
|
||||
--mycena mushroom
|
||||
minetest.register_node("caverealms:mycena", {
|
||||
description = "Mycena Mushroom",
|
||||
tiles = {"caverealms_mycena.png"},
|
||||
inventory_image = "caverealms_mycena.png",
|
||||
wield_image = "caverealms_mycena.png",
|
||||
is_ground_content = true,
|
||||
groups = {oddly_breakable_by_hand=3},
|
||||
light_source = 6,
|
||||
paramtype = "light",
|
||||
drawtype = "plantlike",
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
visual_scale = 1.0,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
|
||||
},
|
||||
})
|
||||
|
||||
--giant mushroom
|
||||
--stem
|
||||
minetest.register_node("caverealms:mushroom_stem", {
|
||||
description = "Giant Mushroom Stem",
|
||||
tiles = {"caverealms_mushroom_stem.png"},
|
||||
is_ground_content = true,
|
||||
groups = {oddly_breakable_by_hand=1},
|
||||
})
|
||||
|
||||
--cap
|
||||
minetest.register_node("caverealms:mushroom_cap", {
|
||||
description = "Giant Mushroom Cap",
|
||||
tiles = {"caverealms_mushroom_cap.png"},
|
||||
is_ground_content = true,
|
||||
groups = {oddly_breakable_by_hand=1},
|
||||
})
|
||||
|
||||
--gills
|
||||
minetest.register_node("caverealms:mushroom_gills", {
|
||||
description = "Giant Mushroom Gills",
|
||||
tiles = {"caverealms_mushroom_gills.png"},
|
||||
is_ground_content = true,
|
||||
groups = {oddly_breakable_by_hand=1},
|
||||
drawtype = "plantlike",
|
||||
paramtype = "light",
|
||||
})
|
||||
|
||||
--define special flame so that it does not expire
|
||||
minetest.register_node("caverealms:constant_flame", {
|
||||
description = "Fire",
|
||||
drawtype = "plantlike",
|
||||
tiles = {{
|
||||
name="fire_basic_flame_animated.png",
|
||||
animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1},
|
||||
}},
|
||||
inventory_image = "fire_basic_flame.png",
|
||||
light_source = 14,
|
||||
groups = {igniter=2,dig_immediate=3,hot=3, not_in_creative_inventory=1},
|
||||
drop = '',
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
damage_per_second = 4,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
if pos.y > DM_TOP then
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
if not (minetest.get_modpath("moontest")) then
|
||||
fire.on_flame_add_at(pos)
|
||||
end
|
||||
end,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
if not (minetest.get_modpath("moontest")) then
|
||||
fire.on_flame_remove_at(pos)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--node to create a treasure chest in DM Forts.
|
||||
minetest.register_node("caverealms:s_chest", {
|
||||
description = "Trying to rob the bank before it's opened, eh?",
|
||||
tiles = {"default_chest_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy=3,oddly_breakable_by_hand=2,cavechest=1, not_in_creative_inventory=1},
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
if pos.y > DM_TOP then
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--hacky schematic placers
|
||||
|
||||
minetest.register_node("caverealms:s_fountain", {
|
||||
description = "A Hack like you should know what this does...",
|
||||
tiles = {"caverealms_stone_eyes.png"},
|
||||
groups = {crumbly=3, schema=1, not_in_creative_inventory=1},
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
if pos.y > DM_TOP then
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("caverealms:s_fortress", {
|
||||
description = "A Hack like you should know what this does...",
|
||||
tiles = {"caverealms_stone_eyes.png"},
|
||||
groups = {crumbly=3, schema=1, not_in_creative_inventory=1},
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
if pos.y > DM_TOP then
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--dungeon master statue (nodebox)
|
||||
minetest.register_node("caverealms:dm_statue", {
|
||||
tiles = {
|
||||
"caverealms_dm_stone.png",
|
||||
"caverealms_dm_stone.png",
|
||||
"caverealms_dm_stone.png",
|
||||
"caverealms_dm_stone.png",
|
||||
"caverealms_dm_stone.png",
|
||||
"caverealms_stone_eyes.png"
|
||||
},
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.4375, -0.5, -0.4375, 0.4375, -0.3125, 0.4375}, -- NodeBox1
|
||||
{-0.25, -0.125, -0.1875, 0.25, 0.5, 0.1875}, -- NodeBox2
|
||||
{-0.375, 0, -0.125, -0.25, 0.4375, 0.125}, -- NodeBox3
|
||||
{0.25, 0.125, -0.4375, 0.375, 0.375, 0.1875}, -- NodeBox4
|
||||
{-0.25, -0.5, -0.125, -0.125, -0.125, 0.125}, -- NodeBox5
|
||||
{0.125, -0.3125, -0.125, 0.25, 0, 0.125}, -- NodeBox6
|
||||
}
|
||||
},
|
||||
selection_box = {
|
||||
type = "regular"
|
||||
}
|
||||
})
|
BIN
worldmods/caverealms/schems/DMFort.mts
Normal file
BIN
worldmods/caverealms/schems/DMFountain.mts
Normal file
BIN
worldmods/caverealms/screenshot.png
Normal file
After Width: | Height: | Size: 512 KiB |
BIN
worldmods/caverealms/textures/caverealms_algae.png
Normal file
After Width: | Height: | Size: 739 B |
BIN
worldmods/caverealms/textures/caverealms_algae_side.png
Normal file
After Width: | Height: | Size: 446 B |
BIN
worldmods/caverealms/textures/caverealms_coal_dust.png
Normal file
After Width: | Height: | Size: 288 B |
BIN
worldmods/caverealms/textures/caverealms_dm_stone.png
Normal file
After Width: | Height: | Size: 590 B |
BIN
worldmods/caverealms/textures/caverealms_fungi.png
Normal file
After Width: | Height: | Size: 150 B |
BIN
worldmods/caverealms/textures/caverealms_glow_amethyst.png
Normal file
After Width: | Height: | Size: 325 B |
BIN
worldmods/caverealms/textures/caverealms_glow_amethyst_ore.png
Normal file
After Width: | Height: | Size: 329 B |
BIN
worldmods/caverealms/textures/caverealms_glow_crystal.png
Normal file
After Width: | Height: | Size: 330 B |
BIN
worldmods/caverealms/textures/caverealms_glow_emerald.png
Normal file
After Width: | Height: | Size: 330 B |
BIN
worldmods/caverealms/textures/caverealms_glow_emerald_ore.png
Normal file
After Width: | Height: | Size: 329 B |
BIN
worldmods/caverealms/textures/caverealms_glow_gem.png
Normal file
After Width: | Height: | Size: 248 B |
BIN
worldmods/caverealms/textures/caverealms_glow_mese.png
Normal file
After Width: | Height: | Size: 330 B |
BIN
worldmods/caverealms/textures/caverealms_glow_obsidian.png
Normal file
After Width: | Height: | Size: 162 B |
BIN
worldmods/caverealms/textures/caverealms_glow_obsidian2.png
Normal file
After Width: | Height: | Size: 661 B |
BIN
worldmods/caverealms/textures/caverealms_glow_ore.png
Normal file
After Width: | Height: | Size: 345 B |
BIN
worldmods/caverealms/textures/caverealms_glow_ruby.png
Normal file
After Width: | Height: | Size: 330 B |
BIN
worldmods/caverealms/textures/caverealms_glow_ruby_ore.png
Normal file
After Width: | Height: | Size: 329 B |
BIN
worldmods/caverealms/textures/caverealms_glow_worm.png
Normal file
After Width: | Height: | Size: 191 B |
BIN
worldmods/caverealms/textures/caverealms_hot_cobble.png
Normal file
After Width: | Height: | Size: 431 B |
BIN
worldmods/caverealms/textures/caverealms_icicle_down.png
Normal file
After Width: | Height: | Size: 161 B |
BIN
worldmods/caverealms/textures/caverealms_icicle_up.png
Normal file
After Width: | Height: | Size: 158 B |
BIN
worldmods/caverealms/textures/caverealms_lichen.png
Normal file
After Width: | Height: | Size: 925 B |
BIN
worldmods/caverealms/textures/caverealms_lichen_side.png
Normal file
After Width: | Height: | Size: 437 B |
BIN
worldmods/caverealms/textures/caverealms_moss.png
Normal file
After Width: | Height: | Size: 754 B |
BIN
worldmods/caverealms/textures/caverealms_moss_side.png
Normal file
After Width: | Height: | Size: 457 B |
BIN
worldmods/caverealms/textures/caverealms_mushroom_cap.png
Normal file
After Width: | Height: | Size: 172 B |
BIN
worldmods/caverealms/textures/caverealms_mushroom_cap_legacy.png
Normal file
After Width: | Height: | Size: 172 B |
BIN
worldmods/caverealms/textures/caverealms_mushroom_gills.png
Normal file
After Width: | Height: | Size: 141 B |
BIN
worldmods/caverealms/textures/caverealms_mushroom_stem.png
Normal file
After Width: | Height: | Size: 402 B |
BIN
worldmods/caverealms/textures/caverealms_mycena.png
Normal file
After Width: | Height: | Size: 216 B |
BIN
worldmods/caverealms/textures/caverealms_mycena_powder.png
Normal file
After Width: | Height: | Size: 156 B |
BIN
worldmods/caverealms/textures/caverealms_salt_crystal.png
Normal file
After Width: | Height: | Size: 402 B |
BIN
worldmods/caverealms/textures/caverealms_salt_gem.png
Normal file
After Width: | Height: | Size: 243 B |
BIN
worldmods/caverealms/textures/caverealms_salty.png
Normal file
After Width: | Height: | Size: 825 B |
BIN
worldmods/caverealms/textures/caverealms_salty2.png
Normal file
After Width: | Height: | Size: 330 B |
BIN
worldmods/caverealms/textures/caverealms_salty_side.png
Normal file
After Width: | Height: | Size: 517 B |
BIN
worldmods/caverealms/textures/caverealms_spike.png
Normal file
After Width: | Height: | Size: 248 B |
BIN
worldmods/caverealms/textures/caverealms_stone_eyes.png
Normal file
After Width: | Height: | Size: 662 B |
BIN
worldmods/caverealms/textures/caverealms_thin_ice.png
Normal file
After Width: | Height: | Size: 679 B |
BIN
worldmods/caverealms/textures/fire_basic_flame.png
Normal file
After Width: | Height: | Size: 719 B |
BIN
worldmods/caverealms/textures/fire_basic_flame_animated.png
Normal file
After Width: | Height: | Size: 1.2 KiB |