Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
caverealms
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
caverealms
Commits
9cee177c
Commit
9cee177c
authored
10 years ago
by
HeroOfTheWinds
Browse files
Options
Downloads
Patches
Plain Diff
Version 0.2 Release
New crystal stalagmite structure, now generates stalactites. Some setting tweaks.
parent
796914fc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
init.lua
+115
-33
115 additions, 33 deletions
init.lua
with
115 additions
and
33 deletions
init.lua
+
115
−
33
View file @
9cee177c
-- caverealms 0.
1.1
by HeroOfTheWinds
-- caverealms 0.
2
by HeroOfTheWinds
-- For latest stable Minetest and back to 0.4.8
-- Depends default
-- License: code WTFPL
...
...
@@ -23,11 +23,11 @@ local STOTHR = 0.08 -- Stone density threshold
local
STABLE
=
2
-- Minimum number of stacked stone nodes in column for dirt / sand on top
local
STAGCHA
=
0
.
002
--chance of stalagmites
local
STAL
A
C
=
0
.
0
4
--chance of stalactites
local
STALC
HA
=
0
.
0
03
--chance of stalactites
local
H_LAG
=
15
--max height for stalagmites
local
H_LAC
=
20
--...stalactites
local
CRYSTAL
=
0
.
007
--chance of glow crystal formations
local
H_CRY
=
6
--max height of glow crystals
local
H_CRY
=
9
--max height of glow crystals
local
GEMCHA
=
0
.
03
--chance of small glow gems
...
...
@@ -120,13 +120,17 @@ minetest.register_node("caverealms:stone_with_moss", {
description
=
"Cave Dirt with Grass"
,
tiles
=
{
"default_cobble.png^caverealms_moss.png"
,
"default_cobble.png"
,
"default_cobble.png^caverealms_moss_side.png"
},
is_ground_content
=
true
,
groups
=
{
crumbly
=
3
,
soil
=
1
},
groups
=
{
crumbly
=
3
},
drop
=
'default:dirt'
,
sounds
=
default
.
node_sound_dirt_defaults
({
footstep
=
{
name
=
"default_grass_footstep"
,
gain
=
0
.
25
},
}),
})
--cave plants
--cave plants go here
--FUNCTIONS--
--stalagmite spawner
function
caverealms
:
stalagmite
(
x
,
y
,
z
,
area
,
data
)
...
...
@@ -161,46 +165,75 @@ function caverealms:stalagmite(x,y,z, area, data)
end
end
--stalactite spawner
function
caverealms
:
stalactite
(
x
,
y
,
z
,
area
,
data
)
--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
)
--content IDs
function
caverealms
:
crystal_stalagmite
(
x
,
y
,
z
,
area
,
data
)
--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"
)
for
j
=
0
,
H_CRY
do
--y
for
k
=
-
2
,
2
do
--x
for
l
=
-
2
,
2
do
--z
if
j
<=
math.ceil
(
H_CRY
/
4
)
then
--base
if
k
*
k
+
l
*
l
<=
4
then
--make a circle
local
vi
=
area
:
index
(
x
+
k
,
y
+
j
,
z
+
l
-
2
)
if
math.random
(
3
)
==
1
then
data
[
vi
]
=
c_crystal
else
data
[
vi
]
=
c_crystore
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
]
=
c_stone
end
else
--top
if
k
>=
-
1
and
k
<=
1
then
if
l
>=
-
1
and
l
<=
1
then
if
j
<=
H_CRY
-
2
then
local
vi
=
area
:
index
(
x
+
k
,
y
+
j
,
z
+
l
-
2
)
if
math.random
(
3
)
<=
2
then
data
[
vi
]
=
c_crystal
else
data
[
vi
]
=
c_crystore
end
else
local
vi
=
area
:
index
(
x
,
y
+
j
,
z
-
2
)
data
[
vi
]
=
c_crystal
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_crystore
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_crystal
end
else
local
vi
=
area
:
index
(
x
,
y
+
j
,
z
-
3
)
data
[
vi
]
=
c_crystal
end
end
end
end
end
-- On generated function
minetest
.
register_on_generated
(
function
(
minp
,
maxp
,
seed
)
...
...
@@ -256,20 +289,27 @@ minetest.register_on_generated(function(minp, maxp, seed)
local
nixyz
=
1
--short for node index xyz
local
nixz
=
1
--node index xz
local
stable
=
{}
--stability for ground
local
dirt
=
{}
--table for
dirt
local
dirt
=
{}
--table for
ground surface
local
chumid
=
y0
+
sidelen
/
2
--middle of the current chunk
local
roof
=
{}
local
nixyz2
=
1
local
nixz2
=
1
local
stable2
=
{}
for
z
=
z0
,
z1
do
--for each xy plane progressing northwards
for
x
=
x0
,
x1
do
local
si
=
x
-
x0
+
1
--stability index
dirt
[
si
]
=
0
--no dirt here... yet
roof
[
si
]
=
0
local
nodename
=
minetest
.
get_node
({
x
=
x
,
y
=
y0
-
1
,
z
=
z
}).
name
--grab the name of the node just below
if
nodename
==
"air"
or
nodename
==
"default:water_source"
or
nodename
==
"default:lava_source"
then
--if a cave or any kind of lake
stable
[
si
]
=
0
--this is not stable for plants or falling nodes above
stable2
[
si
]
=
0
else
-- all else including ignore in ungenerated chunks
stable
[
si
]
=
STABLE
--stuff can safely go above
stable2
[
si
]
=
STABLE
end
end
for
y
=
y1
,
y0
,
-
1
do
-- for each x row progressing downwards
...
...
@@ -286,6 +326,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
local
density
=
nvals_cave
[
nixyz
]
-
grad
--how dense is the emptiness?
if
density
<
0
and
density
>
-
0
.
7
then
-- if cavern "shell"
local
nodename
=
minetest
.
get_node
({
x
=
x
,
y
=
y
,
z
=
z
}).
name
--grab the name of the node
data
[
vi
]
=
c_air
--make emptiness
if
density
<
STOTHR
and
stable
[
si
]
<=
STABLE
then
dirt
[
si
]
=
dirt
[
si
]
+
1
...
...
@@ -320,8 +361,49 @@ minetest.register_on_generated(function(minp, maxp, seed)
nixz
=
nixz
-
sidelen
--shift the 2D index down a layer
end
nixz
=
nixz
+
sidelen
--shift the 2D index up a layer
--second loop to obtain ceiling
for
y
=
y0
,
y1
do
-- for each x row progressing downwards
local
vi
=
area
:
index
(
x0
,
y
,
z
)
--grab the index of the node to edit
for
x
=
x0
,
x1
do
-- for each node do
--here's the good part
local
si
=
x
-
x0
+
1
--stability index
local
cavemid
=
chumid
+
nvals_wave
[
nixz2
]
*
WAVAMP
--grab the middle of the cave's amplitude
local
grad
if
y
>
cavemid
then
grad
=
((
y
-
cavemid
)
/
HISCAL
)
^
HIEXP
--for the ceiling
else
grad
=
((
cavemid
-
y
)
/
LOSCAL
)
^
LOEXP
--for the floor
end
local
density
=
nvals_cave
[
nixyz2
]
-
grad
--how dense is the emptiness?
if
density
<
0
and
density
>
-
0
.
7
then
-- if cavern "shell"
if
density
<
STOTHR
and
stable2
[
si
]
<=
STABLE
then
roof
[
si
]
=
roof
[
si
]
+
1
else
stable2
[
si
]
=
stable2
[
si
]
+
1
end
elseif
roof
[
si
]
>=
1
then
--and stable2[si] >= 2 then -- node above surface
if
math.random
()
<=
STALCHA
then
local
ai
=
area
:
index
(
x
,
y
+
1
,
z
)
if
data
[
ai
]
~=
c_air
then
caverealms
:
stalactite
(
x
,
y
,
z
,
area
,
data
)
end
end
roof
[
si
]
=
0
else
-- solid rock
stable2
[
si
]
=
0
end
nixyz2
=
nixyz2
+
1
--increment the 3D index
nixz2
=
nixz2
+
1
--increment the 2D index
vi
=
vi
+
1
--increment the area index
end
nixz2
=
nixz2
-
sidelen
end
nixz2
=
nixz2
+
sidelen
end
--write these changes to the world
vm
:
set_data
(
data
)
vm
:
set_lighting
({
day
=
0
,
night
=
0
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment