index
:
minetest.git
gpcf
lifo-fixes
release
modified minetest for gpcfs purposes
gpcf
about
summary
refs
log
tree
commit
diff
log msg
author
committer
range
path:
root
/
cmake
/
Modules
diff options
context:
1
2
3
4
5
6
7
8
9
10
15
20
25
30
35
40
space:
include
ignore
mode:
unified
ssdiff
stat only
author
SmallJoker <mk939@ymail.com>
2020-11-08 11:30:16 +0100
committer
SmallJoker <mk939@ymail.com>
2020-11-08 11:30:16 +0100
commit
c940a57a384b1a75730776906451078d25c5aa52
(
patch
)
tree
0eb4843a765cd41fc156ce03da9ccc4723faac73
/
cmake/Modules
parent
8c1871fa2c066a2086988684256da97bd0f4ab6f
(
diff
)
download
minetest-c940a57a384b1a75730776906451078d25c5aa52.tar.gz
minetest-c940a57a384b1a7573077
#!/usr/bin/python2
# This is an example script that generates some valid map data.
import
struct
import
random
import
os
import
sys
from
pnoise
import
pnoise
"""
Map format:
map/sectors/XXXXZZZZ/YYYY
XXXX,YYYY,ZZZZ = coordinates in hexadecimal
fffe = -2
ffff = -1
0000 = 0
0001 = 1
"""
def
to4h
(
i
):
s
=
""
;
s
+=
'{0:1x}'
.
format
((
i
>>
12
) &
0x000f
)
s
+=
'{0:1x}'
.
format
((
i
>>
8
) &
0x000f
)
s
+=
'{0:1x}'
.
format
((
i
>>
4
) &
0x000f
)
s
+=
'{0:1x}'
.
format
((
i
>>
0
) &
0x000f
)
return
s
def
getrand
():
i
=
random
.
randrange
(
0
,
2
)
if
i
==
0
:
return
0
return
254
def
writeblock
(
mapdir
,
px
,
py
,
pz
,
version
):
sectordir
=
mapdir
+
"/sectors/"
+
to4h
(
px
) +
to4h
(
pz
)
try
:
os
.
makedirs
(
sectordir
)
except
OSError
:
pass
f
=
open
(
sectordir
+
"/"
+
to4h
(
py
),
"wb"
)
if
version
==
0
:
# version
f
.
write
(
struct
.
pack
(
'B'
,
0
))
# is_underground
f
.
write
(
struct
.
pack
(
'B'
,
0
))
elif
version
==
2
:
# version
f
.
write
(
struct
.
pack
(
'B'
,
2
))
# is_underground
f
.
write
(
struct
.
pack
(
'B'
,
0
))
for
z
in
range
(
0
,
16
):
for
y
in
range
(
0
,
16
):
for
x
in
range
(
0
,
16
):
b
=
254
r
=
20.0
*
pnoise
((
px
*
16
+
x
)/
100
.,(
pz
*
16
+
z
)/
100
.,
0
)
r
+=
5.0
*
pnoise
((
px
*
16
+
x
)/
25
.,(
pz
*
16
+
z
)/
25
.,
0
)
#print("r="+str(r))
y1
=
py
*
16
+
y
if
y1
<=
r
-
3
:
b
=
0
#stone
elif
y1
<=
r
:
b
=
1
#grass
elif
y1
<=
1
:
b
=
9
#water
if
version
==
0
:
# Material content
f
.
write
(
struct
.
pack
(
'B'
,
b
))
elif
version
==
2
:
# Material content
f
.
write
(
struct
.
pack
(
'B'
,
b
))
# Brightness
f
.
write
(
struct
.
pack
(
'B'
,
15
))
f
.
close
()
mapdir
=
"map"
for
z
in
range
(-
2
,
3
):
for
y
in
range
(-
1
,
2
):
for
x
in
range
(-
2
,
3
):
print
(
"generating block "
+
str
(
x
)+
","
+
str
(
y
)+
","
+
str
(
z
))
writeblock
(
mapdir
,
x
,
y
,
z
,
0
)
#END