Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
minetest_game
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
minetest_game
Commits
53e9b0e1
Commit
53e9b0e1
authored
12 years ago
by
Perttu Ahola
Browse files
Options
Downloads
Patches
Plain Diff
Re-implement nyancat generation in Lua (they don't occur in the exact same spots, though)
parent
216227ba
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mods/default/mapgen.lua
+51
-0
51 additions, 0 deletions
mods/default/mapgen.lua
with
51 additions
and
0 deletions
mods/default/mapgen.lua
+
51
−
0
View file @
53e9b0e1
...
...
@@ -80,6 +80,54 @@ function default.make_cactus(pos, size)
end
end
-- facedir: 0/1/2/3 (head node facedir value)
-- length: length of rainbow tail
function
default
.
make_nyancat
(
pos
,
facedir
,
length
)
local
tailvec
=
{
x
=
0
,
y
=
0
,
z
=
0
}
if
facedir
==
0
then
tailvec
.
z
=
1
elseif
facedir
==
1
then
tailvec
.
x
=
1
elseif
facedir
==
2
then
tailvec
.
z
=
-
1
elseif
facedir
==
3
then
tailvec
.
x
=
-
1
else
print
(
"default.make_nyancat(): Invalid facedir: "
+
dump
(
facedir
))
facedir
=
0
tailvec
.
z
=
1
end
local
p
=
{
x
=
pos
.
x
,
y
=
pos
.
y
,
z
=
pos
.
z
}
minetest
.
env
:
set_node
(
p
,
{
name
=
"default:nyancat"
,
param2
=
facedir
})
for
i
=
1
,
length
do
p
.
x
=
p
.
x
+
tailvec
.
x
p
.
z
=
p
.
z
+
tailvec
.
z
minetest
.
env
:
set_node
(
p
,
{
name
=
"default:nyancat_rainbow"
})
end
end
function
generate_nyancats
(
seed
,
minp
,
maxp
)
local
height_min
=
-
31000
local
height_max
=
-
32
if
maxp
.
y
<
height_min
or
minp
.
y
>
height_max
then
return
end
local
y_min
=
math.max
(
minp
.
y
,
height_min
)
local
y_max
=
math.min
(
maxp
.
y
,
height_max
)
local
volume
=
(
maxp
.
x
-
minp
.
x
+
1
)
*
(
y_max
-
y_min
+
1
)
*
(
maxp
.
z
-
minp
.
z
+
1
)
local
pr
=
PseudoRandom
(
seed
+
9324342
)
local
max_num_nyancats
=
math.floor
(
volume
/
(
16
*
16
*
16
))
for
i
=
1
,
max_num_nyancats
do
if
pr
.
next
(
0
,
1000
)
==
0
then
local
x0
=
pr
:
next
(
minp
.
x
,
maxp
.
x
)
local
y0
=
pr
:
next
(
minp
.
y
,
maxp
.
y
)
local
z0
=
pr
:
next
(
minp
.
z
,
maxp
.
z
)
local
p0
=
{
x
=
x0
,
y
=
y0
,
z
=
z0
}
default
.
make_nyancat
(
p0
,
pr
:
next
(
0
,
3
),
pr
:
next
(
3
,
15
))
end
end
end
minetest
.
register_on_generated
(
function
(
minp
,
maxp
,
seed
)
-- Generate regular ores
generate_ore
(
"default:stone_with_coal"
,
"default:stone"
,
minp
,
maxp
,
seed
+
0
,
1
/
8
/
8
/
8
,
3
,
8
,
-
31000
,
64
)
...
...
@@ -220,5 +268,8 @@ minetest.register_on_generated(function(minp, maxp, seed)
end
end
end
-- Generate nyan cats
generate_nyancats
(
seed
,
minp
,
maxp
)
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