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
045e9641
Commit
045e9641
authored
10 years ago
by
Craig Robbins
Browse files
Options
Downloads
Patches
Plain Diff
Began moving values to config.lua so they can be specified in the .conf file
parent
9cee177c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config.lua
+24
-0
24 additions, 0 deletions
config.lua
init.lua
+27
-25
27 additions, 25 deletions
init.lua
with
51 additions
and
25 deletions
config.lua
0 → 100644
+
24
−
0
View file @
045e9641
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
setting
(
"number"
,
"ymin"
,
-
33000
)
setting
(
"number"
,
"ymax"
,
-
700
)
This diff is collapsed.
Click to expand it.
init.lua
+
27
−
25
View file @
045e9641
...
...
@@ -3,10 +3,16 @@
-- Depends default
-- License: code WTFPL
-- Parameters
caverealms
=
{}
local
modpath
=
minetest
.
get_modpath
(
minetest
.
get_current_modname
())
dofile
(
modpath
..
"/config.lua"
)
local
YMIN
=
-
33000
-- Approximate realm limits.
local
YMAX
=
-
700
-- Parameters (see also config.lua)
local
YMIN
=
caverealms
.
config
.
ymin
-- Approximate realm limits.
local
YMAX
=
caverealms
.
config
.
ymax
local
XMIN
=
-
33000
local
XMAX
=
33000
local
ZMIN
=
-
33000
...
...
@@ -64,10 +70,6 @@ local np_wave = {
persist
=
0
.
5
}
-- Stuff
caverealms
=
{}
-- Nodes
--glowing crystal
...
...
@@ -136,7 +138,7 @@ minetest.register_node("caverealms:stone_with_moss", {
function
caverealms
:
stalagmite
(
x
,
y
,
z
,
area
,
data
)
--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
...
...
@@ -169,7 +171,7 @@ end
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
...
...
@@ -204,7 +206,7 @@ function caverealms:crystal_stalagmite(x,y,z, area, data)
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
top
=
math.random
(
5
,
H_CRY
)
--grab a random height for the stalagmite
for
j
=
0
,
top
do
--y
for
k
=
-
3
,
3
do
...
...
@@ -243,13 +245,13 @@ minetest.register_on_generated(function(minp, maxp, seed)
or
minp
.
z
<
ZMIN
or
maxp
.
z
>
ZMAX
then
return
end
--determine if there's enough spacing between layers to start a realm
local
chulay
=
math.floor
((
minp
.
y
+
32
)
/
80
)
-- chunk layer number, 0 = surface chunk
if
math.fmod
(
chulay
,
CHUINT
)
~=
0
then
-- if chulay / CHUINT has a remainder
return
end
--easy to reference variables for limits and time
local
t1
=
os.clock
()
local
x1
=
maxp
.
x
...
...
@@ -258,21 +260,21 @@ minetest.register_on_generated(function(minp, maxp, seed)
local
x0
=
minp
.
x
local
y0
=
minp
.
y
local
z0
=
minp
.
z
--let people know you're generating a realm
print
(
"[caverealms] chunk minp ("
..
x0
..
" "
..
y0
..
" "
..
z0
..
")"
)
--fire up the LVM
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_crystal
=
minetest
.
get_content_id
(
"caverealms:glow_crystal"
)
local
c_gem
=
minetest
.
get_content_id
(
"caverealms:glow_gem"
)
local
c_moss
=
minetest
.
get_content_id
(
"caverealms:stone_with_moss"
)
--some mandatory values
local
sidelen
=
x1
-
x0
+
1
--usually equals 80 with default mapgen values. Always a multiple of 16.
local
chulens
=
{
x
=
sidelen
,
y
=
sidelen
,
z
=
sidelen
}
--position table to pass to get3dMap_flat
...
...
@@ -284,7 +286,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local
nvals_cluster
=
minetest
.
get_perlin_map
(
np_cluster
,
chulens
):
get3dMap_flat
(
minposxyz
)
local
nvals_wave
=
minetest
.
get_perlin_map
(
np_wave
,
chulens
):
get2dMap_flat
(
minposxz
)
--more values
local
nixyz
=
1
--short for node index xyz
local
nixz
=
1
--node index xz
...
...
@@ -295,9 +297,9 @@ minetest.register_on_generated(function(minp, maxp, seed)
local
nixyz2
=
1
local
nixz2
=
1
local
stable2
=
{}
for
z
=
z0
,
z1
do
--for each xy plane progressing northwards
for
x
=
x0
,
x1
do
for
x
=
x0
,
x1
do
local
si
=
x
-
x0
+
1
--stability index
dirt
[
si
]
=
0
--no dirt here... yet
roof
[
si
]
=
0
...
...
@@ -333,7 +335,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
else
stable
[
si
]
=
stable
[
si
]
+
1
end
elseif
dirt
[
si
]
>=
1
then
-- node above surface
--place dirt on floor, add plants
data
[
vi
]
=
c_moss
...
...
@@ -361,7 +363,7 @@ 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
...
...
@@ -382,7 +384,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
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
)
...
...
@@ -402,8 +404,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
nixz2
=
nixz2
+
sidelen
end
--write these changes to the world
vm
:
set_data
(
data
)
vm
:
set_lighting
({
day
=
0
,
night
=
0
})
...
...
@@ -411,4 +413,4 @@ minetest.register_on_generated(function(minp, maxp, seed)
vm
:
write_to_map
(
data
)
local
chugent
=
math.ceil
((
os.clock
()
-
t1
)
*
1000
)
--grab how long this took
print
(
"[caverealms] "
..
chugent
..
" ms"
)
--tell people how long it took
end
)
\ No newline at end of file
end
)
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