Compare commits
390 Commits
0.4.dev-20
...
0.4.dev-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
684b004751 | ||
|
|
cbe11fc7aa | ||
|
|
d01387a82f | ||
|
|
862d76b617 | ||
|
|
bd9912213f | ||
|
|
814ada538a | ||
|
|
53f7eef052 | ||
|
|
405347769a | ||
|
|
5b31d32da8 | ||
|
|
dcef5183f7 | ||
|
|
728d01ef4b | ||
|
|
0557df8d06 | ||
|
|
3a9753b85f | ||
|
|
8e6ac5c263 | ||
|
|
188b303991 | ||
|
|
836595313c | ||
|
|
6779036d25 | ||
|
|
4fb6c07535 | ||
|
|
f01c988094 | ||
|
|
677456d319 | ||
|
|
f022af66da | ||
|
|
98c40f5ee6 | ||
|
|
db0928add3 | ||
|
|
a9a923e4da | ||
|
|
1cac1de3b2 | ||
|
|
524c78a8d6 | ||
|
|
e71262463f | ||
|
|
26666bb36f | ||
|
|
f801e16b78 | ||
|
|
4bf5065a9c | ||
|
|
04085cad3c | ||
|
|
c8997e48c0 | ||
|
|
77621568fd | ||
|
|
601d1936c9 | ||
|
|
06e93f8d95 | ||
|
|
74780134f2 | ||
|
|
93219e3b9d | ||
|
|
77120a021d | ||
|
|
6c14025b2d | ||
|
|
e53794868e | ||
|
|
8c2f3bb378 | ||
|
|
0ac2ce7dea | ||
|
|
c301e3c82a | ||
|
|
9dd78a8a45 | ||
|
|
ede1674d6a | ||
|
|
c3f2b24a9a | ||
|
|
b91bba1ab2 | ||
|
|
fbc22f91d5 | ||
|
|
424b36d469 | ||
|
|
8070f9485b | ||
|
|
c353709f7e | ||
|
|
c13691a8e6 | ||
|
|
2671b9af1b | ||
|
|
7d0ad0f521 | ||
|
|
9bd75d5668 | ||
|
|
fde676a43a | ||
|
|
2469ce6067 | ||
|
|
ef0ec31554 | ||
|
|
da4f51332f | ||
|
|
194258b479 | ||
|
|
fa416e7116 | ||
|
|
71b2e0e002 | ||
|
|
7d1ac4d1f6 | ||
|
|
2f2ef80ec2 | ||
|
|
c0530921ff | ||
|
|
94f1ab4da3 | ||
|
|
3f75b748cf | ||
|
|
8181b68531 | ||
|
|
2de91f11fb | ||
|
|
50621ffe85 | ||
|
|
db4911f956 | ||
|
|
2a325de7aa | ||
|
|
b9cc0a7976 | ||
|
|
97b693052c | ||
|
|
19ed3bb193 | ||
|
|
895b970a10 | ||
|
|
1f56d71f19 | ||
|
|
1ff20da5b6 | ||
|
|
5ef78cd815 | ||
|
|
9101b680c0 | ||
|
|
d24c56fd4b | ||
|
|
77d09552ae | ||
|
|
dbaccff476 | ||
|
|
dc6cf5cdee | ||
|
|
fb3ac49335 | ||
|
|
c54a40df06 | ||
|
|
9c4f68e174 | ||
|
|
4ee4dfdc13 | ||
|
|
2e0c0e9d89 | ||
|
|
db5db587be | ||
|
|
569fca5308 | ||
|
|
b409803527 | ||
|
|
99d257ae8b | ||
|
|
2f2b7915ea | ||
|
|
c1cfcb1577 | ||
|
|
2e90ed07ac | ||
|
|
58bed83d03 | ||
|
|
54917e3062 | ||
|
|
81385682c8 | ||
|
|
807a0d313b | ||
|
|
f9a66c5d46 | ||
|
|
60add387e3 | ||
|
|
ca0fd4173c | ||
|
|
4aa0f040fb | ||
|
|
5957fed9a7 | ||
|
|
6298878bfa | ||
|
|
899004207d | ||
|
|
2b200d481f | ||
|
|
8551ddc839 | ||
|
|
eea3277b81 | ||
|
|
11b86f8d8a | ||
|
|
71a3c2fcd1 | ||
|
|
4ff36696ea | ||
|
|
800d3b4ee7 | ||
|
|
a0b2c7ba25 | ||
|
|
64232f0aec | ||
|
|
591527d878 | ||
|
|
82073025cc | ||
|
|
2c9bb06516 | ||
|
|
18c4a90101 | ||
|
|
5a8ee4889d | ||
|
|
ea1fdf3201 | ||
|
|
2e61008fd9 | ||
|
|
eafde7186f | ||
|
|
a72dc388c3 | ||
|
|
618314985d | ||
|
|
d1d83d7e7f | ||
|
|
bcaab74f1f | ||
|
|
1b670a293b | ||
|
|
45f78bdf40 | ||
|
|
54eca4e736 | ||
|
|
3da05a09b5 | ||
|
|
f79082a46d | ||
|
|
e71d75ed9a | ||
|
|
a4a35f659b | ||
|
|
9eba6a349f | ||
|
|
6a1b6d0344 | ||
|
|
7f7fb9750d | ||
|
|
df190b8f87 | ||
|
|
af33b3b338 | ||
|
|
a87d19cd7e | ||
|
|
611fe41588 | ||
|
|
8b6cce18cb | ||
|
|
d330430336 | ||
|
|
37b2bc3c0c | ||
|
|
f49914dd17 | ||
|
|
f1d9880006 | ||
|
|
6ec447a1aa | ||
|
|
b485fac33e | ||
|
|
98404ad8ea | ||
|
|
e1f5227304 | ||
|
|
2de8f915f8 | ||
|
|
967f25461b | ||
|
|
0053651814 | ||
|
|
7d36833bd4 | ||
|
|
1bbfd0b6d2 | ||
|
|
4547ace59a | ||
|
|
d74659254b | ||
|
|
55d310b05a | ||
|
|
15da308c2a | ||
|
|
e80bc6ef58 | ||
|
|
d81e783665 | ||
|
|
030b63c3d2 | ||
|
|
f3dba05143 | ||
|
|
1020707918 | ||
|
|
c89d1cf072 | ||
|
|
9c5e422d3a | ||
|
|
5e00141005 | ||
|
|
fa70413c82 | ||
|
|
06d2bc7fbd | ||
|
|
1ae9e0afa1 | ||
|
|
f9da2c9507 | ||
|
|
989aba1966 | ||
|
|
6b7d6c27ee | ||
|
|
8db89b8136 | ||
|
|
8c01ad8a9d | ||
|
|
f60a5ec08f | ||
|
|
501b8fe743 | ||
|
|
e9cdb938fe | ||
|
|
f1cb91cd93 | ||
|
|
910186905f | ||
|
|
07ed57476f | ||
|
|
0b21618a05 | ||
|
|
b49a7c140e | ||
|
|
562ac3bce9 | ||
|
|
f21291211c | ||
|
|
d834d6e074 | ||
|
|
11716825fc | ||
|
|
0309021359 | ||
|
|
14a71590c3 | ||
|
|
a5f6d65c37 | ||
|
|
79326e6287 | ||
|
|
c8ec711503 | ||
|
|
0f8b91bfba | ||
|
|
b7fd3c8669 | ||
|
|
b3f4cbe157 | ||
|
|
d0491ce8b6 | ||
|
|
806f10524f | ||
|
|
50110e00e8 | ||
|
|
3a89c40e26 | ||
|
|
ff678d1607 | ||
|
|
abab3db23d | ||
|
|
496451c164 | ||
|
|
993821a924 | ||
|
|
ad5ac22442 | ||
|
|
94b25685c5 | ||
|
|
88cdd3a363 | ||
|
|
e15de8b70d | ||
|
|
61016962ee | ||
|
|
a1eb2836c0 | ||
|
|
64af6d3afe | ||
|
|
365f7a5bfe | ||
|
|
796009ef21 | ||
|
|
b85b4ede82 | ||
|
|
2cb96d9d68 | ||
|
|
78bf92175a | ||
|
|
0c3d39357b | ||
|
|
0e8bd531c2 | ||
|
|
ac69a3561a | ||
|
|
24b1008d56 | ||
|
|
a4340c330a | ||
|
|
2e8e9ee7f5 | ||
|
|
cb05a28745 | ||
|
|
a387c9b95d | ||
|
|
0a426f3592 | ||
|
|
00bc9a8678 | ||
|
|
c241902b40 | ||
|
|
4799a8f761 | ||
|
|
02b334a679 | ||
|
|
b4dd5d3bd7 | ||
|
|
1efdc36b22 | ||
|
|
157a4cf18c | ||
|
|
f22c73f501 | ||
|
|
c920df748b | ||
|
|
a58d725569 | ||
|
|
6a76c226e1 | ||
|
|
569156b013 | ||
|
|
6d4bc012f0 | ||
|
|
2f5c28aaf1 | ||
|
|
4f2c1e36a1 | ||
|
|
bc743ca7ce | ||
|
|
f9d7e399b2 | ||
|
|
3e6f824e6c | ||
|
|
6286c555d4 | ||
|
|
4630281318 | ||
|
|
cd0019acd2 | ||
|
|
e82a76e438 | ||
|
|
ab57fbe4ca | ||
|
|
56f55ab1af | ||
|
|
2445cbbbdc | ||
|
|
48131bf988 | ||
|
|
2b9596fe9b | ||
|
|
0e1f448b61 | ||
|
|
ff82b95800 | ||
|
|
49b7055cb3 | ||
|
|
cb88f7b6d4 | ||
|
|
9425fb8192 | ||
|
|
e48ccd7943 | ||
|
|
6be5441176 | ||
|
|
d5ba7ebaf0 | ||
|
|
270a482740 | ||
|
|
e0b4890794 | ||
|
|
247e8b6e5d | ||
|
|
b760e2ba23 | ||
|
|
103173fc9b | ||
|
|
70ed371d0c | ||
|
|
81d3485109 | ||
|
|
7b7b68cdab | ||
|
|
135a65e200 | ||
|
|
123529e5eb | ||
|
|
e81989a0d8 | ||
|
|
1c15f53318 | ||
|
|
7937813c98 | ||
|
|
ad4040d982 | ||
|
|
69579306dd | ||
|
|
bd21f00f0a | ||
|
|
012bcbcb48 | ||
|
|
e06d4555bf | ||
|
|
abd106bacb | ||
|
|
008de2fb8f | ||
|
|
2e67fa3e48 | ||
|
|
ea36951bc4 | ||
|
|
09c48b60bd | ||
|
|
4cc117ddf6 | ||
|
|
ceaf8edade | ||
|
|
520200d597 | ||
|
|
ab67985d21 | ||
|
|
bc5cc638fc | ||
|
|
bff8be8b76 | ||
|
|
3e95b8a158 | ||
|
|
e8539d4dae | ||
|
|
1907b31da7 | ||
|
|
6145a135bd | ||
|
|
97c3bc408b | ||
|
|
a00e908f52 | ||
|
|
4ad8891e05 | ||
|
|
2b8b2a4f30 | ||
|
|
5c24450e54 | ||
|
|
3a689a5c4f | ||
|
|
44e36d9aad | ||
|
|
62f7f72d20 | ||
|
|
829c632511 | ||
|
|
8730dfb1f9 | ||
|
|
6764365994 | ||
|
|
8addbc9655 | ||
|
|
658d1a7235 | ||
|
|
4b00d4d9d2 | ||
|
|
6a5829788e | ||
|
|
03074cd23e | ||
|
|
2620e8eada | ||
|
|
9b5e676ffa | ||
|
|
fd1ef11617 | ||
|
|
9fa567a6ce | ||
|
|
fc6c00cbe1 | ||
|
|
66f90a6101 | ||
|
|
1fe5c58d56 | ||
|
|
f23616acaf | ||
|
|
7d37913ea4 | ||
|
|
ac56053c74 | ||
|
|
d566ffaa5f | ||
|
|
d06d7cb9a4 | ||
|
|
e494b5d422 | ||
|
|
fdf7b3bcdf | ||
|
|
871e6c0c73 | ||
|
|
392485aa45 | ||
|
|
275a348b75 | ||
|
|
189689716c | ||
|
|
3965d432ca | ||
|
|
746b960c0d | ||
|
|
760416b81f | ||
|
|
1c785c32ef | ||
|
|
cd608b1877 | ||
|
|
c6dd75ccfb | ||
|
|
6b2023dc3e | ||
|
|
2f4a92d701 | ||
|
|
324c544922 | ||
|
|
fbbbcf97d8 | ||
|
|
d96cd236f3 | ||
|
|
581f950e10 | ||
|
|
9344816bd6 | ||
|
|
67c21fc42f | ||
|
|
c2d266efc6 | ||
|
|
ec1859b095 | ||
|
|
bc00cdeb2c | ||
|
|
3e6e35f383 | ||
|
|
b9e8e20c9c | ||
|
|
932988af46 | ||
|
|
69bc9224db | ||
|
|
a17efe6e8f | ||
|
|
e8b0722137 | ||
|
|
ed128fff26 | ||
|
|
a465fd5b99 | ||
|
|
9af0142a36 | ||
|
|
34fd47887e | ||
|
|
2dc9a0c724 | ||
|
|
c357985135 | ||
|
|
ae2b7f9523 | ||
|
|
5344dec760 | ||
|
|
89bc306632 | ||
|
|
dc05b106f2 | ||
|
|
a416cf7c45 | ||
|
|
09010410cf | ||
|
|
f8bbecebf5 | ||
|
|
9d67037570 | ||
|
|
e4daa4c065 | ||
|
|
08a10b8a6a | ||
|
|
af32240545 | ||
|
|
ee0d3bacbc | ||
|
|
9dcfa882b1 | ||
|
|
cb589b1f99 | ||
|
|
e6e3eef0ef | ||
|
|
0e113a4c81 | ||
|
|
1da3a8e24b | ||
|
|
3509714951 | ||
|
|
146be1f0b6 | ||
|
|
223a4f4741 | ||
|
|
1f1c1790f5 | ||
|
|
2ca00fa585 | ||
|
|
1901158b3e | ||
|
|
63d3403a20 | ||
|
|
7f7fe444d3 | ||
|
|
f4272ccf8f | ||
|
|
4196b0d341 | ||
|
|
ebc7a36a83 | ||
|
|
aab50cd2cc | ||
|
|
96c30452f9 | ||
|
|
4d0f227c70 | ||
|
|
50b87c3791 | ||
|
|
b6539399f4 | ||
|
|
8b8ef8acc0 |
42
.gitignore
vendored
@@ -1,5 +1,29 @@
|
||||
map/*
|
||||
world/*
|
||||
## Generic ignorable patterns and files
|
||||
*~
|
||||
.*.swp
|
||||
*bak*
|
||||
tags
|
||||
*.vim
|
||||
|
||||
## Non-static Minetest directories
|
||||
/bin/
|
||||
/games/*
|
||||
!/games/minimal/
|
||||
/cache/
|
||||
/textures/
|
||||
/sounds/
|
||||
/mods/*
|
||||
!/mods/minetest/
|
||||
/mods/minetest/*
|
||||
!/mods/minetest/mods_here.txt
|
||||
/worlds/
|
||||
/world/
|
||||
|
||||
## Configuration/log files
|
||||
minetest.conf
|
||||
debug.txt
|
||||
|
||||
## Build files
|
||||
CMakeFiles/*
|
||||
src/CMakeFiles/*
|
||||
src/Makefile
|
||||
@@ -9,19 +33,13 @@ src/jthread/CMakeFiles/*
|
||||
src/jthread/Makefile
|
||||
src/jthread/cmake_config.h
|
||||
src/jthread/cmake_install.cmake
|
||||
.*.swp
|
||||
minetest.conf
|
||||
bin/
|
||||
src/jthread/libjthread.a
|
||||
src/lua/build/
|
||||
src/lua/CMakeFiles/
|
||||
CMakeCache.txt
|
||||
CPackConfig.cmake
|
||||
CPackSourceConfig.cmake
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
src/jthread/libjthread.a
|
||||
debug.txt
|
||||
bin/debug.txt
|
||||
minetestmapper/map.png
|
||||
locale/
|
||||
src/lua/build/
|
||||
src/lua/CMakeFiles/
|
||||
*bak*
|
||||
|
||||
|
||||
25
.hgignore
@@ -1,25 +0,0 @@
|
||||
map/*
|
||||
world/*
|
||||
CMakeFiles/*
|
||||
src/CMakeFiles/*
|
||||
src/Makefile
|
||||
src/cmake_config.h
|
||||
src/cmake_install.cmake
|
||||
src/jthread/CMakeFiles/*
|
||||
src/jthread/Makefile
|
||||
src/jthread/cmake_config.h
|
||||
src/jthread/cmake_install.cmake
|
||||
src/.*.swp
|
||||
src/sqlite/libsqlite3.a
|
||||
src/session.vim
|
||||
util/uloste.png
|
||||
minetest.conf
|
||||
debug.txt
|
||||
bin/
|
||||
CMakeCache.txt
|
||||
CPackConfig.cmake
|
||||
CPackSourceConfig.cmake
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
src/jthread/libjthread.a
|
||||
data_temp/*
|
||||
@@ -10,7 +10,7 @@ project(minetest)
|
||||
# Also remember to set PROTOCOL_VERSION in clientserver.h when releasing
|
||||
set(VERSION_MAJOR 0)
|
||||
set(VERSION_MINOR 4)
|
||||
set(VERSION_PATCH dev-20111201-0)
|
||||
set(VERSION_PATCH dev-20120326)
|
||||
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
||||
|
||||
MESSAGE(STATUS "*** Will build version ${VERSION_STRING} ***")
|
||||
@@ -49,26 +49,61 @@ find_package(Irrlicht)
|
||||
#
|
||||
|
||||
if(WIN32)
|
||||
set(DATADIR "data")
|
||||
set(SHAREDIR ".")
|
||||
set(BINDIR "bin")
|
||||
set(DOCDIR "doc")
|
||||
set(EXAMPLE_CONF_DIR ".")
|
||||
set(LOCALEDIR "locale")
|
||||
elseif(APPLE)
|
||||
# random placeholders
|
||||
set(DATADIR "share/${PROJECT_NAME}")
|
||||
# Random placeholders; this isn't usually used and may not work
|
||||
# See https://github.com/toabi/minetest-mac/
|
||||
set(SHAREDIR "share/${PROJECT_NAME}")
|
||||
set(BINDIR "bin")
|
||||
set(DOCDIR "share/doc/${PROJECT_NAME}")
|
||||
set(EXAMPLE_CONF_DIR ".")
|
||||
set(EXAMPLE_CONF_DIR ${DOCDIR})
|
||||
set(LOCALEDIR "locale")
|
||||
elseif(UNIX) # Linux, BSD etc
|
||||
set(DATADIR "share/${PROJECT_NAME}")
|
||||
set(BINDIR "bin")
|
||||
set(DOCDIR "share/doc/${PROJECT_NAME}")
|
||||
set(EXAMPLE_CONF_DIR "share/doc/${PROJECT_NAME}")
|
||||
if(RUN_IN_PLACE)
|
||||
set(SHAREDIR ".")
|
||||
set(BINDIR "bin")
|
||||
set(DOCDIR "doc")
|
||||
set(EXAMPLE_CONF_DIR ".")
|
||||
set(MANDIR "unix/man")
|
||||
set(XDG_APPS_DIR "unix/applications")
|
||||
set(ICONDIR "unix/icons")
|
||||
set(LOCALEDIR "locale")
|
||||
else()
|
||||
set(SHAREDIR "share/${PROJECT_NAME}")
|
||||
set(BINDIR "bin")
|
||||
set(DOCDIR "share/doc/${PROJECT_NAME}")
|
||||
set(MANDIR "share/man")
|
||||
set(EXAMPLE_CONF_DIR ${DOCDIR})
|
||||
set(XDG_APPS_DIR "share/applications")
|
||||
set(ICONDIR "share/icons")
|
||||
set(LOCALEDIR "share/locale")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/builtin" DESTINATION "${SHAREDIR}")
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/games/minetest" DESTINATION "${SHAREDIR}/games")
|
||||
if(BUILD_CLIENT)
|
||||
#install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/sounds/base/pack" DESTINATION "${SHAREDIR}/sounds/base")
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/textures/base/pack" DESTINATION "${SHAREDIR}/textures/base")
|
||||
endif()
|
||||
if(RUN_IN_PLACE)
|
||||
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/mods/minetest/mods_here.txt" DESTINATION "${SHAREDIR}/mods/minetest")
|
||||
endif()
|
||||
|
||||
install(FILES "README.txt" DESTINATION "${DOCDIR}")
|
||||
install(FILES "doc/changelog.txt" DESTINATION "${DOCDIR}")
|
||||
install(FILES "minetest.conf.example" DESTINATION "${DOCDIR}")
|
||||
install(FILES "doc/lua_api.txt" DESTINATION "${DOCDIR}")
|
||||
install(FILES "doc/mapformat.txt" DESTINATION "${DOCDIR}")
|
||||
install(FILES "minetest.conf.example" DESTINATION "${EXAMPLE_CONF_DIR}")
|
||||
|
||||
if(UNIX)
|
||||
install(FILES "doc/minetest.6" "doc/minetestserver.6" DESTINATION "${MANDIR}/man6")
|
||||
install(FILES "misc/minetest.desktop" DESTINATION "${XDG_APPS_DIR}")
|
||||
install(FILES "misc/minetest-icon.svg" DESTINATION "${ICONDIR}/hicolor/scalable/apps")
|
||||
endif()
|
||||
|
||||
#
|
||||
# Subdirectories
|
||||
|
||||
138
README.txt
@@ -1,50 +1,75 @@
|
||||
Minetest-c55
|
||||
---------------
|
||||
An InfiniMiner/Minecraft inspired game.
|
||||
Copyright (c) 2010-2011 Perttu Ahola <celeron55@gmail.com>
|
||||
(see source files for other contributors)
|
||||
============
|
||||
|
||||
Further documentation:
|
||||
An InfiniMiner/Minecraft inspired game.
|
||||
|
||||
Copyright (c) 2010-2012 Perttu Ahola <celeron55@gmail.com>
|
||||
and ther contributors (see source file comments and the version control log)
|
||||
|
||||
In case you downloaded the source code:
|
||||
---------------------------------------
|
||||
If you downloaded the Minetest Engine source code in which this file is
|
||||
contained, you probably want to download the minetest_game project too:
|
||||
https://github.com/celeron55/minetest_game/
|
||||
See the README.txt in it.
|
||||
|
||||
Further documentation
|
||||
----------------------
|
||||
- Website: http://celeron.55.lt/~celeron55/minetest/
|
||||
- Wiki: http://celeron.55.lt/~celeron55/minetest/wiki/
|
||||
- Forum: http://celeron.55.lt/~celeron55/minetest/forum/
|
||||
- Website: http://c55.me/minetest/
|
||||
- Wiki: http://c55.me/minetest/wiki/
|
||||
- Forum: http://c55.me/minetest/forum/
|
||||
- Github: https://github.com/celeron55/minetest/
|
||||
- doc/ directory of source distribution
|
||||
|
||||
This game is not finished:
|
||||
This game is not finished
|
||||
--------------------------
|
||||
- Don't expect it to work as well as a finished game will.
|
||||
- Please report any bugs to me. debug.txt is useful.
|
||||
- Please report any bugs. When doing that, debug.txt is useful.
|
||||
|
||||
Controls:
|
||||
---------
|
||||
- See the in-game pause menu
|
||||
Default Controls
|
||||
-----------------
|
||||
- WASD: Move
|
||||
- Space: Jump
|
||||
- E: Go down
|
||||
- Shift: Sneak
|
||||
- Q: Drop item
|
||||
- I: Open inventory
|
||||
- Mouse: Turn/look
|
||||
- Settable in the configuration file, see the section below.
|
||||
|
||||
Map directory:
|
||||
--------------
|
||||
- Map is stored in a directory, which can be removed to generate a new map.
|
||||
- There is a command-line option for it: --map-dir
|
||||
- For a RUN_IN_PLACE build, it is located in:
|
||||
../world
|
||||
- Otherwise something like this:
|
||||
Windows: C:\Documents and Settings\user\Application Data\minetest\world
|
||||
Linux: ~/.minetest/world
|
||||
OS X: ~/Library/Application Support/minetest/world
|
||||
Paths
|
||||
------
|
||||
$bin - Compiled binaries
|
||||
$share - Cistributed read-only data
|
||||
$user - User-created modifiable data
|
||||
|
||||
Windows .zip / RUN_IN_PLACE source:
|
||||
$bin = bin
|
||||
$share = .
|
||||
$user = .
|
||||
|
||||
Linux installed:
|
||||
$bin = /usr/bin
|
||||
$share = /usr/share/minetest
|
||||
$user = ~/.minetest
|
||||
|
||||
OS X:
|
||||
$bin = ?
|
||||
$share = ?
|
||||
$user = ~/Library/Application Support/minetest
|
||||
|
||||
World directory
|
||||
----------------
|
||||
- Worlds can be found as separate folders in:
|
||||
$user/worlds/
|
||||
|
||||
Configuration file:
|
||||
-------------------
|
||||
- An optional configuration file can be used. See minetest.conf.example.
|
||||
- Path to file can be passed as a parameter to the executable:
|
||||
- Default location:
|
||||
$user/minetest.conf
|
||||
- It is created by Minetest when it is ran the first time.
|
||||
- A specific file can be specified on the command line:
|
||||
--config <path-to-file>
|
||||
- Defaults:
|
||||
- If built with -DRUN_IN_PLACE=1:
|
||||
../minetest.conf
|
||||
../../minetest.conf
|
||||
- Otherwise something like this:
|
||||
Windows: C:\Documents and Settings\user\Application Data\minetest\minetest.conf
|
||||
Linux: ~/.minetest/minetest.conf
|
||||
OS X: ~/Library/Application Support/minetest.conf
|
||||
|
||||
Command-line options:
|
||||
---------------------
|
||||
@@ -94,12 +119,13 @@ Compiling on Windows:
|
||||
http://gnuwin32.sourceforge.net/downlinks/gettext.php
|
||||
- This is used for other UI languages. Feel free to leave it out.
|
||||
* And, of course, Minetest-c55:
|
||||
http://celeron.55.lt/~celeron55/minetest/download
|
||||
http://c55.me/minetest/download
|
||||
- Steps:
|
||||
- Select a directory called DIR hereafter in which you will operate.
|
||||
- Make sure you have CMake and a compiler installed.
|
||||
- Download all the other stuff to DIR and extract them into there.
|
||||
("extract here", not "extract to packagename/")
|
||||
NOTE: zlib125dll.zip needs to be extracted into zlib125dll
|
||||
- All those packages contain a nice base directory in them, which
|
||||
should end up being the direct subdirectories of DIR.
|
||||
- You will end up with a directory structure like this (+=dir, -=file):
|
||||
@@ -176,35 +202,49 @@ Compiling on Windows:
|
||||
If using MinGW:
|
||||
- Using the command line, browse to the build directory and run 'make'
|
||||
(or mingw32-make or whatever it happens to be)
|
||||
- You may need to copy some of the downloaded DLLs into bin/, see what
|
||||
running the produced executable tells you it doesn't have.
|
||||
- You should now have a working game with the executable in
|
||||
DIR/minetest/bin/minetest.exe
|
||||
|
||||
Windows releases of minetest are built using a bat script like this:
|
||||
--------------------------------------------------------------------
|
||||
|
||||
set sourcedir=%CD%
|
||||
set installpath="C:\tmp\minetest_install"
|
||||
set irrlichtpath="C:\tmp\irrlicht-1.7.2"
|
||||
|
||||
set sourcedir=%CD%
|
||||
set builddir=%sourcedir%\bvc10
|
||||
mkdir %builddir%
|
||||
pushd %builddir%
|
||||
cmake %sourcedir% -G "Visual Studio 10" -DIRRLICHT_SOURCE_DIR=%irrlichtpath% -DRUN_IN_PLACE=1 -DCMAKE_INSTALL_PREFIX=%installpath%
|
||||
if %errorlevel% neq 0 goto fail
|
||||
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration=Release
|
||||
if %errorlevel% neq 0 goto fail
|
||||
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" INSTALL.vcxproj /p:Configuration=Release
|
||||
if %errorlevel% neq 0 goto fail
|
||||
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" PACKAGE.vcxproj /p:Configuration=Release
|
||||
if %errorlevel% neq 0 goto fail
|
||||
popd
|
||||
echo Finished.
|
||||
exit /b 0
|
||||
|
||||
License of Minetest-c55 textures
|
||||
--------------------------------
|
||||
:fail
|
||||
popd
|
||||
echo Failed.
|
||||
exit /b 1
|
||||
|
||||
This does not apply to texture packs made by others.
|
||||
License of Minetest-c55 textures and sounds
|
||||
-------------------------------------------
|
||||
|
||||
This applies to textures and sounds contained in the main Minetest
|
||||
distribution.
|
||||
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
License of Minetest-c55
|
||||
-----------------------
|
||||
License of Minetest-c55 source code
|
||||
-----------------------------------
|
||||
|
||||
Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
@@ -276,3 +316,21 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
|
||||
|
||||
Fonts
|
||||
---------------
|
||||
|
||||
DejaVu Sans Mono:
|
||||
|
||||
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
|
||||
Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)
|
||||
|
||||
Bitstream Vera Fonts Copyright:
|
||||
|
||||
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
|
||||
a trademark of Bitstream, Inc.
|
||||
|
||||
Arev Fonts Copyright:
|
||||
|
||||
Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.
|
||||
|
||||
|
||||
|
||||
804
builtin/builtin.lua
Normal file
@@ -0,0 +1,804 @@
|
||||
--
|
||||
-- This file contains built-in stuff in Minetest implemented in Lua.
|
||||
--
|
||||
-- It is always loaded and executed after registration of the C API,
|
||||
-- before loading and running any mods.
|
||||
--
|
||||
|
||||
--
|
||||
-- Override some Lua library functions
|
||||
--
|
||||
|
||||
print = minetest.debug
|
||||
|
||||
--
|
||||
--
|
||||
--
|
||||
|
||||
function basic_dump2(o)
|
||||
if type(o) == "number" then
|
||||
return tostring(o)
|
||||
elseif type(o) == "string" then
|
||||
return string.format("%q", o)
|
||||
elseif type(o) == "boolean" then
|
||||
return tostring(o)
|
||||
elseif type(o) == "function" then
|
||||
return "<function>"
|
||||
elseif type(o) == "userdata" then
|
||||
return "<userdata>"
|
||||
elseif type(o) == "nil" then
|
||||
return "nil"
|
||||
else
|
||||
error("cannot dump a " .. type(o))
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
function dump2(o, name, dumped)
|
||||
name = name or "_"
|
||||
dumped = dumped or {}
|
||||
io.write(name, " = ")
|
||||
if type(o) == "number" or type(o) == "string" or type(o) == "boolean"
|
||||
or type(o) == "function" or type(o) == "nil"
|
||||
or type(o) == "userdata" then
|
||||
io.write(basic_dump2(o), "\n")
|
||||
elseif type(o) == "table" then
|
||||
if dumped[o] then
|
||||
io.write(dumped[o], "\n")
|
||||
else
|
||||
dumped[o] = name
|
||||
io.write("{}\n") -- new table
|
||||
for k,v in pairs(o) do
|
||||
local fieldname = string.format("%s[%s]", name, basic_dump2(k))
|
||||
dump2(v, fieldname, dumped)
|
||||
end
|
||||
end
|
||||
else
|
||||
error("cannot dump a " .. type(o))
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
function dump(o, dumped)
|
||||
dumped = dumped or {}
|
||||
if type(o) == "number" then
|
||||
return tostring(o)
|
||||
elseif type(o) == "string" then
|
||||
return string.format("%q", o)
|
||||
elseif type(o) == "table" then
|
||||
if dumped[o] then
|
||||
return "<circular reference>"
|
||||
end
|
||||
dumped[o] = true
|
||||
local t = {}
|
||||
for k,v in pairs(o) do
|
||||
t[#t+1] = "" .. k .. " = " .. dump(v, dumped)
|
||||
end
|
||||
return "{" .. table.concat(t, ", ") .. "}"
|
||||
elseif type(o) == "boolean" then
|
||||
return tostring(o)
|
||||
elseif type(o) == "function" then
|
||||
return "<function>"
|
||||
elseif type(o) == "userdata" then
|
||||
return "<userdata>"
|
||||
elseif type(o) == "nil" then
|
||||
return "nil"
|
||||
else
|
||||
error("cannot dump a " .. type(o))
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- Item definition helpers
|
||||
--
|
||||
|
||||
function minetest.inventorycube(img1, img2, img3)
|
||||
img2 = img2 or img1
|
||||
img3 = img3 or img1
|
||||
return "[inventorycube"
|
||||
.. "{" .. img1:gsub("%^", "&")
|
||||
.. "{" .. img2:gsub("%^", "&")
|
||||
.. "{" .. img3:gsub("%^", "&")
|
||||
end
|
||||
|
||||
function minetest.pos_to_string(pos)
|
||||
return "(" .. pos.x .. "," .. pos.y .. "," .. pos.z .. ")"
|
||||
end
|
||||
|
||||
function minetest.get_pointed_thing_position(pointed_thing, above)
|
||||
if pointed_thing.type == "node" then
|
||||
if above then
|
||||
-- The position where a node would be placed
|
||||
return pointed_thing.above
|
||||
else
|
||||
-- The position where a node would be dug
|
||||
return pointed_thing.under
|
||||
end
|
||||
elseif pointed_thing.type == "object" then
|
||||
obj = pointed_thing.ref
|
||||
if obj ~= nil then
|
||||
return obj:getpos()
|
||||
else
|
||||
return nil
|
||||
end
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
function minetest.dir_to_facedir(dir)
|
||||
if math.abs(dir.x) > math.abs(dir.z) then
|
||||
if dir.x < 0 then
|
||||
return 3
|
||||
else
|
||||
return 1
|
||||
end
|
||||
else
|
||||
if dir.z < 0 then
|
||||
return 2
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function minetest.dir_to_wallmounted(dir)
|
||||
if math.abs(dir.y) > math.max(math.abs(dir.x), math.abs(dir.z)) then
|
||||
if dir.y < 0 then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
end
|
||||
elseif math.abs(dir.x) > math.abs(dir.z) then
|
||||
if dir.x < 0 then
|
||||
return 3
|
||||
else
|
||||
return 2
|
||||
end
|
||||
else
|
||||
if dir.z < 0 then
|
||||
return 5
|
||||
else
|
||||
return 4
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function minetest.get_node_drops(nodename, toolname)
|
||||
local drop = ItemStack({name=nodename}):get_definition().drop
|
||||
if drop == nil then
|
||||
-- default drop
|
||||
return {ItemStack({name=nodename})}
|
||||
elseif type(drop) == "string" then
|
||||
-- itemstring drop
|
||||
return {ItemStack(drop)}
|
||||
elseif drop.items == nil then
|
||||
-- drop = {} to disable default drop
|
||||
return {}
|
||||
end
|
||||
|
||||
-- Extended drop table
|
||||
local got_items = {}
|
||||
local got_count = 0
|
||||
local _, item, tool
|
||||
for _, item in ipairs(drop.items) do
|
||||
local good_rarity = true
|
||||
local good_tool = true
|
||||
if item.rarity ~= nil then
|
||||
good_rarity = item.rarity < 1 or math.random(item.rarity) == 1
|
||||
end
|
||||
if item.tools ~= nil then
|
||||
good_tool = false
|
||||
for _, tool in ipairs(item.tools) do
|
||||
if tool:sub(1, 1) == '~' then
|
||||
good_tool = toolname:find(tool:sub(2)) ~= nil
|
||||
else
|
||||
good_tool = toolname == tool
|
||||
end
|
||||
if good_tool then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if good_rarity and good_tool then
|
||||
got_count = got_count + 1
|
||||
for _, add_item in ipairs(item.items) do
|
||||
got_items[#got_items+1] = add_item
|
||||
end
|
||||
if drop.max_items ~= nil and got_count == drop.max_items then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
return got_items
|
||||
end
|
||||
|
||||
function minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||
local item = itemstack:peek_item()
|
||||
local def = itemstack:get_definition()
|
||||
if def.type == "node" and pointed_thing.type == "node" then
|
||||
local pos = pointed_thing.above
|
||||
local oldnode = minetest.env:get_node(pos)
|
||||
local olddef = ItemStack({name=oldnode.name}):get_definition()
|
||||
|
||||
if not olddef.buildable_to then
|
||||
minetest.log("info", placer:get_player_name() .. " tried to place"
|
||||
.. " node in invalid position " .. minetest.pos_to_string(pos)
|
||||
.. ", replacing " .. oldnode.name)
|
||||
return
|
||||
end
|
||||
|
||||
minetest.log("action", placer:get_player_name() .. " places node "
|
||||
.. def.name .. " at " .. minetest.pos_to_string(pos))
|
||||
|
||||
local newnode = {name = def.name, param1 = 0, param2 = 0}
|
||||
|
||||
-- Calculate direction for wall mounted stuff like torches and signs
|
||||
if def.paramtype2 == 'wallmounted' then
|
||||
local under = pointed_thing.under
|
||||
local above = pointed_thing.above
|
||||
local dir = {x = under.x - above.x, y = under.y - above.y, z = under.z - above.z}
|
||||
newnode.param2 = minetest.dir_to_wallmounted(dir)
|
||||
-- Calculate the direction for furnaces and chests and stuff
|
||||
elseif def.paramtype2 == 'facedir' then
|
||||
local playerpos = placer:getpos()
|
||||
local dir = {x = pos.x - playerpos.x, y = pos.y - playerpos.y, z = pos.z - playerpos.z}
|
||||
newnode.param2 = minetest.dir_to_facedir(dir)
|
||||
minetest.log("action", "facedir: " .. newnode.param2)
|
||||
end
|
||||
|
||||
-- Add node and update
|
||||
minetest.env:add_node(pos, newnode)
|
||||
|
||||
-- Set metadata owner
|
||||
if def.metadata_name ~= "" then
|
||||
minetest.env:get_meta(pos):set_owner(placer:get_player_name())
|
||||
end
|
||||
|
||||
-- Run script hook
|
||||
local _, callback
|
||||
for _, callback in ipairs(minetest.registered_on_placenodes) do
|
||||
callback(pos, newnode, placer)
|
||||
end
|
||||
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
||||
function minetest.item_place_object(itemstack, placer, pointed_thing)
|
||||
local pos = minetest.get_pointed_thing_position(pointed_thing, true)
|
||||
if pos ~= nil then
|
||||
local item = itemstack:take_item()
|
||||
minetest.env:add_item(pos, item)
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
||||
function minetest.item_place(itemstack, placer, pointed_thing)
|
||||
if itemstack:get_definition().type == "node" then
|
||||
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||
else
|
||||
return minetest.item_place_object(itemstack, placer, pointed_thing)
|
||||
end
|
||||
end
|
||||
|
||||
function minetest.item_drop(itemstack, dropper, pos)
|
||||
minetest.env:add_item(pos, itemstack)
|
||||
return ""
|
||||
end
|
||||
|
||||
function minetest.item_eat(hp_change, replace_with_item)
|
||||
return function(itemstack, user, pointed_thing) -- closure
|
||||
if itemstack:take_item() ~= nil then
|
||||
user:set_hp(user:get_hp() + hp_change)
|
||||
itemstack:add_item(replace_with_item) -- note: replace_with_item is optional
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
|
||||
function minetest.node_punch(pos, node, puncher)
|
||||
-- Run script hook
|
||||
local _, callback
|
||||
for _, callback in ipairs(minetest.registered_on_punchnodes) do
|
||||
callback(pos, node, puncher)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function minetest.node_dig(pos, node, digger)
|
||||
minetest.debug("node_dig")
|
||||
|
||||
local def = ItemStack({name=node.name}):get_definition()
|
||||
if not def.diggable then
|
||||
minetest.debug("not diggable")
|
||||
minetest.log("info", digger:get_player_name() .. " tried to dig "
|
||||
.. node.name .. " which is not diggable "
|
||||
.. minetest.pos_to_string(pos))
|
||||
return
|
||||
end
|
||||
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
if meta ~= nil and not meta:get_allow_removal() then
|
||||
minetest.debug("dig prevented by metadata")
|
||||
minetest.log("info", digger:get_player_name() .. " tried to dig "
|
||||
.. node.name .. ", but removal is disabled by metadata "
|
||||
.. minetest.pos_to_string(pos))
|
||||
return
|
||||
end
|
||||
|
||||
minetest.log('action', digger:get_player_name() .. " digs "
|
||||
.. node.name .. " at " .. minetest.pos_to_string(pos))
|
||||
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
local wielded = digger:get_wielded_item()
|
||||
local drops = minetest.get_node_drops(node.name, wielded:get_name())
|
||||
|
||||
-- Wear out tool
|
||||
tp = wielded:get_tool_capabilities()
|
||||
dp = minetest.get_dig_params(def.groups, tp)
|
||||
wielded:add_wear(dp.wear)
|
||||
digger:set_wielded_item(wielded)
|
||||
|
||||
-- Add dropped items
|
||||
local _, dropped_item
|
||||
for _, dropped_item in ipairs(drops) do
|
||||
digger:get_inventory():add_item("main", dropped_item)
|
||||
end
|
||||
end
|
||||
|
||||
-- Remove node and update
|
||||
minetest.env:remove_node(pos)
|
||||
|
||||
-- Run script hook
|
||||
local _, callback
|
||||
for _, callback in ipairs(minetest.registered_on_dignodes) do
|
||||
callback(pos, node, digger)
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- Item definition defaults
|
||||
--
|
||||
|
||||
minetest.nodedef_default = {
|
||||
-- Item properties
|
||||
type="node",
|
||||
-- name intentionally not defined here
|
||||
description = "",
|
||||
groups = {},
|
||||
inventory_image = "",
|
||||
wield_image = "",
|
||||
wield_scale = {x=1,y=1,z=1},
|
||||
stack_max = 99,
|
||||
usable = false,
|
||||
liquids_pointable = false,
|
||||
tool_capabilities = nil,
|
||||
|
||||
-- Interaction callbacks
|
||||
on_place = minetest.item_place,
|
||||
on_drop = minetest.item_drop,
|
||||
on_use = nil,
|
||||
|
||||
on_punch = minetest.node_punch,
|
||||
on_dig = minetest.node_dig,
|
||||
|
||||
-- Node properties
|
||||
drawtype = "normal",
|
||||
visual_scale = 1.0,
|
||||
tile_images = {""},
|
||||
special_materials = {
|
||||
{image="", backface_culling=true},
|
||||
{image="", backface_culling=true},
|
||||
},
|
||||
alpha = 255,
|
||||
post_effect_color = {a=0, r=0, g=0, b=0},
|
||||
paramtype = "none",
|
||||
paramtype2 = "none",
|
||||
is_ground_content = false,
|
||||
sunlight_propagates = false,
|
||||
walkable = true,
|
||||
pointable = true,
|
||||
diggable = true,
|
||||
climbable = false,
|
||||
buildable_to = false,
|
||||
metadata_name = "",
|
||||
liquidtype = "none",
|
||||
liquid_alternative_flowing = "",
|
||||
liquid_alternative_source = "",
|
||||
liquid_viscosity = 0,
|
||||
light_source = 0,
|
||||
damage_per_second = 0,
|
||||
selection_box = {type="regular"},
|
||||
legacy_facedir_simple = false,
|
||||
legacy_wallmounted = false,
|
||||
}
|
||||
|
||||
minetest.craftitemdef_default = {
|
||||
type="craft",
|
||||
-- name intentionally not defined here
|
||||
description = "",
|
||||
groups = {},
|
||||
inventory_image = "",
|
||||
wield_image = "",
|
||||
wield_scale = {x=1,y=1,z=1},
|
||||
stack_max = 99,
|
||||
liquids_pointable = false,
|
||||
tool_capabilities = nil,
|
||||
|
||||
-- Interaction callbacks
|
||||
on_place = minetest.item_place,
|
||||
on_drop = minetest.item_drop,
|
||||
on_use = nil,
|
||||
}
|
||||
|
||||
minetest.tooldef_default = {
|
||||
type="tool",
|
||||
-- name intentionally not defined here
|
||||
description = "",
|
||||
groups = {},
|
||||
inventory_image = "",
|
||||
wield_image = "",
|
||||
wield_scale = {x=1,y=1,z=1},
|
||||
stack_max = 1,
|
||||
liquids_pointable = false,
|
||||
tool_capabilities = nil,
|
||||
|
||||
-- Interaction callbacks
|
||||
on_place = minetest.item_place,
|
||||
on_drop = minetest.item_drop,
|
||||
on_use = nil,
|
||||
}
|
||||
|
||||
minetest.noneitemdef_default = { -- This is used for the hand and unknown items
|
||||
type="none",
|
||||
-- name intentionally not defined here
|
||||
description = "",
|
||||
groups = {},
|
||||
inventory_image = "",
|
||||
wield_image = "",
|
||||
wield_scale = {x=1,y=1,z=1},
|
||||
stack_max = 99,
|
||||
liquids_pointable = false,
|
||||
tool_capabilities = nil,
|
||||
|
||||
-- Interaction callbacks
|
||||
on_place = nil,
|
||||
on_drop = nil,
|
||||
on_use = nil,
|
||||
}
|
||||
|
||||
--
|
||||
-- Make raw registration functions inaccessible to anyone except builtin.lua
|
||||
--
|
||||
|
||||
local register_item_raw = minetest.register_item_raw
|
||||
minetest.register_item_raw = nil
|
||||
|
||||
local register_alias_raw = minetest.register_alias_raw
|
||||
minetest.register_item_raw = nil
|
||||
|
||||
--
|
||||
-- Item / entity / ABM registration functions
|
||||
--
|
||||
|
||||
minetest.registered_abms = {}
|
||||
minetest.registered_entities = {}
|
||||
minetest.registered_items = {}
|
||||
minetest.registered_nodes = {}
|
||||
minetest.registered_craftitems = {}
|
||||
minetest.registered_tools = {}
|
||||
minetest.registered_aliases = {}
|
||||
|
||||
-- For tables that are indexed by item name:
|
||||
-- If table[X] does not exist, default to table[minetest.registered_aliases[X]]
|
||||
local function set_alias_metatable(table)
|
||||
setmetatable(table, {
|
||||
__index = function(name)
|
||||
return rawget(table, minetest.registered_aliases[name])
|
||||
end
|
||||
})
|
||||
end
|
||||
set_alias_metatable(minetest.registered_items)
|
||||
set_alias_metatable(minetest.registered_nodes)
|
||||
set_alias_metatable(minetest.registered_craftitems)
|
||||
set_alias_metatable(minetest.registered_tools)
|
||||
|
||||
-- These item names may not be used because they would interfere
|
||||
-- with legacy itemstrings
|
||||
local forbidden_item_names = {
|
||||
MaterialItem = true,
|
||||
MaterialItem2 = true,
|
||||
MaterialItem3 = true,
|
||||
NodeItem = true,
|
||||
node = true,
|
||||
CraftItem = true,
|
||||
craft = true,
|
||||
MBOItem = true,
|
||||
ToolItem = true,
|
||||
tool = true,
|
||||
}
|
||||
|
||||
local function check_modname_prefix(name)
|
||||
if name:sub(1,1) == ":" then
|
||||
-- Escape the modname prefix enforcement mechanism
|
||||
return name:sub(2)
|
||||
else
|
||||
-- Modname prefix enforcement
|
||||
local expected_prefix = minetest.get_current_modname() .. ":"
|
||||
if name:sub(1, #expected_prefix) ~= expected_prefix then
|
||||
error("Name " .. name .. " does not follow naming conventions: " ..
|
||||
"\"modname:\" or \":\" prefix required")
|
||||
end
|
||||
local subname = name:sub(#expected_prefix+1)
|
||||
if subname:find("[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]") then
|
||||
error("Name " .. name .. " does not follow naming conventions: " ..
|
||||
"contains unallowed characters")
|
||||
end
|
||||
return name
|
||||
end
|
||||
end
|
||||
|
||||
function minetest.register_abm(spec)
|
||||
-- Add to minetest.registered_abms
|
||||
minetest.registered_abms[#minetest.registered_abms+1] = spec
|
||||
end
|
||||
|
||||
function minetest.register_entity(name, prototype)
|
||||
-- Check name
|
||||
if name == nil then
|
||||
error("Unable to register entity: Name is nil")
|
||||
end
|
||||
name = check_modname_prefix(tostring(name))
|
||||
|
||||
prototype.name = name
|
||||
prototype.__index = prototype -- so that it can be used as a metatable
|
||||
|
||||
-- Add to minetest.registered_entities
|
||||
minetest.registered_entities[name] = prototype
|
||||
end
|
||||
|
||||
function minetest.register_item(name, itemdef)
|
||||
-- Check name
|
||||
if name == nil then
|
||||
error("Unable to register item: Name is nil")
|
||||
end
|
||||
name = check_modname_prefix(tostring(name))
|
||||
if forbidden_item_names[name] then
|
||||
error("Unable to register item: Name is forbidden: " .. name)
|
||||
end
|
||||
itemdef.name = name
|
||||
|
||||
-- Apply defaults and add to registered_* table
|
||||
if itemdef.type == "node" then
|
||||
setmetatable(itemdef, {__index = minetest.nodedef_default})
|
||||
minetest.registered_nodes[itemdef.name] = itemdef
|
||||
elseif itemdef.type == "craft" then
|
||||
setmetatable(itemdef, {__index = minetest.craftitemdef_default})
|
||||
minetest.registered_craftitems[itemdef.name] = itemdef
|
||||
elseif itemdef.type == "tool" then
|
||||
setmetatable(itemdef, {__index = minetest.tooldef_default})
|
||||
minetest.registered_tools[itemdef.name] = itemdef
|
||||
elseif itemdef.type == "none" then
|
||||
setmetatable(itemdef, {__index = minetest.noneitemdef_default})
|
||||
else
|
||||
error("Unable to register item: Type is invalid: " .. dump(itemdef))
|
||||
end
|
||||
|
||||
-- Flowing liquid uses param2
|
||||
if itemdef.type == "node" and itemdef.liquidtype == "flowing" then
|
||||
itemdef.paramtype2 = "flowingliquid"
|
||||
end
|
||||
|
||||
-- BEGIN Legacy stuff
|
||||
if itemdef.cookresult_itemstring ~= nil and itemdef.cookresult_itemstring ~= "" then
|
||||
minetest.register_craft({
|
||||
type="cooking",
|
||||
output=itemdef.cookresult_itemstring,
|
||||
recipe=itemdef.name,
|
||||
cooktime=itemdef.furnace_cooktime
|
||||
})
|
||||
end
|
||||
if itemdef.furnace_burntime ~= nil and itemdef.furnace_burntime >= 0 then
|
||||
minetest.register_craft({
|
||||
type="fuel",
|
||||
recipe=itemdef.name,
|
||||
burntime=itemdef.furnace_burntime
|
||||
})
|
||||
end
|
||||
-- END Legacy stuff
|
||||
|
||||
-- Disable all further modifications
|
||||
getmetatable(itemdef).__newindex = {}
|
||||
|
||||
--minetest.log("Registering item: " .. itemdef.name)
|
||||
minetest.registered_items[itemdef.name] = itemdef
|
||||
minetest.registered_aliases[itemdef.name] = nil
|
||||
register_item_raw(itemdef)
|
||||
end
|
||||
|
||||
function minetest.register_node(name, nodedef)
|
||||
nodedef.type = "node"
|
||||
minetest.register_item(name, nodedef)
|
||||
end
|
||||
|
||||
function minetest.register_craftitem(name, craftitemdef)
|
||||
craftitemdef.type = "craft"
|
||||
|
||||
-- BEGIN Legacy stuff
|
||||
if craftitemdef.inventory_image == nil and craftitemdef.image ~= nil then
|
||||
craftitemdef.inventory_image = craftitemdef.image
|
||||
end
|
||||
-- END Legacy stuff
|
||||
|
||||
minetest.register_item(name, craftitemdef)
|
||||
end
|
||||
|
||||
function minetest.register_tool(name, tooldef)
|
||||
tooldef.type = "tool"
|
||||
tooldef.stack_max = 1
|
||||
|
||||
-- BEGIN Legacy stuff
|
||||
if tooldef.inventory_image == nil and tooldef.image ~= nil then
|
||||
tooldef.inventory_image = tooldef.image
|
||||
end
|
||||
if tooldef.tool_capabilities == nil and
|
||||
(tooldef.full_punch_interval ~= nil or
|
||||
tooldef.basetime ~= nil or
|
||||
tooldef.dt_weight ~= nil or
|
||||
tooldef.dt_crackiness ~= nil or
|
||||
tooldef.dt_crumbliness ~= nil or
|
||||
tooldef.dt_cuttability ~= nil or
|
||||
tooldef.basedurability ~= nil or
|
||||
tooldef.dd_weight ~= nil or
|
||||
tooldef.dd_crackiness ~= nil or
|
||||
tooldef.dd_crumbliness ~= nil or
|
||||
tooldef.dd_cuttability ~= nil) then
|
||||
tooldef.tool_capabilities = {
|
||||
full_punch_interval = tooldef.full_punch_interval,
|
||||
basetime = tooldef.basetime,
|
||||
dt_weight = tooldef.dt_weight,
|
||||
dt_crackiness = tooldef.dt_crackiness,
|
||||
dt_crumbliness = tooldef.dt_crumbliness,
|
||||
dt_cuttability = tooldef.dt_cuttability,
|
||||
basedurability = tooldef.basedurability,
|
||||
dd_weight = tooldef.dd_weight,
|
||||
dd_crackiness = tooldef.dd_crackiness,
|
||||
dd_crumbliness = tooldef.dd_crumbliness,
|
||||
dd_cuttability = tooldef.dd_cuttability,
|
||||
}
|
||||
end
|
||||
-- END Legacy stuff
|
||||
|
||||
minetest.register_item(name, tooldef)
|
||||
end
|
||||
|
||||
function minetest.register_alias(name, convert_to)
|
||||
if forbidden_item_names[name] then
|
||||
error("Unable to register alias: Name is forbidden: " .. name)
|
||||
end
|
||||
if minetest.registered_items[name] ~= nil then
|
||||
minetest.log("WARNING: Not registering alias, item with same name" ..
|
||||
" is already defined: " .. name .. " -> " .. convert_to)
|
||||
else
|
||||
--minetest.log("Registering alias: " .. name .. " -> " .. convert_to)
|
||||
minetest.registered_aliases[name] = convert_to
|
||||
register_alias_raw(name, convert_to)
|
||||
end
|
||||
end
|
||||
|
||||
-- Alias the forbidden item names to "" so they can't be
|
||||
-- created via itemstrings (e.g. /give)
|
||||
local name
|
||||
for name in pairs(forbidden_item_names) do
|
||||
minetest.registered_aliases[name] = ""
|
||||
register_alias_raw(name, "")
|
||||
end
|
||||
|
||||
|
||||
-- Deprecated:
|
||||
-- Aliases for minetest.register_alias (how ironic...)
|
||||
--minetest.alias_node = minetest.register_alias
|
||||
--minetest.alias_tool = minetest.register_alias
|
||||
--minetest.alias_craftitem = minetest.register_alias
|
||||
|
||||
--
|
||||
-- Built-in node definitions. Also defined in C.
|
||||
--
|
||||
|
||||
minetest.register_item(":unknown", {
|
||||
type = "none",
|
||||
description = "Unknown Item",
|
||||
inventory_image = "unknown_item.png",
|
||||
on_place = minetest.item_place,
|
||||
on_drop = minetest.item_drop,
|
||||
})
|
||||
|
||||
minetest.register_node(":air", {
|
||||
description = "Air (you hacker you!)",
|
||||
inventory_image = "unknown_block.png",
|
||||
wield_image = "unknown_block.png",
|
||||
drawtype = "airlike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
air_equivalent = true,
|
||||
})
|
||||
|
||||
minetest.register_node(":ignore", {
|
||||
description = "Ignore (you hacker you!)",
|
||||
inventory_image = "unknown_block.png",
|
||||
wield_image = "unknown_block.png",
|
||||
drawtype = "airlike",
|
||||
paramtype = "none",
|
||||
sunlight_propagates = false,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true, -- A way to remove accidentally placed ignores
|
||||
air_equivalent = true,
|
||||
})
|
||||
|
||||
-- The hand (bare definition)
|
||||
minetest.register_item(":", {
|
||||
type = "none",
|
||||
})
|
||||
|
||||
--
|
||||
-- Default material types
|
||||
--
|
||||
function digprop_err()
|
||||
minetest.log("info", debug.traceback())
|
||||
minetest.log("info", "WARNING: The minetest.digprop_* functions are obsolete and need to be replaced by item groups.")
|
||||
end
|
||||
|
||||
minetest.digprop_constanttime = digprop_err
|
||||
minetest.digprop_stonelike = digprop_err
|
||||
minetest.digprop_dirtlike = digprop_err
|
||||
minetest.digprop_gravellike = digprop_err
|
||||
minetest.digprop_woodlike = digprop_err
|
||||
minetest.digprop_leaveslike = digprop_err
|
||||
minetest.digprop_glasslike = digprop_err
|
||||
|
||||
--
|
||||
-- Creative inventory
|
||||
--
|
||||
|
||||
minetest.creative_inventory = {}
|
||||
|
||||
minetest.add_to_creative_inventory = function(itemstring)
|
||||
table.insert(minetest.creative_inventory, itemstring)
|
||||
end
|
||||
|
||||
--
|
||||
-- Callback registration
|
||||
--
|
||||
|
||||
local function make_registration()
|
||||
local t = {}
|
||||
local registerfunc = function(func) table.insert(t, func) end
|
||||
return t, registerfunc
|
||||
end
|
||||
|
||||
minetest.registered_on_chat_messages, minetest.register_on_chat_message = make_registration()
|
||||
minetest.registered_globalsteps, minetest.register_globalstep = make_registration()
|
||||
minetest.registered_on_placenodes, minetest.register_on_placenode = make_registration()
|
||||
minetest.registered_on_dignodes, minetest.register_on_dignode = make_registration()
|
||||
minetest.registered_on_punchnodes, minetest.register_on_punchnode = make_registration()
|
||||
minetest.registered_on_generateds, minetest.register_on_generated = make_registration()
|
||||
minetest.registered_on_newplayers, minetest.register_on_newplayer = make_registration()
|
||||
minetest.registered_on_dieplayers, minetest.register_on_dieplayer = make_registration()
|
||||
minetest.registered_on_respawnplayers, minetest.register_on_respawnplayer = make_registration()
|
||||
|
||||
--
|
||||
-- Set random seed
|
||||
--
|
||||
|
||||
math.randomseed(os.time())
|
||||
|
||||
-- END
|
||||
@@ -59,7 +59,7 @@ ENDIF()
|
||||
IF(GETTEXT_FOUND)
|
||||
SET(GETTEXT_PO_PATH ${CMAKE_SOURCE_DIR}/po)
|
||||
SET(GETTEXT_MO_BUILD_PATH ${CMAKE_BINARY_DIR}/locale/<locale>/LC_MESSAGES)
|
||||
SET(GETTEXT_MO_DEST_PATH ${DATADIR}/../locale/<locale>/LC_MESSAGES)
|
||||
SET(GETTEXT_MO_DEST_PATH ${LOCALEDIR}/<locale>/LC_MESSAGES)
|
||||
FILE(GLOB GETTEXT_AVAILABLE_LOCALES RELATIVE ${GETTEXT_PO_PATH} "${GETTEXT_PO_PATH}/*")
|
||||
LIST(REMOVE_ITEM GETTEXT_AVAILABLE_LOCALES minetest.pot)
|
||||
MACRO(SET_MO_PATHS _buildvar _destvar _locale)
|
||||
|
||||
46
cmake/Modules/FindVorbis.cmake
Normal file
@@ -0,0 +1,46 @@
|
||||
# - Find vorbis
|
||||
# Find the native vorbis includes and libraries
|
||||
#
|
||||
# VORBIS_INCLUDE_DIR - where to find vorbis.h, etc.
|
||||
# OGG_INCLUDE_DIR - where to find ogg/ogg.h, etc.
|
||||
# VORBIS_LIBRARIES - List of libraries when using vorbis(file).
|
||||
# VORBIS_FOUND - True if vorbis found.
|
||||
|
||||
if(NOT GP2XWIZ)
|
||||
if(VORBIS_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
set(VORBIS_FIND_QUIETLY TRUE)
|
||||
endif(VORBIS_INCLUDE_DIR)
|
||||
find_path(OGG_INCLUDE_DIR ogg/ogg.h)
|
||||
find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
|
||||
# MSVC built ogg/vorbis may be named ogg_static and vorbis_static
|
||||
find_library(OGG_LIBRARY NAMES ogg ogg_static)
|
||||
find_library(VORBIS_LIBRARY NAMES vorbis vorbis_static)
|
||||
find_library(VORBISFILE_LIBRARY NAMES vorbisfile vorbisfile_static)
|
||||
# Handle the QUIETLY and REQUIRED arguments and set VORBIS_FOUND
|
||||
# to TRUE if all listed variables are TRUE.
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(VORBIS DEFAULT_MSG
|
||||
OGG_INCLUDE_DIR VORBIS_INCLUDE_DIR
|
||||
OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY)
|
||||
else(NOT GP2XWIZ)
|
||||
find_path(VORBIS_INCLUDE_DIR tremor/ivorbisfile.h)
|
||||
find_library(VORBIS_LIBRARY NAMES vorbis_dec)
|
||||
find_package_handle_standard_args(VORBIS DEFAULT_MSG
|
||||
VORBIS_INCLUDE_DIR VORBIS_LIBRARY)
|
||||
endif(NOT GP2XWIZ)
|
||||
|
||||
if(VORBIS_FOUND)
|
||||
if(NOT GP2XWIZ)
|
||||
set(VORBIS_LIBRARIES ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY}
|
||||
${OGG_LIBRARY})
|
||||
else(NOT GP2XWIZ)
|
||||
set(VORBIS_LIBRARIES ${VORBIS_LIBRARY})
|
||||
endif(NOT GP2XWIZ)
|
||||
else(VORBIS_FOUND)
|
||||
set(VORBIS_LIBRARIES)
|
||||
endif(VORBIS_FOUND)
|
||||
|
||||
mark_as_advanced(OGG_INCLUDE_DIR VORBIS_INCLUDE_DIR)
|
||||
mark_as_advanced(OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY)
|
||||
|
||||
349
data/builtin.lua
@@ -1,349 +0,0 @@
|
||||
--
|
||||
-- This file contains built-in stuff in Minetest implemented in Lua.
|
||||
--
|
||||
-- It is always loaded and executed after registration of the C API,
|
||||
-- before loading and running any mods.
|
||||
--
|
||||
|
||||
function basic_dump2(o)
|
||||
if type(o) == "number" then
|
||||
return tostring(o)
|
||||
elseif type(o) == "string" then
|
||||
return string.format("%q", o)
|
||||
elseif type(o) == "boolean" then
|
||||
return tostring(o)
|
||||
elseif type(o) == "function" then
|
||||
return "<function>"
|
||||
elseif type(o) == "userdata" then
|
||||
return "<userdata>"
|
||||
elseif type(o) == "nil" then
|
||||
return "nil"
|
||||
else
|
||||
error("cannot dump a " .. type(o))
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
function dump2(o, name, dumped)
|
||||
name = name or "_"
|
||||
dumped = dumped or {}
|
||||
io.write(name, " = ")
|
||||
if type(o) == "number" or type(o) == "string" or type(o) == "boolean"
|
||||
or type(o) == "function" or type(o) == "nil"
|
||||
or type(o) == "userdata" then
|
||||
io.write(basic_dump2(o), "\n")
|
||||
elseif type(o) == "table" then
|
||||
if dumped[o] then
|
||||
io.write(dumped[o], "\n")
|
||||
else
|
||||
dumped[o] = name
|
||||
io.write("{}\n") -- new table
|
||||
for k,v in pairs(o) do
|
||||
local fieldname = string.format("%s[%s]", name, basic_dump2(k))
|
||||
dump2(v, fieldname, dumped)
|
||||
end
|
||||
end
|
||||
else
|
||||
error("cannot dump a " .. type(o))
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
function dump(o, dumped)
|
||||
dumped = dumped or {}
|
||||
if type(o) == "number" then
|
||||
return tostring(o)
|
||||
elseif type(o) == "string" then
|
||||
return string.format("%q", o)
|
||||
elseif type(o) == "table" then
|
||||
if dumped[o] then
|
||||
return "<circular reference>"
|
||||
end
|
||||
dumped[o] = true
|
||||
local t = {}
|
||||
for k,v in pairs(o) do
|
||||
t[#t+1] = "" .. k .. " = " .. dump(v, dumped)
|
||||
end
|
||||
return "{" .. table.concat(t, ", ") .. "}"
|
||||
elseif type(o) == "boolean" then
|
||||
return tostring(o)
|
||||
elseif type(o) == "function" then
|
||||
return "<function>"
|
||||
elseif type(o) == "userdata" then
|
||||
return "<userdata>"
|
||||
elseif type(o) == "nil" then
|
||||
return "nil"
|
||||
else
|
||||
error("cannot dump a " .. type(o))
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- Built-in node definitions. Also defined in C.
|
||||
--
|
||||
|
||||
minetest.register_nodedef_defaults({
|
||||
-- name intentionally not defined here
|
||||
drawtype = "normal",
|
||||
visual_scale = 1.0,
|
||||
tile_images = {"unknown_block.png"},
|
||||
inventory_image = "unknown_block.png",
|
||||
special_materials = {
|
||||
{image="", backface_culling=true},
|
||||
{image="", backface_culling=true},
|
||||
},
|
||||
alpha = 255,
|
||||
post_effect_color = {a=0, r=0, g=0, b=0},
|
||||
paramtype = "none",
|
||||
is_ground_content = false,
|
||||
light_propagates = false,
|
||||
sunlight_propagates = false,
|
||||
walkable = true,
|
||||
pointable = true,
|
||||
diggable = true,
|
||||
climbable = false,
|
||||
buildable_to = false,
|
||||
wall_mounted = false,
|
||||
often_contains_mineral = false,
|
||||
dug_item = "",
|
||||
extra_dug_item = "",
|
||||
extra_dug_item_rarity = 2,
|
||||
metadata_name = "",
|
||||
liquidtype = "none",
|
||||
liquid_alternative_flowing = "",
|
||||
liquid_alternative_source = "",
|
||||
liquid_viscosity = 0,
|
||||
light_source = 0,
|
||||
damage_per_second = 0,
|
||||
selection_box = {type="regular"},
|
||||
material = {
|
||||
diggablity = "normal",
|
||||
weight = 0,
|
||||
crackiness = 0,
|
||||
crumbliness = 0,
|
||||
cuttability = 0,
|
||||
flammability = 0,
|
||||
},
|
||||
cookresult_item = "", -- Cannot be cooked
|
||||
furnace_cooktime = 3.0,
|
||||
furnace_burntime = -1, -- Cannot be used as fuel
|
||||
})
|
||||
|
||||
minetest.register_node("air", {
|
||||
drawtype = "airlike",
|
||||
paramtype = "light",
|
||||
light_propagates = true,
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
air_equivalent = true,
|
||||
})
|
||||
|
||||
minetest.register_node("ignore", {
|
||||
drawtype = "airlike",
|
||||
paramtype = "none",
|
||||
light_propagates = false,
|
||||
sunlight_propagates = false,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true, -- A way to remove accidentally placed ignores
|
||||
air_equivalent = true,
|
||||
})
|
||||
|
||||
--
|
||||
-- stackstring manipulation functions
|
||||
-- example stackstring: 'CraftItem "apple" 4'
|
||||
-- example item: {type="CraftItem", name="apple"}
|
||||
-- example item: {type="ToolItem", name="SteelPick", wear="23272"}
|
||||
--
|
||||
|
||||
function stackstring_take_item(stackstring)
|
||||
if stackstring == nil then
|
||||
return '', nil
|
||||
end
|
||||
local stacktype = nil
|
||||
stacktype = string.match(stackstring,
|
||||
'([%a%d]+Item[%a%d]*)')
|
||||
if stacktype == "NodeItem" or stacktype == "CraftItem" then
|
||||
local itemtype = nil
|
||||
local itemname = nil
|
||||
local itemcount = nil
|
||||
itemtype, itemname, itemcount = string.match(stackstring,
|
||||
'([%a%d]+Item[%a%d]*) "([^"]*)" (%d+)')
|
||||
itemcount = tonumber(itemcount)
|
||||
if itemcount == 0 then
|
||||
return '', nil
|
||||
elseif itemcount == 1 then
|
||||
return '', {type=itemtype, name=itemname}
|
||||
else
|
||||
return itemtype.." \""..itemname.."\" "..(itemcount-1),
|
||||
{type=itemtype, name=itemname}
|
||||
end
|
||||
elseif stacktype == "ToolItem" then
|
||||
local itemtype = nil
|
||||
local itemname = nil
|
||||
local itemwear = nil
|
||||
itemtype, itemname, itemwear = string.match(stackstring,
|
||||
'([%a%d]+Item[%a%d]*) "([^"]*)" (%d+)')
|
||||
itemwear = tonumber(itemwear)
|
||||
return '', {type=itemtype, name=itemname, wear=itemwear}
|
||||
end
|
||||
end
|
||||
|
||||
function stackstring_put_item(stackstring, item)
|
||||
if item == nil then
|
||||
return stackstring, false
|
||||
end
|
||||
stackstring = stackstring or ''
|
||||
local stacktype = nil
|
||||
stacktype = string.match(stackstring,
|
||||
'([%a%d]+Item[%a%d]*)')
|
||||
stacktype = stacktype or ''
|
||||
if stacktype ~= '' and stacktype ~= item.type then
|
||||
return stackstring, false
|
||||
end
|
||||
if item.type == "NodeItem" or item.type == "CraftItem" then
|
||||
local itemtype = nil
|
||||
local itemname = nil
|
||||
local itemcount = nil
|
||||
itemtype, itemname, itemcount = string.match(stackstring,
|
||||
'([%a%d]+Item[%a%d]*) "([^"]*)" (%d+)')
|
||||
itemtype = itemtype or item.type
|
||||
itemname = itemname or item.name
|
||||
if itemcount == nil then
|
||||
itemcount = 0
|
||||
end
|
||||
itemcount = itemcount + 1
|
||||
return itemtype.." \""..itemname.."\" "..itemcount, true
|
||||
elseif item.type == "ToolItem" then
|
||||
if stacktype ~= nil then
|
||||
return stackstring, false
|
||||
end
|
||||
local itemtype = nil
|
||||
local itemname = nil
|
||||
local itemwear = nil
|
||||
itemtype, itemname, itemwear = string.match(stackstring,
|
||||
'([%a%d]+Item[%a%d]*) "([^"]*)" (%d+)')
|
||||
itemwear = tonumber(itemwear)
|
||||
return itemtype.." \""..itemname.."\" "..itemwear, true
|
||||
end
|
||||
return stackstring, false
|
||||
end
|
||||
|
||||
function stackstring_put_stackstring(stackstring, src)
|
||||
while src ~= '' do
|
||||
--print("src="..dump(src))
|
||||
src, item = stackstring_take_item(src)
|
||||
--print("src="..dump(src).." item="..dump(item))
|
||||
local success
|
||||
stackstring, success = stackstring_put_item(stackstring, item)
|
||||
if not success then
|
||||
return stackstring, false
|
||||
end
|
||||
end
|
||||
return stackstring, true
|
||||
end
|
||||
|
||||
function test_stackstring()
|
||||
local stack
|
||||
local item
|
||||
local success
|
||||
|
||||
stack, item = stackstring_take_item('NodeItem "TNT" 3')
|
||||
assert(stack == 'NodeItem "TNT" 2')
|
||||
assert(item.type == 'NodeItem')
|
||||
assert(item.name == 'TNT')
|
||||
|
||||
stack, item = stackstring_take_item('CraftItem "with spaces" 2')
|
||||
assert(stack == 'CraftItem "with spaces" 1')
|
||||
assert(item.type == 'CraftItem')
|
||||
assert(item.name == 'with spaces')
|
||||
|
||||
stack, item = stackstring_take_item('CraftItem "with spaces" 1')
|
||||
assert(stack == '')
|
||||
assert(item.type == 'CraftItem')
|
||||
assert(item.name == 'with spaces')
|
||||
|
||||
stack, item = stackstring_take_item('CraftItem "s8df2kj3" 0')
|
||||
assert(stack == '')
|
||||
assert(item == nil)
|
||||
|
||||
stack, item = stackstring_take_item('ToolItem "With Spaces" 32487')
|
||||
assert(stack == '')
|
||||
assert(item.type == 'ToolItem')
|
||||
assert(item.name == 'With Spaces')
|
||||
assert(item.wear == 32487)
|
||||
|
||||
stack, success = stackstring_put_item('NodeItem "With Spaces" 40',
|
||||
{type='NodeItem', name='With Spaces'})
|
||||
assert(stack == 'NodeItem "With Spaces" 41')
|
||||
assert(success == true)
|
||||
|
||||
stack, success = stackstring_put_item('CraftItem "With Spaces" 40',
|
||||
{type='CraftItem', name='With Spaces'})
|
||||
assert(stack == 'CraftItem "With Spaces" 41')
|
||||
assert(success == true)
|
||||
|
||||
stack, success = stackstring_put_item('ToolItem "With Spaces" 32487',
|
||||
{type='ToolItem', name='With Spaces'})
|
||||
assert(stack == 'ToolItem "With Spaces" 32487')
|
||||
assert(success == false)
|
||||
|
||||
stack, success = stackstring_put_item('NodeItem "With Spaces" 40',
|
||||
{type='ToolItem', name='With Spaces'})
|
||||
assert(stack == 'NodeItem "With Spaces" 40')
|
||||
assert(success == false)
|
||||
|
||||
assert(stackstring_put_stackstring('NodeItem "With Spaces" 2',
|
||||
'NodeItem "With Spaces" 1') == 'NodeItem "With Spaces" 3')
|
||||
end
|
||||
test_stackstring()
|
||||
|
||||
--
|
||||
-- craftitem helpers
|
||||
--
|
||||
|
||||
minetest.craftitem_place_item = function(item, placer, pos)
|
||||
--print("craftitem_place_item")
|
||||
--print("item: " .. dump(item))
|
||||
--print("placer: " .. dump(placer))
|
||||
--print("pos: " .. dump(pos))
|
||||
minetest.env:add_item(pos, 'CraftItem "' .. item .. '" 1')
|
||||
return true
|
||||
end
|
||||
|
||||
minetest.craftitem_eat = function(hp_change)
|
||||
return function(item, user, pointed_thing) -- closure
|
||||
--print("craftitem_eat(" .. hp_change .. ")")
|
||||
--print("item: " .. dump(item))
|
||||
--print("user: " .. dump(user))
|
||||
--print("pointed_thing: " .. dump(pointed_thing))
|
||||
user:set_hp(user:get_hp() + hp_change)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- Callback registration
|
||||
--
|
||||
|
||||
function make_registration()
|
||||
local t = {}
|
||||
local registerfunc = function(func) table.insert(t, func) end
|
||||
return t, registerfunc
|
||||
end
|
||||
|
||||
minetest.registered_on_chat_messages, minetest.register_on_chat_message = make_registration()
|
||||
minetest.registered_globalsteps, minetest.register_globalstep = make_registration()
|
||||
minetest.registered_on_placenodes, minetest.register_on_placenode = make_registration()
|
||||
minetest.registered_on_dignodes, minetest.register_on_dignode = make_registration()
|
||||
minetest.registered_on_punchnodes, minetest.register_on_punchnode = make_registration()
|
||||
minetest.registered_on_generateds, minetest.register_on_generated = make_registration()
|
||||
minetest.registered_on_newplayers, minetest.register_on_newplayer = make_registration()
|
||||
minetest.registered_on_respawnplayers, minetest.register_on_respawnplayer = make_registration()
|
||||
|
||||
-- END
|
||||
@@ -1,73 +0,0 @@
|
||||
minetest.register_craft({
|
||||
output = 'CraftItem "bucket" 1',
|
||||
recipe = {
|
||||
{'CraftItem "steel_ingot"', '', 'CraftItem "steel_ingot"'},
|
||||
{'', 'CraftItem "steel_ingot"', ''},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("bucket", {
|
||||
image = "bucket.png",
|
||||
stack_max = 1,
|
||||
liquids_pointable = true,
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
on_use = function(item, player, pointed_thing)
|
||||
if pointed_thing.type == "node" then
|
||||
n = minetest.env:get_node(pointed_thing.under)
|
||||
if n.name == "water_source" then
|
||||
minetest.env:add_node(pointed_thing.under, {name="air"})
|
||||
player:add_to_inventory_later('CraftItem "bucket_water" 1')
|
||||
return true
|
||||
elseif n.name == "lava_source" then
|
||||
minetest.env:add_node(pointed_thing.under, {name="air"})
|
||||
player:add_to_inventory_later('CraftItem "bucket_lava" 1')
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("bucket_water", {
|
||||
image = "bucket_water.png",
|
||||
stack_max = 1,
|
||||
liquids_pointable = true,
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
on_use = function(item, player, pointed_thing)
|
||||
if pointed_thing.type == "node" then
|
||||
n = minetest.env:get_node(pointed_thing.under)
|
||||
if n.name == "water_source" then
|
||||
-- unchanged
|
||||
elseif n.name == "water_flowing" or n.name == "lava_source" or n.name == "lava_flowing" then
|
||||
minetest.env:add_node(pointed_thing.under, {name="water_source"})
|
||||
else
|
||||
minetest.env:add_node(pointed_thing.above, {name="water_source"})
|
||||
end
|
||||
player:add_to_inventory_later('CraftItem "bucket" 1')
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("bucket_lava", {
|
||||
image = "bucket_lava.png",
|
||||
stack_max = 1,
|
||||
liquids_pointable = true,
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
on_use = function(item, player, pointed_thing)
|
||||
if pointed_thing.type == "node" then
|
||||
n = minetest.env:get_node(pointed_thing.under)
|
||||
if n.name == "lava_source" then
|
||||
-- unchanged
|
||||
elseif n.name == "water_source" or n.name == "water_flowing" or n.name == "lava_flowing" then
|
||||
minetest.env:add_node(pointed_thing.under, {name="lava_source"})
|
||||
else
|
||||
minetest.env:add_node(pointed_thing.above, {name="lava_source"})
|
||||
end
|
||||
player:add_to_inventory_later('CraftItem "bucket" 1')
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end,
|
||||
})
|
||||
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 236 B |
|
Before Width: | Height: | Size: 598 B |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 231 B |
|
Before Width: | Height: | Size: 199 B |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 190 B |
|
Before Width: | Height: | Size: 190 B |
|
Before Width: | Height: | Size: 190 B |
@@ -1,398 +0,0 @@
|
||||
--
|
||||
-- Experimental things
|
||||
--
|
||||
|
||||
-- An example furnace-thing implemented in Lua
|
||||
|
||||
minetest.register_node("luafurnace", {
|
||||
tile_images = {"lava.png", "furnace_side.png", "furnace_side.png",
|
||||
"furnace_side.png", "furnace_side.png", "furnace_front.png"},
|
||||
--inventory_image = "furnace_front.png",
|
||||
inventory_image = inventorycube("furnace_front.png"),
|
||||
paramtype = "facedir_simple",
|
||||
metadata_name = "generic",
|
||||
material = digprop_stonelike(3.0),
|
||||
})
|
||||
|
||||
minetest.register_on_placenode(function(pos, newnode, placer)
|
||||
if newnode.name == "luafurnace" then
|
||||
print("get_meta");
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
print("inventory_set_list");
|
||||
meta:inventory_set_list("fuel", {""})
|
||||
print("inventory_set_list");
|
||||
meta:inventory_set_list("src", {""})
|
||||
print("inventory_set_list");
|
||||
meta:inventory_set_list("dst", {"","","",""})
|
||||
print("set_inventory_draw_spec");
|
||||
meta:set_inventory_draw_spec(
|
||||
"invsize[8,9;]"
|
||||
.."list[current_name;fuel;2,3;1,1;]"
|
||||
.."list[current_name;src;2,1;1,1;]"
|
||||
.."list[current_name;dst;5,1;2,2;]"
|
||||
.."list[current_player;main;0,5;8,4;]"
|
||||
)
|
||||
|
||||
local total_cooked = 0;
|
||||
print("set_string")
|
||||
meta:set_string("total_cooked", total_cooked)
|
||||
print("set_infotext");
|
||||
meta:set_infotext("Lua Furnace: total cooked: "..total_cooked)
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"luafurnace"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local fuellist = meta:inventory_get_list("fuel")
|
||||
local srclist = meta:inventory_get_list("src")
|
||||
local dstlist = meta:inventory_get_list("dst")
|
||||
if fuellist == nil or srclist == nil or dstlist == nil then
|
||||
return
|
||||
end
|
||||
_, srcitem = stackstring_take_item(srclist[1])
|
||||
_, fuelitem = stackstring_take_item(fuellist[1])
|
||||
if not srcitem or not fuelitem then return end
|
||||
if fuelitem.type == "NodeItem" then
|
||||
local prop = minetest.registered_nodes[fuelitem.name]
|
||||
if prop == nil then return end
|
||||
if prop.furnace_burntime < 0 then return end
|
||||
else
|
||||
return
|
||||
end
|
||||
local resultstack = nil
|
||||
if srcitem.type == "NodeItem" then
|
||||
local prop = minetest.registered_nodes[srcitem.name]
|
||||
if prop == nil then return end
|
||||
if prop.cookresult_item == "" then return end
|
||||
resultstack = prop.cookresult_item
|
||||
else
|
||||
return
|
||||
end
|
||||
|
||||
if resultstack == nil then
|
||||
return
|
||||
end
|
||||
|
||||
dstlist[1], success = stackstring_put_stackstring(dstlist[1], resultstack)
|
||||
if not success then
|
||||
return
|
||||
end
|
||||
|
||||
fuellist[1], _ = stackstring_take_item(fuellist[1])
|
||||
srclist[1], _ = stackstring_take_item(srclist[1])
|
||||
|
||||
meta:inventory_set_list("fuel", fuellist)
|
||||
meta:inventory_set_list("src", srclist)
|
||||
meta:inventory_set_list("dst", dstlist)
|
||||
|
||||
local total_cooked = meta:get_string("total_cooked")
|
||||
total_cooked = tonumber(total_cooked) + 1
|
||||
meta:set_string("total_cooked", total_cooked)
|
||||
meta:set_infotext("Lua Furnace: total cooked: "..total_cooked)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'NodeItem "luafurnace" 1',
|
||||
recipe = {
|
||||
{'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'},
|
||||
{'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'},
|
||||
{'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'},
|
||||
}
|
||||
})
|
||||
|
||||
--
|
||||
-- Random stuff
|
||||
--
|
||||
|
||||
--[[
|
||||
minetest.register_tool("horribletool", {
|
||||
image = "lava.png",
|
||||
basetime = 2.0
|
||||
dt_weight = 0.2
|
||||
dt_crackiness = 0.2
|
||||
dt_crumbliness = 0.2
|
||||
dt_cuttability = 0.2
|
||||
basedurability = 50
|
||||
dd_weight = -5
|
||||
dd_crackiness = -5
|
||||
dd_crumbliness = -5
|
||||
dd_cuttability = -5
|
||||
})
|
||||
--]]
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'NodeItem "somenode" 4',
|
||||
recipe = {
|
||||
{'CraftItem "Stick" 1'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("somenode", {
|
||||
tile_images = {"lava.png", "mese.png", "stone.png", "grass.png", "cobble.png", "tree_top.png"},
|
||||
inventory_image = "treeprop.png",
|
||||
material = {
|
||||
diggability = "normal",
|
||||
weight = 0,
|
||||
crackiness = 0,
|
||||
crumbliness = 0,
|
||||
cuttability = 0,
|
||||
flammability = 0
|
||||
},
|
||||
metadata_name = "chest",
|
||||
})
|
||||
|
||||
--
|
||||
-- TNT (not functional)
|
||||
--
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'NodeItem "TNT" 4',
|
||||
recipe = {
|
||||
{'NodeItem "wood" 1'},
|
||||
{'CraftItem "lump_of_coal" 1'},
|
||||
{'NodeItem "wood" 1'}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("TNT", {
|
||||
tile_images = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png", "tnt_side.png", "tnt_side.png", "tnt_side.png"},
|
||||
inventory_image = "tnt_side.png",
|
||||
dug_item = '', -- Get nothing
|
||||
material = {
|
||||
diggability = "not",
|
||||
},
|
||||
})
|
||||
|
||||
local TNT = {
|
||||
-- Static definition
|
||||
physical = true, -- Collides with things
|
||||
-- weight = 5,
|
||||
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
||||
visual = "cube",
|
||||
textures = {"tnt_top.png","tnt_bottom.png","tnt_side.png","tnt_side.png","tnt_side.png","tnt_side.png"},
|
||||
-- Initial value for our timer
|
||||
timer = 0,
|
||||
-- Number of punches required to defuse
|
||||
health = 1,
|
||||
blinktimer = 0,
|
||||
blinkstatus = true,
|
||||
}
|
||||
|
||||
-- Called when a TNT object is created
|
||||
function TNT:on_activate(staticdata)
|
||||
print("TNT:on_activate()")
|
||||
self.object:setvelocity({x=0, y=4, z=0})
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
self.object:settexturemod("^[brighten")
|
||||
end
|
||||
|
||||
-- Called periodically
|
||||
function TNT:on_step(dtime)
|
||||
--print("TNT:on_step()")
|
||||
self.timer = self.timer + dtime
|
||||
self.blinktimer = self.blinktimer + dtime
|
||||
if self.blinktimer > 0.5 then
|
||||
self.blinktimer = self.blinktimer - 0.5
|
||||
if self.blinkstatus then
|
||||
self.object:settexturemod("")
|
||||
else
|
||||
self.object:settexturemod("^[brighten")
|
||||
end
|
||||
self.blinkstatus = not self.blinkstatus
|
||||
end
|
||||
end
|
||||
|
||||
-- Called when object is punched
|
||||
function TNT:on_punch(hitter)
|
||||
print("TNT:on_punch()")
|
||||
self.health = self.health - 1
|
||||
if self.health <= 0 then
|
||||
self.object:remove()
|
||||
hitter:add_to_inventory("NodeItem TNT 1")
|
||||
hitter:set_hp(hitter:get_hp() - 1)
|
||||
end
|
||||
end
|
||||
|
||||
-- Called when object is right-clicked
|
||||
function TNT:on_rightclick(clicker)
|
||||
--pos = self.object:getpos()
|
||||
--pos = {x=pos.x, y=pos.y+0.1, z=pos.z}
|
||||
--self.object:moveto(pos, false)
|
||||
end
|
||||
|
||||
print("TNT dump: "..dump(TNT))
|
||||
|
||||
print("Registering TNT");
|
||||
minetest.register_entity("TNT", TNT)
|
||||
|
||||
--
|
||||
-- A test entity for testing animated and yaw-modulated sprites
|
||||
--
|
||||
|
||||
minetest.register_entity("testentity", {
|
||||
-- Static definition
|
||||
physical = true, -- Collides with things
|
||||
-- weight = 5,
|
||||
collisionbox = {-0.7,-1.35,-0.7, 0.7,1.0,0.7},
|
||||
--collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
||||
visual = "sprite",
|
||||
visual_size = {x=2, y=3},
|
||||
textures = {"dungeon_master.png^[makealpha:128,0,0^[makealpha:128,128,0"},
|
||||
spritediv = {x=6, y=5},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
|
||||
on_activate = function(self, staticdata)
|
||||
print("testentity.on_activate")
|
||||
self.object:setsprite({x=0,y=0}, 1, 0, true)
|
||||
--self.object:setsprite({x=0,y=0}, 4, 0.3, true)
|
||||
|
||||
-- Set gravity
|
||||
self.object:setacceleration({x=0, y=-10, z=0})
|
||||
-- Jump a bit upwards
|
||||
self.object:setvelocity({x=0, y=10, z=0})
|
||||
end,
|
||||
|
||||
on_punch = function(self, hitter)
|
||||
self.object:remove()
|
||||
hitter:add_to_inventory('CraftItem testobject1 1')
|
||||
end,
|
||||
})
|
||||
|
||||
--
|
||||
-- More random stuff
|
||||
--
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
print("on_respawnplayer")
|
||||
-- player:setpos({x=0, y=30, z=0})
|
||||
-- return true
|
||||
end)
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp)
|
||||
--print("on_generated: minp="..dump(minp).." maxp="..dump(maxp))
|
||||
--cp = {x=(minp.x+maxp.x)/2, y=(minp.y+maxp.y)/2, z=(minp.z+maxp.z)/2}
|
||||
--minetest.env:add_node(cp, {name="sand"})
|
||||
end)
|
||||
|
||||
-- Example setting get
|
||||
print("setting max_users = " .. dump(minetest.setting_get("max_users")))
|
||||
print("setting asdf = " .. dump(minetest.setting_get("asdf")))
|
||||
|
||||
minetest.register_on_chat_message(function(name, message)
|
||||
--[[print("on_chat_message: name="..dump(name).." message="..dump(message))
|
||||
local cmd = "/testcommand"
|
||||
if message:sub(0, #cmd) == cmd then
|
||||
print(cmd.." invoked")
|
||||
return true
|
||||
end
|
||||
local cmd = "/help"
|
||||
if message:sub(0, #cmd) == cmd then
|
||||
print("script-overridden help command")
|
||||
minetest.chat_send_all("script-overridden help command")
|
||||
return true
|
||||
end]]
|
||||
end)
|
||||
|
||||
-- Grow papyrus on TNT every 10 seconds
|
||||
--[[minetest.register_abm({
|
||||
nodenames = {"TNT"},
|
||||
interval = 10.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
print("TNT ABM action")
|
||||
pos.y = pos.y + 1
|
||||
minetest.env:add_node(pos, {name="papyrus"})
|
||||
end,
|
||||
})]]
|
||||
|
||||
-- Replace texts of alls signs with "foo" every 10 seconds
|
||||
--[[minetest.register_abm({
|
||||
nodenames = {"sign_wall"},
|
||||
interval = 10.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
print("ABM: Sign text changed")
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_text("foo")
|
||||
end,
|
||||
})]]
|
||||
|
||||
--[[local ncpos = nil
|
||||
local ncq = 1
|
||||
local ncstuff = {
|
||||
{2, 1, 0, 3}, {3, 0, 1, 2}, {4, -1, 0, 1}, {5, -1, 0, 1}, {6, 0, -1, 0},
|
||||
{7, 0, -1, 0}, {8, 1, 0, 3}, {9, 1, 0, 3}, {10, 1, 0, 3}, {11, 0, 1, 2},
|
||||
{12, 0, 1, 2}, {13, 0, 1, 2}, {14, -1, 0, 1}, {15, -1, 0, 1}, {16, -1, 0, 1},
|
||||
{17, -1, 0, 1}, {18, 0, -1, 0}, {19, 0, -1, 0}, {20, 0, -1, 0}, {21, 0, -1, 0},
|
||||
{22, 1, 0, 3}, {23, 1, 0, 3}, {24, 1, 0, 3}, {25, 1, 0, 3}, {10, 0, 1, 2}
|
||||
}
|
||||
local ncold = {}
|
||||
local nctime = nil
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"dirt_with_grass"},
|
||||
interval = 100000.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if ncpos ~= nil then
|
||||
return
|
||||
end
|
||||
|
||||
if pos.x % 16 ~= 8 or pos.z % 16 ~= 8 then
|
||||
return
|
||||
end
|
||||
|
||||
pos.y = pos.y + 1
|
||||
n = minetest.env:get_node(pos)
|
||||
print(dump(n))
|
||||
if n.name ~= "air" then
|
||||
return
|
||||
end
|
||||
|
||||
pos.y = pos.y + 2
|
||||
ncpos = pos
|
||||
nctime = os.clock()
|
||||
minetest.env:add_node(ncpos, {name="nyancat"})
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"nyancat"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if ncpos == nil then
|
||||
return
|
||||
end
|
||||
if pos.x == ncpos.x and pos.y == ncpos.y and pos.z == ncpos.z then
|
||||
clock = os.clock()
|
||||
if clock - nctime < 0.1 then
|
||||
return
|
||||
end
|
||||
nctime = clock
|
||||
|
||||
s0 = ncstuff[ncq]
|
||||
ncq = s0[1]
|
||||
s1 = ncstuff[ncq]
|
||||
p0 = pos
|
||||
p1 = {x = p0.x + s0[2], y = p0.y, z = p0.z + s0[3]}
|
||||
p2 = {x = p1.x + s1[2], y = p1.y, z = p1.z + s1[3]}
|
||||
table.insert(ncold, 1, p0)
|
||||
while #ncold >= 10 do
|
||||
minetest.env:add_node(ncold[#ncold], {name="air"})
|
||||
table.remove(ncold, #ncold)
|
||||
end
|
||||
minetest.env:add_node(p0, {name="nyancat_rainbow"})
|
||||
minetest.env:add_node(p1, {name="nyancat", param1=s0[4]})
|
||||
minetest.env:add_node(p2, {name="air"})
|
||||
ncpos = p1
|
||||
end
|
||||
end,
|
||||
})--]]
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
minetest.register_on_newplayer(function(player)
|
||||
print("on_newplayer")
|
||||
if minetest.setting_getbool("give_initial_stuff") then
|
||||
print("giving give_initial_stuff to player")
|
||||
player:add_to_inventory('ToolItem "SteelPick" 0')
|
||||
player:add_to_inventory('NodeItem "torch" 99')
|
||||
player:add_to_inventory('ToolItem "SteelAxe" 0')
|
||||
player:add_to_inventory('ToolItem "SteelShovel" 0')
|
||||
player:add_to_inventory('NodeItem "cobble" 99')
|
||||
end
|
||||
end)
|
||||
|
||||
798
doc/lua_api.txt
Normal file
@@ -0,0 +1,798 @@
|
||||
Minetest Lua Modding API Reference 0.4.dev
|
||||
==========================================
|
||||
More information at http://c55.me/minetest/
|
||||
|
||||
Introduction
|
||||
-------------
|
||||
Content and functionality can be added to Minetest 0.4 by using Lua
|
||||
scripting in run-time loaded mods.
|
||||
|
||||
A mod is a self-contained bunch of scripts, textures and other related
|
||||
things that is loaded by and interfaces with Minetest.
|
||||
|
||||
Mods are contained and ran solely on the server side. Definitions and media
|
||||
files are automatically transferred to the client.
|
||||
|
||||
If you see a deficiency in the API, feel free to attempt to add the
|
||||
functionality in the engine and API. You can send such improvements as
|
||||
source code patches to <celeron55@gmail.com>.
|
||||
|
||||
Programming in Lua
|
||||
-------------------
|
||||
If you have any difficulty in understanding this, please read:
|
||||
http://www.lua.org/pil/
|
||||
|
||||
Startup
|
||||
--------
|
||||
Mods are loaded during server startup from the mod load paths by running
|
||||
the init.lua scripts.
|
||||
|
||||
Mod load path
|
||||
-------------
|
||||
Generic:
|
||||
$path_share/games/gameid/mods/
|
||||
$path_share/mods/gameid/
|
||||
$path_user/games/gameid/mods/
|
||||
$path_user/mods/gameid/ <-- User-installed mods
|
||||
$worldpath/worldmods/
|
||||
|
||||
In a run-in-place version (eg. the distributed windows version):
|
||||
minetest-0.4.x/games/gameid/mods/
|
||||
minetest-0.4.x/mods/gameid/ <-- User-installed mods
|
||||
minetest-0.4.x/worlds/worldname/worldmods/
|
||||
|
||||
On an installed version on linux:
|
||||
/usr/share/minetest/games/gameid/mods/
|
||||
~/.minetest/mods/gameid/ <-- User-installed mods
|
||||
~/.minetest/worlds/worldname/worldmods
|
||||
|
||||
Mod directory structure
|
||||
------------------------
|
||||
mods
|
||||
|-- modname
|
||||
| |-- depends.txt
|
||||
| |-- init.lua
|
||||
| |-- textures
|
||||
| | |-- modname_stuff.png
|
||||
| | `-- modname_something_else.png
|
||||
| |-- sounds
|
||||
| |-- media
|
||||
| `-- <custom data>
|
||||
`-- another
|
||||
|
||||
modname:
|
||||
The location of this directory can be fetched by using
|
||||
minetest.get_modpath(modname)
|
||||
|
||||
depends.txt:
|
||||
List of mods that have to be loaded before loading this mod.
|
||||
A single line contains a single modname.
|
||||
|
||||
init.lua:
|
||||
The main Lua script. Running this script should register everything it
|
||||
wants to register. Subsequent execution depends on minetest calling the
|
||||
registered callbacks.
|
||||
|
||||
minetest.setting_get(name) and minetest.setting_getbool(name) can be used
|
||||
to read custom or existing settings at load time, if necessary.
|
||||
|
||||
textures, sounds, media:
|
||||
Media files (textures, sounds, whatever) that will be transferred to the
|
||||
client and will be available for use by the mod.
|
||||
|
||||
Naming convention for registered textual names
|
||||
----------------------------------------------
|
||||
Registered names should generally be in this format:
|
||||
"modname:<whatever>" (<whatever> can have characters a-zA-Z0-9_)
|
||||
|
||||
This is to prevent conflicting names from corrupting maps and is
|
||||
enforced by the mod loader.
|
||||
|
||||
Example: mod "experimental", ideal item/node/entity name "tnt":
|
||||
-> the name should be "experimental:tnt".
|
||||
|
||||
Enforcement can be overridden by prefixing the name with ":". This can
|
||||
be used for overriding the registrations of some other mod.
|
||||
|
||||
Example: Any mod can redefine experimental:tnt by using the name
|
||||
":experimental:tnt" when registering it.
|
||||
(also that mod is required to have "experimental" as a dependency)
|
||||
|
||||
The ":" prefix can also be used for maintaining backwards compatibility.
|
||||
|
||||
Aliases
|
||||
-------
|
||||
Aliases can be added by using minetest.register_alias(name, convert_to)
|
||||
|
||||
This will make Minetest to convert things called name to things called
|
||||
convert_to.
|
||||
|
||||
This can be used for maintaining backwards compatibility.
|
||||
|
||||
This can be also used for setting quick access names for things, eg. if
|
||||
you have an item called epiclylongmodname:stuff, you could do
|
||||
minetest.register_alias("stuff", "epiclylongmodname:stuff")
|
||||
and be able to use "/giveme stuff".
|
||||
|
||||
Textures
|
||||
--------
|
||||
Mods should generally prefix their textures with modname_, eg. given
|
||||
the mod name "foomod", a texture could be called
|
||||
"foomod_foothing.png"
|
||||
|
||||
Textures are referred to by their complete name, or alternatively by
|
||||
stripping out the file extension:
|
||||
eg. foomod_foothing.png
|
||||
eg. foomod_foothing
|
||||
|
||||
Sounds
|
||||
-------
|
||||
Only OGG files are supported.
|
||||
|
||||
For positional playing of sounds, only single-channel (mono) files are
|
||||
supported. Otherwise OpenAL will play them non-positionally.
|
||||
|
||||
Mods should generally prefix their sounds with modname_, eg. given
|
||||
the mod name "foomod", a sound could be called
|
||||
"foomod_foosound.ogg"
|
||||
|
||||
Sounds are referred to by their name with a dot, a single digit and the
|
||||
file extension stripped out. When a sound is played, the actual sound file
|
||||
is chosen randomly from the matching sounds.
|
||||
|
||||
When playing the sound "foomod_foosound", the sound is chosen randomly
|
||||
from the available ones of the following files:
|
||||
foomod_foosound.ogg
|
||||
foomod_foosound.0.ogg
|
||||
foomod_foosound.1.ogg
|
||||
...
|
||||
foomod_foosound.9.ogg
|
||||
|
||||
Examples of sound parameter tables:
|
||||
-- Play locationless on all clients
|
||||
{
|
||||
gain = 1.0, -- default
|
||||
}
|
||||
-- Play locationless to a player
|
||||
{
|
||||
to_player = name,
|
||||
gain = 1.0, -- default
|
||||
}
|
||||
-- Play in a location
|
||||
{
|
||||
pos = {x=1,y=2,z=3},
|
||||
gain = 1.0, -- default
|
||||
max_hear_distance = 32, -- default
|
||||
}
|
||||
-- Play connected to an object, looped
|
||||
{
|
||||
object = <an ObjectRef>,
|
||||
gain = 1.0, -- default
|
||||
max_hear_distance = 32, -- default
|
||||
loop = true, -- only sounds connected to objects can be looped
|
||||
}
|
||||
|
||||
Representations of simple things
|
||||
--------------------------------
|
||||
MapNode representation:
|
||||
{name="name", param1=num, param2=num}
|
||||
|
||||
MapNodes do not directly have any other data associated with them.
|
||||
If you want to access the definition of the node, you access
|
||||
minetest.registered_nodes[node.name]
|
||||
|
||||
param1 and param2 are 8 bit and 4 bit integers, respectively. They
|
||||
are reserved for certain automated functions. If you don't use these
|
||||
functions, you can use them to store arbitrary values.
|
||||
|
||||
param1 is reserved for the engine when:
|
||||
paramtype != "none"
|
||||
param2 is reserved for the engine when any of these are used:
|
||||
liquidtype == "flowing"
|
||||
drawtype == "flowingliquid"
|
||||
drawtype == "torchlike"
|
||||
drawtype == "signlike"
|
||||
|
||||
Position/vector:
|
||||
{x=num, y=num, z=num}
|
||||
Currently the API does not provide any helper functions for addition,
|
||||
subtraction and whatever; you can define those that you need yourself.
|
||||
|
||||
stackstring/itemstring: A stack of items in serialized format.
|
||||
eg. 'default:dirt 5'
|
||||
eg. 'default:pick_wood 21323'
|
||||
eg. 'default:apple'
|
||||
|
||||
item: A stack of items in Lua table format.
|
||||
eg. {name="default:dirt", count=5, wear=0, metadata=""}
|
||||
^ 5 dirt nodes
|
||||
eg. {name="default:pick_wood", count=1, wear=21323, metadata=""}
|
||||
^ a wooden pick about 1/3 weared out
|
||||
eg. {name="default:apple", count=1, wear=0, metadata=""}
|
||||
^ an apple.
|
||||
|
||||
Any time an item must be passed to a function, it can be an
|
||||
ItemStack (see below), an itemstring or a table in the above format.
|
||||
|
||||
SimpleSoundSpec:
|
||||
eg. ""
|
||||
eg. "default_place_node"
|
||||
eg. {}
|
||||
eg. {name="default_place_node"}
|
||||
eg. {name="default_place_node", gain=1.0}
|
||||
|
||||
Items
|
||||
------
|
||||
Node (register_node):
|
||||
A node from the world
|
||||
Tool (register_tool):
|
||||
A tool/weapon that can dig and damage things according to tool_capabilities
|
||||
Craftitem (register_craftitem):
|
||||
A miscellaneous item
|
||||
|
||||
Groups
|
||||
-------
|
||||
In a number of places, there is a group table. Groups define the
|
||||
properties of a thing (item, node, armor of entity, capabilities of
|
||||
tool) in such a way that the engine and other mods can can interact with
|
||||
the thing without actually knowing what the thing is.
|
||||
|
||||
Usage:
|
||||
- Groups are stored in a table, having the group names with keys and the
|
||||
group ratings as values. For example:
|
||||
groups = {crumbly=3, soil=1}
|
||||
^ Default dirt (soil group actually currently not defined; TODO)
|
||||
groups = {crumbly=2, soil=1, level=2, outerspace=1}
|
||||
^ A more special dirt-kind of thing
|
||||
- Groups always have a rating associated with them. If there is no
|
||||
useful meaning for a rating for an enabled group, it shall be 1.
|
||||
- When not defined, the rating of a group defaults to 0. Thus when you
|
||||
read groups, you must interpret nil and 0 as the same value, 0.
|
||||
|
||||
Groups of items
|
||||
----------------
|
||||
Groups of items can define what kind of an item it is (eg. wool).
|
||||
|
||||
Groups of nodes
|
||||
----------------
|
||||
In addition to the general item things, whether a node is diggable and how
|
||||
long it takes is defined by using groups.
|
||||
|
||||
Groups of entities
|
||||
-------------------
|
||||
For entities, groups are, as of now, used only for calculating damage.
|
||||
|
||||
object.get_armor_groups() -> a group-rating table (eg. {fleshy=3})
|
||||
object.set_armor_groups({level=2, fleshy=2, cracky=2})
|
||||
|
||||
Groups of tools
|
||||
----------------
|
||||
Groups in tools define which groups of nodes and entities they are
|
||||
effective towards.
|
||||
|
||||
Groups in crafting recipes
|
||||
---------------------------
|
||||
- Not implemented yet. (TODO)
|
||||
- Will probably look like this:
|
||||
{
|
||||
output = 'food:meat_soup_raw',
|
||||
recipe = {
|
||||
{'group:meat'},
|
||||
{'group:water'},
|
||||
{'group:bowl'},
|
||||
},
|
||||
preserve = {'group:bowl'},
|
||||
}
|
||||
|
||||
Special groups
|
||||
---------------
|
||||
- immortal: Disables the group damage system for an entity
|
||||
- level: Can be used to give an additional sense of progression in the game.
|
||||
- A larger level will cause eg. a weapon of a lower level make much less
|
||||
damage, and get weared out much faster, or not be able to get drops
|
||||
from destroyed nodes.
|
||||
- 0 is something that is directly accessible at the start of gameplay
|
||||
- dig_immediate: (player can always pick up node without tool wear)
|
||||
- 2: node is removed without tool wear after 0.5 seconds or so
|
||||
(rail, sign)
|
||||
- 3: node is removed without tool wear immediately (torch)
|
||||
|
||||
Known damage and digging time defining groups
|
||||
----------------------------------------------
|
||||
- crumbly: dirt, sand
|
||||
- cracky: tough but crackable stuff like stone.
|
||||
- snappy: something that can be cut using fine tools; eg. leaves, small
|
||||
plants, wire, sheets of metal
|
||||
- choppy: something that can be cut using force; eg. trees, wooden planks
|
||||
- fleshy: Living things like animals and the player. This could imply
|
||||
some blood effects when hitting.
|
||||
- explody: Especially prone to explosions
|
||||
- oddly_breakable_by_hand:
|
||||
Can be added to nodes that shouldn't logically be breakable by the
|
||||
hand but are. Somewhat similar to dig_immediate, but times are more
|
||||
like {[1]=3.50,[2]=2.00,[3]=0.70} and this does not override the
|
||||
speed of a tool if the tool can dig at a larger speed than this
|
||||
suggests for the hand.
|
||||
|
||||
Examples of custom groups
|
||||
--------------------------
|
||||
Item groups are often used for defining, well, //groups of items//.
|
||||
- meat: any meat-kind of a thing (rating might define the size or healing
|
||||
ability or be irrelevant - it is not defined as of yet)
|
||||
- eatable: anything that can be eaten. Rating might define HP gain in half
|
||||
hearts.
|
||||
- flammable: can be set on fire. Rating might define the intensity of the
|
||||
fire, affecting eg. the speed of the spreading of an open fire.
|
||||
- wool: any wool (any origin, any color)
|
||||
- metal: any metal
|
||||
- weapon: any weapon
|
||||
- heavy: anything considerably heavy
|
||||
|
||||
Digging time calculation specifics
|
||||
-----------------------------------
|
||||
Groups such as **crumbly**, **cracky** and **snappy** are used for this
|
||||
purpose. Rating is 1, 2 or 3. A higher rating for such a group implies
|
||||
faster digging time.
|
||||
|
||||
Also, the **level** group is used.
|
||||
|
||||
Tools define their properties by a list of parameters for groups. They
|
||||
cannot dig other groups; thus it is important to use a standard bunch of
|
||||
groups to enable interaction with tools.
|
||||
|
||||
**Example definition of the digging capabilities of a tool:**
|
||||
tool_capabilities = {
|
||||
full_punch_interval=1.5,
|
||||
max_drop_level=1,
|
||||
groupcaps={
|
||||
crumbly={maxwear=0.01, maxlevel=2, times={[1]=0.80, [2]=0.60, [3]=0.40}}
|
||||
}
|
||||
}
|
||||
|
||||
**Tools define:**
|
||||
* Full punch interval Maximum drop level For an arbitrary list of groups:
|
||||
* Maximum level (usually 0, 1, 2 or 3) Maximum wear (0...1) Digging times
|
||||
|
||||
**Full punch interval**: When used as a weapon, the tool will do full
|
||||
damage if this time is spent between punches. If eg. half the time is
|
||||
spent, the tool will do half damage.
|
||||
|
||||
**Maximum drop level** suggests the maximum level of node, when dug with
|
||||
the tool, that will drop it's useful item. (eg. iron ore to drop a lump of
|
||||
iron).
|
||||
|
||||
**Maximum level** tells what is the maximum level of a node of this group
|
||||
that the tool will be able to dig.
|
||||
|
||||
**Maximum wear** determines how much the tool wears out when it is used for
|
||||
digging a node, of this group, of the maximum level. For lower leveled
|
||||
tools, the wear is divided by //4// to the exponent //level difference//.
|
||||
This means for a maximum wear of 0.1, a level difference 1 will result in
|
||||
wear=0.1/4=0.025, and a level difference of 2 will result in
|
||||
wear=0.1/(4*4)=0.00625.
|
||||
|
||||
**Digging times** is basically a list of digging times for different
|
||||
ratings of the group. It also determines the damage done to entities, based
|
||||
on their "armor groups".
|
||||
* For example, as a lua table, ''times={2=2.00, 3=0.70}''. This would
|
||||
* result the tool to be able to dig nodes that have a rating of 2 or 3
|
||||
* for this group, and unable to dig the rating 1, which is the toughest.
|
||||
* Unless there is a matching group that enables digging otherwise. For
|
||||
* entities, damage equals the amount of nodes dug in the time spent
|
||||
* between hits, with a maximum of ''full_punch_interval''.
|
||||
|
||||
Entity damage mechanism
|
||||
------------------------
|
||||
Client predicts damage based on damage groups. Because of this, it is able to
|
||||
give an immediate response when an entity is damaged or dies; the response is
|
||||
pre-defined somehow (eg. by defining a sprite animation) (not implemented;
|
||||
TODO).
|
||||
|
||||
The group **immortal** will completely disable normal damage.
|
||||
|
||||
Entities can define a special armor group, which is **punch_operable**. This
|
||||
group will disable the regular damage mechanism for players punching it by hand
|
||||
or a non-tool item.
|
||||
|
||||
On the Lua side, every punch calls ''entity:on_punch(puncher,
|
||||
time_from_last_punch, tool_capabilities, direction)''. This should never be
|
||||
called directly, because damage is usually not handled by the entity itself.
|
||||
* ''puncher'' is the object performing the punch. Can be nil. Should never be
|
||||
accessed unless absolutely required.
|
||||
* ''time_from_last_punch'' is time from last punch (by puncher) or nil.
|
||||
* ''tool_capabilities'' can be nil.
|
||||
* ''direction'' is a unit vector, pointing from the source of the punch to
|
||||
the punched object.
|
||||
|
||||
To punch an entity/object in Lua, call ''object:punch(puncher, time_from_last_punch, tool_capabilities, direction)''.
|
||||
* Return value is tool wear.
|
||||
* Parameters are equal to the above callback.
|
||||
* If ''direction'' is nil and ''puncher'' is not nil, ''direction'' will be
|
||||
automatically filled in based on the location of ''puncher''.
|
||||
|
||||
Helper functions
|
||||
-----------------
|
||||
dump2(obj, name="_", dumped={})
|
||||
^ Return object serialized as a string, handles reference loops
|
||||
dump(obj, dumped={})
|
||||
^ Return object serialized as a string
|
||||
|
||||
minetest namespace reference
|
||||
-----------------------------
|
||||
minetest.get_current_modname() -> string
|
||||
minetest.get_modpath(modname) -> eg. "/home/user/.minetest/usermods/modname"
|
||||
^ Useful for loading additional .lua modules or static data from mod
|
||||
minetest.get_worldpath(modname) -> eg. "/home/user/.minetest/world"
|
||||
^ Useful for storing custom data
|
||||
|
||||
minetest.register_entity(name, prototype table)
|
||||
minetest.register_abm(abm definition)
|
||||
minetest.register_node(name, node definition)
|
||||
minetest.register_tool(name, item definition)
|
||||
minetest.register_craftitem(name, item definition)
|
||||
minetest.register_alias(name, convert_to)
|
||||
minetest.register_craft(recipe)
|
||||
|
||||
minetest.register_globalstep(func(dtime))
|
||||
minetest.register_on_placenode(func(pos, newnode, placer))
|
||||
minetest.register_on_dignode(func(pos, oldnode, digger))
|
||||
minetest.register_on_punchnode(func(pos, node, puncher))
|
||||
minetest.register_on_generated(func(minp, maxp))
|
||||
minetest.register_on_newplayer(func(ObjectRef))
|
||||
minetest.register_on_dieplayer(func(ObjectRef))
|
||||
minetest.register_on_respawnplayer(func(ObjectRef))
|
||||
^ return true in func to disable regular player placement
|
||||
^ currently called _before_ repositioning of player occurs
|
||||
minetest.register_on_chat_message(func(name, message))
|
||||
|
||||
minetest.add_to_creative_inventory(itemstring)
|
||||
minetest.setting_get(name) -> string or nil
|
||||
minetest.setting_getbool(name) -> boolean value or nil
|
||||
|
||||
minetest.chat_send_all(text)
|
||||
minetest.chat_send_player(name, text)
|
||||
minetest.get_player_privs(name) -> set of privs
|
||||
minetest.get_inventory(location) -> InvRef
|
||||
^ location = eg. {type="player", name="celeron55"}
|
||||
{type="node", pos={x=, y=, z=}}
|
||||
|
||||
minetest.sound_play(spec, parameters) -> handle
|
||||
^ spec = SimpleSoundSpec
|
||||
^ parameters = sound parameter table
|
||||
minetest.sound_stop(handle)
|
||||
|
||||
minetest.debug(line)
|
||||
^ Goes to dstream
|
||||
minetest.log(line)
|
||||
minetest.log(loglevel, line)
|
||||
^ loglevel one of "error", "action", "info", "verbose"
|
||||
|
||||
Global objects:
|
||||
minetest.env - environment reference
|
||||
|
||||
Global tables:
|
||||
minetest.registered_items
|
||||
^ List of registered items, indexed by name
|
||||
minetest.registered_nodes
|
||||
^ List of registered node definitions, indexed by name
|
||||
minetest.registered_craftitems
|
||||
^ List of registered craft item definitions, indexed by name
|
||||
minetest.registered_tools
|
||||
^ List of registered tool definitions, indexed by name
|
||||
minetest.registered_entities
|
||||
^ List of registered entity prototypes, indexed by name
|
||||
minetest.object_refs
|
||||
^ List of object references, indexed by active object id
|
||||
minetest.luaentities
|
||||
^ List of lua entities, indexed by active object id
|
||||
|
||||
Deprecated but defined for backwards compatibility:
|
||||
minetest.digprop_constanttime(time)
|
||||
minetest.digprop_stonelike(toughness)
|
||||
minetest.digprop_dirtlike(toughness)
|
||||
minetest.digprop_gravellike(toughness)
|
||||
minetest.digprop_woodlike(toughness)
|
||||
minetest.digprop_leaveslike(toughness)
|
||||
minetest.digprop_glasslike(toughness)
|
||||
|
||||
Class reference
|
||||
----------------
|
||||
EnvRef: basically ServerEnvironment and ServerMap combined.
|
||||
methods:
|
||||
- add_node(pos, node)
|
||||
- remove_node(pos)
|
||||
- get_node(pos)
|
||||
^ Returns {name="ignore", ...} for unloaded area
|
||||
- get_node_or_nil(pos)
|
||||
^ Returns nil for unloaded area
|
||||
- get_node_light(pos, timeofday) -> 0...15 or nil
|
||||
^ timeofday: nil = current time, 0 = night, 0.5 = day
|
||||
- add_entity(pos, name): Returns ObjectRef or nil if failed
|
||||
- add_item(pos, itemstring)
|
||||
- add_rat(pos)
|
||||
- add_firefly(pos)
|
||||
- get_meta(pos) -- Get a NodeMetaRef at that position
|
||||
- get_player_by_name(name) -- Get an ObjectRef to a player
|
||||
- get_objects_inside_radius(pos, radius)
|
||||
- set_timeofday(val): val: 0...1; 0 = midnight, 0.5 = midday
|
||||
- get_timeofday()
|
||||
|
||||
NodeMetaRef (this stuff is subject to change in a future version)
|
||||
methods:
|
||||
- get_type()
|
||||
- allows_text_input()
|
||||
- set_text(text) -- eg. set the text of a sign
|
||||
- get_text()
|
||||
- get_owner()
|
||||
- set_owner(string)
|
||||
Generic node metadata specific:
|
||||
- set_infotext(infotext)
|
||||
- get_inventory() -> InvRef
|
||||
- set_inventory_draw_spec(string)
|
||||
- set_allow_text_input(bool)
|
||||
- set_allow_removal(bool)
|
||||
- set_enforce_owner(bool)
|
||||
- is_inventory_modified()
|
||||
- reset_inventory_modified()
|
||||
- is_text_modified()
|
||||
- reset_text_modified()
|
||||
- set_string(name, value)
|
||||
- get_string(name)
|
||||
|
||||
ObjectRef: Moving things in the game are generally these
|
||||
(basically reference to a C++ ServerActiveObject)
|
||||
methods:
|
||||
- remove(): remove object (after returning from Lua)
|
||||
- getpos() -> {x=num, y=num, z=num}
|
||||
- setpos(pos); pos={x=num, y=num, z=num}
|
||||
- moveto(pos, continuous=false): interpolated move
|
||||
- punch(puncher, time_from_last_punch, tool_capabilities, direction)
|
||||
^ puncher = an another ObjectRef,
|
||||
^ time_from_last_punch = time since last punch action of the puncher
|
||||
- right_click(clicker); clicker = an another ObjectRef
|
||||
- get_hp(): returns number of hitpoints (2 * number of hearts)
|
||||
- set_hp(hp): set number of hitpoints (2 * number of hearts)
|
||||
- get_inventory() -> InvRef
|
||||
- get_wield_list(): returns the name of the inventory list the wielded item is in
|
||||
- get_wield_index(): returns the index of the wielded item
|
||||
- get_wielded_item() -> ItemStack
|
||||
- set_wielded_item(item): replaces the wielded item, returns true if successful
|
||||
LuaEntitySAO-only: (no-op for other objects)
|
||||
- setvelocity({x=num, y=num, z=num})
|
||||
- getvelocity() -> {x=num, y=num, z=num}
|
||||
- setacceleration({x=num, y=num, z=num})
|
||||
- getacceleration() -> {x=num, y=num, z=num}
|
||||
- setyaw(radians)
|
||||
- getyaw() -> radians
|
||||
- settexturemod(mod)
|
||||
- setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
|
||||
- select_horiz_by_yawpitch=false)
|
||||
- ^ Select sprite from spritesheet with optional animation and DM-style
|
||||
- texture selection based on yaw relative to camera
|
||||
- set_armor_groups({group1=rating, group2=rating, ...})
|
||||
- get_entity_name() (DEPRECATED: Will be removed in a future version)
|
||||
- get_luaentity()
|
||||
Player-only: (no-op for other objects)
|
||||
- get_player_name(): will return nil if is not a player
|
||||
- get_look_dir(): get camera direction as a unit vector
|
||||
- get_look_pitch(): pitch in radians
|
||||
- get_look_yaw(): yaw in radians (wraps around pretty randomly as of now)
|
||||
|
||||
InvRef: Reference to an inventory
|
||||
methods:
|
||||
- get_size(listname): get size of a list
|
||||
- set_size(listname, size): set size of a list
|
||||
- get_stack(listname, i): get a copy of stack index i in list
|
||||
- set_stack(listname, i, stack): copy stack to index i in list
|
||||
- get_list(listname): return full list
|
||||
- set_list(listname, list): set full list (size will not change)
|
||||
- add_item(listname, stack): add item somewhere in list, returns leftover ItemStack
|
||||
- room_for_item(listname, stack): returns true if the stack of items
|
||||
can be fully added to the list
|
||||
- contains_item(listname, stack): returns true if the stack of items
|
||||
can be fully taken from the list
|
||||
remove_item(listname, stack): take as many items as specified from the list,
|
||||
returns the items that were actually removed (as an ItemStack)
|
||||
|
||||
ItemStack: A stack of items.
|
||||
methods:
|
||||
- is_empty(): return true if stack is empty
|
||||
- get_name(): returns item name (e.g. "default:stone")
|
||||
- get_count(): returns number of items on the stack
|
||||
- get_wear(): returns tool wear (0-65535), 0 for non-tools
|
||||
- get_metadata(): returns metadata (a string attached to an item stack)
|
||||
- clear(): removes all items from the stack, making it empty
|
||||
- replace(item): replace the contents of this stack (item can also
|
||||
be an itemstring or table)
|
||||
- to_string(): returns the stack in itemstring form
|
||||
- to_table(): returns the stack in Lua table form
|
||||
- get_stack_max(): returns the maximum size of the stack (depends on the item)
|
||||
- get_free_space(): returns get_stack_max() - get_count()
|
||||
- is_known(): returns true if the item name refers to a defined item type
|
||||
- get_definition(): returns the item definition table
|
||||
- get_tool_capabilities(): returns the digging properties of the item,
|
||||
^ or those of the hand if none are defined for this item type
|
||||
- add_wear(amount): increases wear by amount if the item is a tool
|
||||
- add_item(item): put some item or stack onto this stack,
|
||||
^ returns leftover ItemStack
|
||||
- item_fits(item): returns true if item or stack can be fully added to this one
|
||||
- take_item(n): take (and remove) up to n items from this stack
|
||||
^ returns taken ItemStack
|
||||
^ if n is omitted, n=1 is used
|
||||
- peek_item(n): copy (don't remove) up to n items from this stack
|
||||
^ returns copied ItemStack
|
||||
^ if n is omitted, n=1 is used
|
||||
|
||||
Registered entities
|
||||
--------------------
|
||||
- Functions receive a "luaentity" as self:
|
||||
- It has the member .name, which is the registered name ("mod:thing")
|
||||
- It has the member .object, which is an ObjectRef pointing to the object
|
||||
- The original prototype stuff is visible directly via a metatable
|
||||
- Callbacks:
|
||||
- on_activate(self, staticdata)
|
||||
^ Called when the object is instantiated.
|
||||
- on_step(self, dtime)
|
||||
^ Called on every server tick (dtime is usually 0.05 seconds)
|
||||
- on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
^ Called when somebody punches the object.
|
||||
^ Note that you probably want to handle most punches using the
|
||||
automatic armor group system.
|
||||
^ puncher: ObjectRef (can be nil)
|
||||
^ time_from_last_punch: Meant for disallowing spamming of clicks (can be nil)
|
||||
^ tool_capabilities: capability table of used tool (can be nil)
|
||||
^ dir: unit vector of direction of punch. Always defined. Points from
|
||||
the puncher to the punched.
|
||||
- on_rightclick(self, clicker)
|
||||
- get_staticdata(self)
|
||||
^ Should return a string that will be passed to on_activate when
|
||||
the object is instantiated the next time.
|
||||
|
||||
Definition tables
|
||||
------------------
|
||||
|
||||
Entity definition (register_entity)
|
||||
{
|
||||
physical = true,
|
||||
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
||||
visual = "cube"/"sprite",
|
||||
visual_size = {x=1, y=1},
|
||||
textures = {texture,texture,texture,texture,texture,texture},
|
||||
spritediv = {x=1, y=1},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
on_activate = function(self, staticdata),
|
||||
on_step = function(self, dtime),
|
||||
on_punch = function(self, hitter),
|
||||
on_rightclick = function(self, clicker),
|
||||
get_staticdata = function(self),
|
||||
# Also you can define arbitrary member variables here
|
||||
myvariable = whatever,
|
||||
}
|
||||
|
||||
ABM (ActiveBlockModifier) definition (register_abm)
|
||||
{
|
||||
nodenames = {"default:lava_source"},
|
||||
neighbors = {"default:water_source", "default:water_flowing"}, -- (any of these)
|
||||
^ If left out or empty, any neighbor will do
|
||||
interval = 1.0, -- (operation interval)
|
||||
chance = 1, -- (chance of trigger is 1.0/this)
|
||||
action = func(pos, node, active_object_count, active_object_count_wider),
|
||||
}
|
||||
|
||||
Item definition (register_node, register_craftitem, register_tool)
|
||||
{
|
||||
description = "Steel Axe",
|
||||
groups = {}, -- key=name, value=rating; rating=1..3.
|
||||
if rating not applicable, use 1.
|
||||
eg. {wool=1, fluffy=3}
|
||||
{soil=2, outerspace=1, crumbly=1}
|
||||
{bendy=2, snappy=1},
|
||||
{hard=1, metal=1, spikes=1}
|
||||
inventory_image = "default_tool_steelaxe.png",
|
||||
wield_image = "",
|
||||
wield_scale = {x=1,y=1,z=1},
|
||||
stack_max = 99,
|
||||
liquids_pointable = false,
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 1.0,
|
||||
max_drop_level=0,
|
||||
groupcaps={
|
||||
-- For example:
|
||||
fleshy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
|
||||
snappy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
|
||||
choppy={times={[3]=0.90}, maxwear=0.05, maxlevel=0}
|
||||
}
|
||||
}
|
||||
on_drop = func(item, dropper, pos),
|
||||
on_place = func(item, placer, pointed_thing),
|
||||
on_use = func(item, user, pointed_thing),
|
||||
}
|
||||
|
||||
Node definition (register_node)
|
||||
{
|
||||
<all fields allowed in item definitions>,
|
||||
|
||||
drawtype = "normal",
|
||||
visual_scale = 1.0,
|
||||
tile_images = {"default_unknown_block.png"},
|
||||
special_materials = {
|
||||
{image="", backface_culling=true},
|
||||
{image="", backface_culling=true},
|
||||
},
|
||||
alpha = 255,
|
||||
post_effect_color = {a=0, r=0, g=0, b=0},
|
||||
paramtype = "none",
|
||||
paramtype2 = "none",
|
||||
is_ground_content = false,
|
||||
sunlight_propagates = false,
|
||||
walkable = true,
|
||||
pointable = true,
|
||||
diggable = true,
|
||||
climbable = false,
|
||||
buildable_to = false,
|
||||
drop = "",
|
||||
-- alternatively drop = { max_items = ..., items = { ... } }
|
||||
metadata_name = "",
|
||||
liquidtype = "none",
|
||||
liquid_alternative_flowing = "",
|
||||
liquid_alternative_source = "",
|
||||
liquid_viscosity = 0,
|
||||
light_source = 0,
|
||||
damage_per_second = 0,
|
||||
selection_box = {type="regular"},
|
||||
legacy_facedir_simple = false, -- Support maps made in and before January 2012
|
||||
legacy_wallmounted = false, -- Support maps made in and before January 2012
|
||||
sounds = {
|
||||
footstep = <SimpleSoundSpec>,
|
||||
dig = <SimpleSoundSpec>, -- "__group" = group-based sound (default)
|
||||
dug = <SimpleSoundSpec>,
|
||||
},
|
||||
}
|
||||
|
||||
Recipe: (register_craft)
|
||||
{
|
||||
output = 'default:pick_stone',
|
||||
recipe = {
|
||||
{'default:cobble', 'default:cobble', 'default:cobble'},
|
||||
{'', 'default:stick', ''},
|
||||
{'', 'default:stick', ''},
|
||||
},
|
||||
replacements = <optional list of item pairs,
|
||||
replace one input item with another item on crafting>
|
||||
}
|
||||
|
||||
Recipe (shapeless):
|
||||
{
|
||||
type = "shapeless",
|
||||
output = 'mushrooms:mushroom_stew',
|
||||
recipe = {
|
||||
"mushrooms:bowl",
|
||||
"mushrooms:mushroom_brown",
|
||||
"mushrooms:mushroom_red",
|
||||
},
|
||||
replacements = <optional list of item pairs,
|
||||
replace one input item with another item on crafting>
|
||||
}
|
||||
|
||||
Recipe (tool repair):
|
||||
{
|
||||
type = "toolrepair",
|
||||
additional_wear = -0.02,
|
||||
}
|
||||
|
||||
Recipe (cooking):
|
||||
{
|
||||
type = "cooking",
|
||||
output = "default:glass",
|
||||
recipe = "default:sand",
|
||||
cooktime = 3,
|
||||
}
|
||||
|
||||
Recipe (furnace fuel):
|
||||
{
|
||||
type = "fuel",
|
||||
recipe = "default:leaves",
|
||||
burntime = 1,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,462 @@
|
||||
I'll try to quickly document the newest block format in here (might contain
|
||||
errors). Refer to the mapgen or minetestmapper script for the directory
|
||||
structure and file naming. There are two sector namings possible,
|
||||
sector/XXXXZZZZ and sector/XXX/ZZZ.
|
||||
=================================================
|
||||
Minetest World Format used as of 0.4.dev-20120322
|
||||
=================================================
|
||||
|
||||
This applies to a world format carrying the block serialization version 22
|
||||
which is used at least in version 0.4.dev-20120322.
|
||||
|
||||
The block serialization version used is 22. It does not fully specify every
|
||||
aspect of this format; if compliance with this format is to be checked, it
|
||||
needs to be done by detecting if the files and data indeed follows it.
|
||||
|
||||
Legacy stuff
|
||||
=============
|
||||
Data can, in theory, be contained in the flat file directory structure
|
||||
described below in Version 17, but it is not officially supported. Also you
|
||||
may stumble upon all kinds of oddities in not-so-recent formats.
|
||||
|
||||
Files
|
||||
======
|
||||
Everything is contained in a directory, the name of which is freeform, but
|
||||
often serves as the name of the world.
|
||||
|
||||
Currently the authentication and ban data is stored on a per-world basis. It
|
||||
can be copied over from an old world to a newly created world.
|
||||
|
||||
World
|
||||
|-- auth.txt ----- Authentication data
|
||||
|-- env_meta.txt - Environment metadata
|
||||
|-- ipban.txt ---- Banned ips/users
|
||||
|-- map_meta.txt - Map metadata
|
||||
|-- map.sqlite --- Map data
|
||||
|-- players ------ Player directory
|
||||
| |-- player1 -- Player file
|
||||
| '-- Foo ------ Player file
|
||||
`-- world.mt ----- World metadata
|
||||
|
||||
auth.txt
|
||||
---------
|
||||
Contains authentication data, player per line.
|
||||
<name>:<password hash>:<privilege1,...>
|
||||
Format of password hash is <name><password> SHA1'd, in the base64 encoding.
|
||||
|
||||
Example lines:
|
||||
- Player "celeron55", no password, privileges "interact" and "shout":
|
||||
celeron55::interact,shout
|
||||
- Player "Foo", password "bar", privilege "shout":
|
||||
foo:iEPX+SQWIR3p67lj/0zigSWTKHg:shout
|
||||
- Player "bar", no password, no privileges:
|
||||
bar::
|
||||
|
||||
env_meta.txt
|
||||
-------------
|
||||
Simple global environment variables.
|
||||
Example content (added indentation):
|
||||
game_time = 73471
|
||||
time_of_day = 19118
|
||||
EnvArgsEnd
|
||||
|
||||
ipban.txt
|
||||
----------
|
||||
Banned IP addresses and usernames.
|
||||
Example content (added indentation):
|
||||
123.456.78.9|foo
|
||||
123.456.78.10|bar
|
||||
|
||||
map_meta.txt
|
||||
-------------
|
||||
Simple global map variables.
|
||||
Example content (added indentation):
|
||||
seed = 7980462765762429666
|
||||
[end_of_params]
|
||||
|
||||
map.sqlite
|
||||
-----------
|
||||
Map data.
|
||||
See Map File Format below.
|
||||
|
||||
player1, Foo
|
||||
-------------
|
||||
Player data.
|
||||
Filename can be anything.
|
||||
See Player File Format below.
|
||||
|
||||
world.mt
|
||||
---------
|
||||
World metadata.
|
||||
Example content (added indentation):
|
||||
gameid = mesetint
|
||||
|
||||
Player File Format
|
||||
===================
|
||||
|
||||
- Should be pretty self-explanatory.
|
||||
- Note: position is in nodes * 10
|
||||
|
||||
Example content (added indentation):
|
||||
hp = 11
|
||||
name = celeron55
|
||||
pitch = 39.77
|
||||
position = (-5231.97,15,1961.41)
|
||||
version = 1
|
||||
yaw = 101.37
|
||||
PlayerArgsEnd
|
||||
List main 32
|
||||
Item default:torch 13
|
||||
Item default:pick_steel 1 50112
|
||||
Item experimental:tnt
|
||||
Item default:cobble 99
|
||||
Item default:pick_stone 1 13104
|
||||
Item default:shovel_steel 1 51838
|
||||
Item default:dirt 61
|
||||
Item default:rail 78
|
||||
Item default:coal_lump 3
|
||||
Item default:cobble 99
|
||||
Item default:leaves 22
|
||||
Item default:gravel 52
|
||||
Item default:axe_steel 1 2045
|
||||
Item default:cobble 98
|
||||
Item default:sand 61
|
||||
Item default:water_source 94
|
||||
Item default:glass 2
|
||||
Item default:mossycobble
|
||||
Item default:pick_steel 1 64428
|
||||
Item animalmaterials:bone
|
||||
Item default:sword_steel
|
||||
Item default:sapling
|
||||
Item default:sword_stone 1 10647
|
||||
Item default:dirt 99
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
EndInventoryList
|
||||
List craft 9
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
EndInventoryList
|
||||
List craftpreview 1
|
||||
Empty
|
||||
EndInventoryList
|
||||
List craftresult 1
|
||||
Empty
|
||||
EndInventoryList
|
||||
EndInventory
|
||||
|
||||
Map File Format
|
||||
================
|
||||
|
||||
Minetest maps consist of MapBlocks, chunks of 16x16x16 nodes.
|
||||
|
||||
In addition to the bulk node data, MapBlocks stored on disk also contain
|
||||
other things.
|
||||
|
||||
History
|
||||
--------
|
||||
We need a bit of history in here. Initially Minetest stored maps in a
|
||||
format called the "sectors" format. It was a directory/file structure like
|
||||
this:
|
||||
sectors2/XXX/ZZZ/YYYY
|
||||
For example, the MapBlock at (0,1,-2) was this file:
|
||||
sectors2/000/ffd/0001
|
||||
|
||||
Eventually Minetest outgrow this directory structure, as filesystems were
|
||||
struggling under the amount of files and directories.
|
||||
|
||||
Large servers seriously needed a new format, and thus the base of the
|
||||
current format was invented, suggested by celeron55 and implemented by
|
||||
JacobF.
|
||||
|
||||
SQLite3 was slammed in, and blocks files were directly inserted as blobs
|
||||
in a single table, indexed by integer primary keys, oddly mangled from
|
||||
coordinates.
|
||||
|
||||
Today we know that SQLite3 allows multiple primary keys (which would allow
|
||||
storing coordinates separately), but the format has been kept unchanged for
|
||||
that part. So, this is where it has come.
|
||||
</history>
|
||||
|
||||
So here goes
|
||||
-------------
|
||||
map.sqlite is an sqlite3 database, containg a single table, called
|
||||
"blocks". It looks like this:
|
||||
|
||||
CREATE TABLE `blocks` (`pos` INT NOT NULL PRIMARY KEY,`data` BLOB);
|
||||
|
||||
The key
|
||||
--------
|
||||
"pos" is created from the three coordinates of a MapBlock using this
|
||||
algorithm, defined here in Python:
|
||||
|
||||
def getBlockAsInteger(p):
|
||||
return int64(p[2]*16777216 + p[1]*4096 + p[0])
|
||||
|
||||
def int64(u):
|
||||
while u >= 2**63:
|
||||
u -= 2**64
|
||||
while u <= -2**63:
|
||||
u += 2**64
|
||||
return u
|
||||
|
||||
It can be converted the other way by using this code:
|
||||
|
||||
def getIntegerAsBlock(i):
|
||||
x = unsignedToSigned(i % 4096, 2048)
|
||||
i = int((i - x) / 4096)
|
||||
y = unsignedToSigned(i % 4096, 2048)
|
||||
i = int((i - y) / 4096)
|
||||
z = unsignedToSigned(i % 4096, 2048)
|
||||
return x,y,z
|
||||
|
||||
def unsignedToSigned(i, max_positive):
|
||||
if i < max_positive:
|
||||
return i
|
||||
else:
|
||||
return i - 2*max_positive
|
||||
|
||||
The blob
|
||||
---------
|
||||
The blob is the data that would have otherwise gone into the file.
|
||||
|
||||
See below for description.
|
||||
|
||||
MapBlock serialization format
|
||||
==============================
|
||||
NOTE: Byte order is MSB first (big-endian).
|
||||
NOTE: Zlib data is in such a format that Python's zlib at least can
|
||||
directly decompress.
|
||||
|
||||
u8 version
|
||||
- map format version number, this one is version 22
|
||||
|
||||
u8 flags
|
||||
- Flag bitmasks:
|
||||
- 0x01: is_underground: Should be set to 0 if there will be no light
|
||||
obstructions above the block. If/when sunlight of a block is updated
|
||||
and there is no block above it, this value is checked for determining
|
||||
whether sunlight comes from the top.
|
||||
- 0x02: day_night_differs: Whether the lighting of the block is different
|
||||
on day and night. Only blocks that have this bit set are updated when
|
||||
day transforms to night.
|
||||
- 0x04: lighting_expired: If true, lighting is invalid and should be
|
||||
updated. If you can't calculate lighting in your generator properly,
|
||||
you could try setting this 1 to everything and setting the uppermost
|
||||
block in every sector as is_underground=0. I am quite sure it doesn't
|
||||
work properly, though.
|
||||
- 0x08: generated: True if the block has been generated. If false, block
|
||||
is mostly filled with CONTENT_IGNORE and is likely to contain eg. parts
|
||||
of trees of neighboring blocks.
|
||||
|
||||
u8 content_width
|
||||
- Number of bytes in the content (param0) fields of nodes
|
||||
- Always 1
|
||||
|
||||
u8 params_width
|
||||
- Number of bytes used for parameters per node
|
||||
- Always 2
|
||||
|
||||
zlib-compressed node data:
|
||||
- content:
|
||||
u8[4096]: param0 fields
|
||||
u8[4096]: param1 fields
|
||||
u8[4096]: param2 fields
|
||||
- The location of a node in each of those arrays is (z*16*16 + y*16 + x).
|
||||
|
||||
zlib-compressed node metadata list
|
||||
- content:
|
||||
u16 version (=1)
|
||||
u16 count of metadata
|
||||
foreach count:
|
||||
u16 position (p.Z*MAP_BLOCKSIZE*MAP_BLOCKSIZE + p.Y*MAP_BLOCKSIZE + p.X)
|
||||
u16 type_id
|
||||
u16 content_size
|
||||
u8[content_size] (content of metadata)
|
||||
|
||||
u16 mapblockobject_count
|
||||
- Always 0
|
||||
- Should be removed in version 23 (TODO)
|
||||
|
||||
u8 static object version:
|
||||
- Always 0
|
||||
|
||||
u16 static_object_count
|
||||
|
||||
foreach static_object_count:
|
||||
u8 type (object type-id)
|
||||
s32 pos_x_nodes * 10000
|
||||
s32 pos_y_nodes * 10000
|
||||
s32 pos_z_nodes * 10000
|
||||
u16 data_size
|
||||
u8[data_size] data
|
||||
|
||||
u32 timestamp
|
||||
- Timestamp when last saved, as seconds from starting the game.
|
||||
- 0xffffffff = invalid/unknown timestamp, nothing should be done with the time
|
||||
difference when loaded
|
||||
|
||||
u8 name-id-mapping version
|
||||
- Always 0
|
||||
|
||||
u16 num_name_id_mappings
|
||||
|
||||
foreach num_name_id_mappings
|
||||
u16 id
|
||||
u16 name_len
|
||||
u8[name_len] name
|
||||
|
||||
EOF.
|
||||
|
||||
Format of nodes
|
||||
----------------
|
||||
A node is composed of the u8 fields param0, param1 and param2.
|
||||
|
||||
The content id of a node is determined as so:
|
||||
- If param0 < 0x80,
|
||||
content_id = param0
|
||||
- Otherwise
|
||||
content_id = (param0<<4) + (param2>>4)
|
||||
|
||||
The purpose of param1 and param2 depend on the definition of the node.
|
||||
|
||||
The name-id-mapping
|
||||
--------------------
|
||||
The mapping maps node content ids to node names.
|
||||
|
||||
Node metadata format
|
||||
---------------------
|
||||
|
||||
1: Generic metadata
|
||||
serialized inventory
|
||||
u32 len
|
||||
u8[len] text
|
||||
u16 len
|
||||
u8[len] owner
|
||||
u16 len
|
||||
u8[len] infotext
|
||||
u16 len
|
||||
u8[len] inventory drawspec
|
||||
u8 allow_text_input (bool)
|
||||
u8 removal_disabled (bool)
|
||||
u8 enforce_owner (bool)
|
||||
u32 num_vars
|
||||
foreach num_vars
|
||||
u16 len
|
||||
u8[len] name
|
||||
u32 len
|
||||
u8[len] value
|
||||
|
||||
14: Sign metadata
|
||||
u16 text_len
|
||||
u8[text_len] text
|
||||
|
||||
15: Chest metadata
|
||||
serialized inventory
|
||||
|
||||
16: Furnace metadata
|
||||
TBD
|
||||
|
||||
17: Locked Chest metadata
|
||||
u16 len
|
||||
u8[len] owner
|
||||
serialized inventory
|
||||
|
||||
Static objects
|
||||
---------------
|
||||
Static objects are persistent freely moving objects in the world.
|
||||
|
||||
Object types:
|
||||
1: Test object
|
||||
2: Item
|
||||
3: Rat (deprecated)
|
||||
4: Oerkki (deprecated)
|
||||
5: Firefly (deprecated)
|
||||
6: MobV2 (deprecated)
|
||||
7: LuaEntity
|
||||
|
||||
1: Item:
|
||||
u8 version
|
||||
version 0:
|
||||
u16 len
|
||||
u8[len] itemstring
|
||||
|
||||
7: LuaEntity:
|
||||
u8 version
|
||||
version 1:
|
||||
u16 len
|
||||
u8[len] entity name
|
||||
u32 len
|
||||
u8[len] static data
|
||||
s16 hp
|
||||
s32 velocity.x * 10000
|
||||
s32 velocity.y * 10000
|
||||
s32 velocity.z * 10000
|
||||
s32 yaw * 1000
|
||||
|
||||
Itemstring format
|
||||
------------------
|
||||
eg. 'default:dirt 5'
|
||||
eg. 'default:pick_wood 21323'
|
||||
eg. '"default:apple" 2'
|
||||
eg. 'default:apple'
|
||||
- The wear value in tools is 0...65535
|
||||
- There are also a number of older formats that you might stumble upon:
|
||||
eg. 'node "default:dirt" 5'
|
||||
eg. 'NodeItem default:dirt 5'
|
||||
eg. 'ToolItem WPick 21323'
|
||||
|
||||
Inventory serialization format
|
||||
-------------------------------
|
||||
- The inventory serialization format is line-based
|
||||
- The newline character used is "\n"
|
||||
- The end condition of a serialized inventory is always "EndInventory\n"
|
||||
- All the slots in a list must always be serialized.
|
||||
|
||||
Example (format does not include "---"):
|
||||
---
|
||||
List foo 4
|
||||
Item default:sapling
|
||||
Item default:sword_stone 1 10647
|
||||
Item default:dirt 99
|
||||
Empty
|
||||
EndInventoryList
|
||||
List bar 9
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
Empty
|
||||
EndInventoryList
|
||||
EndInventory
|
||||
---
|
||||
|
||||
==============================================
|
||||
Minetest World Format used as of 2011-05 or so
|
||||
==============================================
|
||||
|
||||
Map data serialization format version 17.
|
||||
|
||||
0.3.1 does not use this format, but a more recent one. This exists here for
|
||||
historical reasons.
|
||||
|
||||
Directory structure:
|
||||
sectors/XXXXZZZZ or sectors2/XXX/ZZZ
|
||||
XXXX, ZZZZ, XXX and ZZZ being the hexadecimal X and Z coordinates.
|
||||
Under these, the block files are stored, called YYYY.
|
||||
|
||||
There also exists files map_meta.txt and chunk_meta, that are used by the
|
||||
generator. If they are not found or invalid, the generator will currently
|
||||
|
||||
91
doc/minetest.6
Normal file
@@ -0,0 +1,91 @@
|
||||
.\" Minetest man page
|
||||
.TH minetest 6 "11 March 2012" "" ""
|
||||
|
||||
.SH NAME
|
||||
minetest \- Multiplayer infinite-world block sandbox
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B minetest
|
||||
[ OPTION ... ]
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B Minetest
|
||||
is one of the first InfiniMiner/Minecraft(/whatever) inspired games (started October 2010), with a goal of taking the survival multiplayer gameplay to a slightly different direction.
|
||||
.PP
|
||||
The main design philosophy is to keep it technically simple, stable and portable. It will be kept lightweight enough to run on fairly old hardware.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\-\-address <value>
|
||||
Address to connect to
|
||||
.TP
|
||||
\-\-config <value>
|
||||
Load configuration from specified file
|
||||
.TP
|
||||
\-\-disable\-unittests
|
||||
Disable unit tests
|
||||
.TP
|
||||
\-\-enable\-unittests
|
||||
Enable unit tests
|
||||
.TP
|
||||
\-\-gameid <value>
|
||||
Set gameid
|
||||
.TP
|
||||
\-\-go
|
||||
Disable main menu
|
||||
.TP
|
||||
\-\-help
|
||||
Show allowed options
|
||||
.TP
|
||||
\-\-logfile <value>
|
||||
Set logfile path (debug.txt)
|
||||
.TP
|
||||
\-\-map\-dir <value>
|
||||
Same as --world (deprecated)
|
||||
.TP
|
||||
\-\-name <value>
|
||||
Set player name
|
||||
.TP
|
||||
\-\-password <value>
|
||||
Set password
|
||||
.TP
|
||||
\-\-port <value>
|
||||
Set network port (UDP) to use
|
||||
.TP
|
||||
\-\-random\-input
|
||||
Enable random user input, for testing
|
||||
.TP
|
||||
\-\-server
|
||||
Run dedicated server
|
||||
.TP
|
||||
\-\-speedtests
|
||||
Run speed tests
|
||||
.TP
|
||||
\-\-info
|
||||
Print more information to console
|
||||
.TP
|
||||
\-\-verbose
|
||||
Print even more information to console
|
||||
.TP
|
||||
\-\-trace
|
||||
Print enormous amounts of information to console
|
||||
.TP
|
||||
\-\-world <value>
|
||||
Set world path
|
||||
|
||||
.SH BUGS
|
||||
Please report all bugs to Perttu Ahola <celeron55@gmail.com>.
|
||||
|
||||
.SH AUTHOR
|
||||
.PP
|
||||
Perttu Ahola <celeron55@gmail.com>
|
||||
and contributors.
|
||||
.PP
|
||||
This man page was originally written by
|
||||
Juhani Numminen <juhaninumminen0@gmail.com>.
|
||||
|
||||
.SH WWW
|
||||
http://c55.me/minetest/
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.BR minetestserver(6)
|
||||
70
doc/minetestserver.6
Normal file
@@ -0,0 +1,70 @@
|
||||
.\" Minetestserver man page
|
||||
.TH minetestserver 6 "11 March 2012" "" ""
|
||||
|
||||
.SH NAME
|
||||
minetestserver \- Minetest server
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B minetestserver
|
||||
[ OPTION ... ]
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B Minetest
|
||||
is one of the first InfiniMiner/Minecraft(/whatever) inspired games (started October 2010), with a goal of taking the survival multiplayer gameplay to a slightly different direction.
|
||||
.PP
|
||||
The main design philosophy is to keep it technically simple, stable and portable. It will be kept lightweight enough to run on fairly old hardware.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\-\-config <value>
|
||||
Load configuration from specified file
|
||||
.TP
|
||||
\-\-disable\-unittests
|
||||
Disable unit tests
|
||||
.TP
|
||||
\-\-enable\-unittests
|
||||
Enable unit tests
|
||||
.TP
|
||||
\-\-gameid <value>
|
||||
Set gameid
|
||||
.TP
|
||||
\-\-help
|
||||
Show allowed options
|
||||
.TP
|
||||
\-\-logfile <value>
|
||||
Set logfile path (debug.txt)
|
||||
.TP
|
||||
\-\-map\-dir <value>
|
||||
Same as --world (deprecated)
|
||||
.TP
|
||||
\-\-port <value>
|
||||
Set network port (UDP) to use
|
||||
.TP
|
||||
\-\-info
|
||||
Print more information to console
|
||||
.TP
|
||||
\-\-verbose
|
||||
Print even more information to console
|
||||
.TP
|
||||
\-\-trace
|
||||
Print enormous amounts of information to console
|
||||
.TP
|
||||
\-\-world <value>
|
||||
Set world path
|
||||
|
||||
.SH BUGS
|
||||
Please report all bugs to Perttu Ahola <celeron55@gmail.com>.
|
||||
|
||||
.SH AUTHOR
|
||||
.PP
|
||||
Perttu Ahola <celeron55@gmail.com>
|
||||
and contributors.
|
||||
.PP
|
||||
This man page was originally written by
|
||||
Juhani Numminen <juhaninumminen0@gmail.com>.
|
||||
|
||||
.SH WWW
|
||||
http://c55.me/minetest/
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.BR minetest(6)
|
||||
2
games/minimal/game.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
name = Minimal development test
|
||||
|
||||
95
games/minimal/mods/bucket/init.lua
Normal file
@@ -0,0 +1,95 @@
|
||||
-- bucket (Minetest 0.4 mod)
|
||||
-- A bucket, which can pick up water and lava
|
||||
|
||||
minetest.register_alias("bucket", "bucket:bucket_empty")
|
||||
minetest.register_alias("bucket_water", "bucket:bucket_water")
|
||||
minetest.register_alias("bucket_lava", "bucket:bucket_lava")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'bucket:bucket_empty 1',
|
||||
recipe = {
|
||||
{'default:steel_ingot', '', 'default:steel_ingot'},
|
||||
{'', 'default:steel_ingot', ''},
|
||||
}
|
||||
})
|
||||
|
||||
bucket = {}
|
||||
bucket.liquids = {}
|
||||
|
||||
-- Register a new liquid
|
||||
-- source = name of the source node
|
||||
-- flowing = name of the flowing node
|
||||
-- itemname = name of the new bucket item (or nil if liquid is not takeable)
|
||||
-- inventory_image = texture of the new bucket item (ignored if itemname == nil)
|
||||
-- This function can be called from any mod (that depends on bucket).
|
||||
function bucket.register_liquid(source, flowing, itemname, inventory_image)
|
||||
bucket.liquids[source] = {
|
||||
source = source,
|
||||
flowing = flowing,
|
||||
itemname = itemname,
|
||||
}
|
||||
bucket.liquids[flowing] = bucket.liquids[source]
|
||||
|
||||
if itemname ~= nil then
|
||||
minetest.register_craftitem(itemname, {
|
||||
inventory_image = inventory_image,
|
||||
stack_max = 1,
|
||||
liquids_pointable = true,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
-- Must be pointing to node
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
-- Check if pointing to a liquid
|
||||
n = minetest.env:get_node(pointed_thing.under)
|
||||
if bucket.liquids[n.name] == nil then
|
||||
-- Not a liquid
|
||||
minetest.env:add_node(pointed_thing.above, {name=source})
|
||||
elseif n.name ~= source then
|
||||
-- It's a liquid
|
||||
minetest.env:add_node(pointed_thing.under, {name=source})
|
||||
end
|
||||
return {name="bucket:bucket_empty"}
|
||||
end
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_craftitem("bucket:bucket_empty", {
|
||||
inventory_image = "bucket.png",
|
||||
stack_max = 1,
|
||||
liquids_pointable = true,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
-- Must be pointing to node
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
-- Check if pointing to a liquid source
|
||||
n = minetest.env:get_node(pointed_thing.under)
|
||||
liquiddef = bucket.liquids[n.name]
|
||||
if liquiddef ~= nil and liquiddef.source == n.name and liquiddef.itemname ~= nil then
|
||||
minetest.env:add_node(pointed_thing.under, {name="air"})
|
||||
return {name=liquiddef.itemname}
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
bucket.register_liquid(
|
||||
"default:water_source",
|
||||
"default:water_flowing",
|
||||
"bucket:bucket_water",
|
||||
"bucket_water.png"
|
||||
)
|
||||
|
||||
bucket.register_liquid(
|
||||
"default:lava_source",
|
||||
"default:lava_flowing",
|
||||
"bucket:bucket_lava",
|
||||
"bucket_lava.png"
|
||||
)
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "default:bucket_lava",
|
||||
burntime = 60,
|
||||
})
|
||||
|
Before Width: | Height: | Size: 329 B After Width: | Height: | Size: 329 B |
|
Before Width: | Height: | Size: 363 B After Width: | Height: | Size: 363 B |
|
Before Width: | Height: | Size: 369 B After Width: | Height: | Size: 369 B |
1510
games/minimal/mods/default/init.lua
Normal file
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
|
Before Width: | Height: | Size: 292 B After Width: | Height: | Size: 292 B |
|
Before Width: | Height: | Size: 597 B After Width: | Height: | Size: 597 B |
|
Before Width: | Height: | Size: 604 B After Width: | Height: | Size: 604 B |
|
Before Width: | Height: | Size: 279 B After Width: | Height: | Size: 279 B |
|
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 236 B |
|
Before Width: | Height: | Size: 167 B After Width: | Height: | Size: 167 B |
|
Before Width: | Height: | Size: 224 B After Width: | Height: | Size: 224 B |
|
Before Width: | Height: | Size: 151 B After Width: | Height: | Size: 151 B |
|
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 142 B |
|
Before Width: | Height: | Size: 613 B After Width: | Height: | Size: 613 B |
|
Before Width: | Height: | Size: 249 B After Width: | Height: | Size: 249 B |
|
Before Width: | Height: | Size: 210 B After Width: | Height: | Size: 210 B |
|
Before Width: | Height: | Size: 118 B After Width: | Height: | Size: 118 B |
|
Before Width: | Height: | Size: 933 B After Width: | Height: | Size: 933 B |
|
Before Width: | Height: | Size: 830 B After Width: | Height: | Size: 830 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 539 B After Width: | Height: | Size: 539 B |
|
Before Width: | Height: | Size: 246 B After Width: | Height: | Size: 246 B |
|
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 236 B |
|
Before Width: | Height: | Size: 978 B After Width: | Height: | Size: 978 B |
|
Before Width: | Height: | Size: 874 B After Width: | Height: | Size: 874 B |
|
Before Width: | Height: | Size: 856 B After Width: | Height: | Size: 856 B |
|
Before Width: | Height: | Size: 878 B After Width: | Height: | Size: 878 B |
|
Before Width: | Height: | Size: 591 B After Width: | Height: | Size: 591 B |
|
Before Width: | Height: | Size: 936 B After Width: | Height: | Size: 936 B |
|
Before Width: | Height: | Size: 672 B After Width: | Height: | Size: 672 B |
|
Before Width: | Height: | Size: 502 B After Width: | Height: | Size: 502 B |
|
Before Width: | Height: | Size: 507 B After Width: | Height: | Size: 507 B |
|
Before Width: | Height: | Size: 395 B After Width: | Height: | Size: 395 B |
|
Before Width: | Height: | Size: 357 B After Width: | Height: | Size: 357 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
|
Before Width: | Height: | Size: 952 B After Width: | Height: | Size: 952 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 965 B After Width: | Height: | Size: 965 B |
|
Before Width: | Height: | Size: 303 B After Width: | Height: | Size: 303 B |
|
Before Width: | Height: | Size: 410 B After Width: | Height: | Size: 410 B |
|
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
|
Before Width: | Height: | Size: 260 B After Width: | Height: | Size: 260 B |
|
Before Width: | Height: | Size: 242 B After Width: | Height: | Size: 242 B |
|
Before Width: | Height: | Size: 366 B After Width: | Height: | Size: 366 B |
|
Before Width: | Height: | Size: 507 B After Width: | Height: | Size: 507 B |
|
Before Width: | Height: | Size: 555 B After Width: | Height: | Size: 555 B |
|
Before Width: | Height: | Size: 545 B After Width: | Height: | Size: 545 B |
|
Before Width: | Height: | Size: 542 B After Width: | Height: | Size: 542 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 772 B After Width: | Height: | Size: 772 B |
|
Before Width: | Height: | Size: 502 B After Width: | Height: | Size: 502 B |
|
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 233 B |
|
Before Width: | Height: | Size: 489 B After Width: | Height: | Size: 489 B |
|
Before Width: | Height: | Size: 219 B After Width: | Height: | Size: 219 B |
|
Before Width: | Height: | Size: 207 B After Width: | Height: | Size: 207 B |
|
Before Width: | Height: | Size: 182 B After Width: | Height: | Size: 182 B |
|
Before Width: | Height: | Size: 806 B After Width: | Height: | Size: 806 B |
|
Before Width: | Height: | Size: 161 B After Width: | Height: | Size: 161 B |
|
Before Width: | Height: | Size: 186 B After Width: | Height: | Size: 186 B |
|
Before Width: | Height: | Size: 264 B After Width: | Height: | Size: 264 B |
|
Before Width: | Height: | Size: 252 B After Width: | Height: | Size: 252 B |
|
Before Width: | Height: | Size: 927 B After Width: | Height: | Size: 927 B |
|
Before Width: | Height: | Size: 271 B After Width: | Height: | Size: 271 B |
|
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 216 B |
|
Before Width: | Height: | Size: 291 B After Width: | Height: | Size: 291 B |
|
Before Width: | Height: | Size: 931 B After Width: | Height: | Size: 931 B |