Compare commits
171 Commits
0.4.dev-20
...
0.4.dev-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
40
.gitignore
vendored
@@ -1,5 +1,27 @@
|
|||||||
map/*
|
## Generic ignorable patterns and files
|
||||||
world/*
|
*~
|
||||||
|
.*.swp
|
||||||
|
*bak*
|
||||||
|
tags
|
||||||
|
*.vim
|
||||||
|
|
||||||
|
## Non-static Minetest directories
|
||||||
|
bin/
|
||||||
|
games/
|
||||||
|
!games/mesetint
|
||||||
|
cache/
|
||||||
|
textures/
|
||||||
|
sounds/
|
||||||
|
mods/
|
||||||
|
!mods/mesetint/mods_here.txt
|
||||||
|
worlds/
|
||||||
|
world/
|
||||||
|
|
||||||
|
## Configuration/log files
|
||||||
|
minetest.conf
|
||||||
|
debug.txt
|
||||||
|
|
||||||
|
## Build files
|
||||||
CMakeFiles/*
|
CMakeFiles/*
|
||||||
src/CMakeFiles/*
|
src/CMakeFiles/*
|
||||||
src/Makefile
|
src/Makefile
|
||||||
@@ -9,19 +31,13 @@ src/jthread/CMakeFiles/*
|
|||||||
src/jthread/Makefile
|
src/jthread/Makefile
|
||||||
src/jthread/cmake_config.h
|
src/jthread/cmake_config.h
|
||||||
src/jthread/cmake_install.cmake
|
src/jthread/cmake_install.cmake
|
||||||
.*.swp
|
src/jthread/libjthread.a
|
||||||
minetest.conf
|
src/lua/build/
|
||||||
bin/
|
src/lua/CMakeFiles/
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
CPackConfig.cmake
|
CPackConfig.cmake
|
||||||
CPackSourceConfig.cmake
|
CPackSourceConfig.cmake
|
||||||
Makefile
|
Makefile
|
||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
src/jthread/libjthread.a
|
|
||||||
debug.txt
|
|
||||||
bin/debug.txt
|
|
||||||
minetestmapper/map.png
|
|
||||||
locale/
|
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
|
# Also remember to set PROTOCOL_VERSION in clientserver.h when releasing
|
||||||
set(VERSION_MAJOR 0)
|
set(VERSION_MAJOR 0)
|
||||||
set(VERSION_MINOR 4)
|
set(VERSION_MINOR 4)
|
||||||
set(VERSION_PATCH dev-20120106-1)
|
set(VERSION_PATCH dev-20120320)
|
||||||
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
||||||
|
|
||||||
MESSAGE(STATUS "*** Will build version ${VERSION_STRING} ***")
|
MESSAGE(STATUS "*** Will build version ${VERSION_STRING} ***")
|
||||||
@@ -49,26 +49,59 @@ find_package(Irrlicht)
|
|||||||
#
|
#
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(DATADIR "data")
|
set(SHAREDIR ".")
|
||||||
set(BINDIR "bin")
|
set(BINDIR "bin")
|
||||||
set(DOCDIR "doc")
|
set(DOCDIR "doc")
|
||||||
set(EXAMPLE_CONF_DIR ".")
|
set(EXAMPLE_CONF_DIR ".")
|
||||||
|
set(LOCALEDIR "locale")
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
# random placeholders
|
# Random placeholders; this isn't usually used and may not work
|
||||||
set(DATADIR "share/${PROJECT_NAME}")
|
# See https://github.com/toabi/minetest-mac/
|
||||||
|
set(SHAREDIR "share/${PROJECT_NAME}")
|
||||||
set(BINDIR "bin")
|
set(BINDIR "bin")
|
||||||
set(DOCDIR "share/doc/${PROJECT_NAME}")
|
set(DOCDIR "share/doc/${PROJECT_NAME}")
|
||||||
set(EXAMPLE_CONF_DIR ".")
|
set(EXAMPLE_CONF_DIR ${DOCDIR})
|
||||||
|
set(LOCALEDIR "locale")
|
||||||
elseif(UNIX) # Linux, BSD etc
|
elseif(UNIX) # Linux, BSD etc
|
||||||
set(DATADIR "share/${PROJECT_NAME}")
|
if(RUN_IN_PLACE)
|
||||||
set(BINDIR "bin")
|
set(SHAREDIR ".")
|
||||||
set(DOCDIR "share/doc/${PROJECT_NAME}")
|
set(BINDIR "bin")
|
||||||
set(EXAMPLE_CONF_DIR "share/doc/${PROJECT_NAME}")
|
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/mesetint" 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/mesetint/mods_here.txt" DESTINATION "${SHAREDIR}/mods/mesetint")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(FILES "README.txt" DESTINATION "${DOCDIR}")
|
install(FILES "README.txt" DESTINATION "${DOCDIR}")
|
||||||
install(FILES "doc/changelog.txt" DESTINATION "${DOCDIR}")
|
install(FILES "minetest.conf.example" DESTINATION "${EXAMPLE_CONF_DIR}")
|
||||||
install(FILES "minetest.conf.example" DESTINATION "${DOCDIR}")
|
|
||||||
|
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
|
# Subdirectories
|
||||||
|
|||||||
36
README.txt
@@ -1,7 +1,7 @@
|
|||||||
Minetest-c55
|
Minetest-c55
|
||||||
---------------
|
---------------
|
||||||
An InfiniMiner/Minecraft inspired game.
|
An InfiniMiner/Minecraft inspired game.
|
||||||
Copyright (c) 2010-2011 Perttu Ahola <celeron55@gmail.com>
|
Copyright (c) 2010-2012 Perttu Ahola <celeron55@gmail.com>
|
||||||
(see source files for other contributors)
|
(see source files for other contributors)
|
||||||
|
|
||||||
Further documentation:
|
Further documentation:
|
||||||
@@ -100,6 +100,7 @@ Compiling on Windows:
|
|||||||
- Make sure you have CMake and a compiler installed.
|
- Make sure you have CMake and a compiler installed.
|
||||||
- Download all the other stuff to DIR and extract them into there.
|
- Download all the other stuff to DIR and extract them into there.
|
||||||
("extract here", not "extract to packagename/")
|
("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
|
- All those packages contain a nice base directory in them, which
|
||||||
should end up being the direct subdirectories of DIR.
|
should end up being the direct subdirectories of DIR.
|
||||||
- You will end up with a directory structure like this (+=dir, -=file):
|
- You will end up with a directory structure like this (+=dir, -=file):
|
||||||
@@ -176,24 +177,37 @@ Compiling on Windows:
|
|||||||
If using MinGW:
|
If using MinGW:
|
||||||
- Using the command line, browse to the build directory and run 'make'
|
- Using the command line, browse to the build directory and run 'make'
|
||||||
(or mingw32-make or whatever it happens to be)
|
(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
|
- You should now have a working game with the executable in
|
||||||
DIR/minetest/bin/minetest.exe
|
DIR/minetest/bin/minetest.exe
|
||||||
|
|
||||||
Windows releases of minetest are built using a bat script like this:
|
Windows releases of minetest are built using a bat script like this:
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
|
|
||||||
|
set sourcedir=%CD%
|
||||||
set installpath="C:\tmp\minetest_install"
|
set installpath="C:\tmp\minetest_install"
|
||||||
set irrlichtpath="C:\tmp\irrlicht-1.7.2"
|
set irrlichtpath="C:\tmp\irrlicht-1.7.2"
|
||||||
|
|
||||||
set sourcedir=%CD%
|
|
||||||
set builddir=%sourcedir%\bvc10
|
set builddir=%sourcedir%\bvc10
|
||||||
mkdir %builddir%
|
mkdir %builddir%
|
||||||
pushd %builddir%
|
pushd %builddir%
|
||||||
cmake %sourcedir% -G "Visual Studio 10" -DIRRLICHT_SOURCE_DIR=%irrlichtpath% -DRUN_IN_PLACE=1 -DCMAKE_INSTALL_PREFIX=%installpath%
|
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
|
"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
|
"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
|
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" PACKAGE.vcxproj /p:Configuration=Release
|
||||||
|
if %errorlevel% neq 0 goto fail
|
||||||
popd
|
popd
|
||||||
|
echo Finished.
|
||||||
|
exit /b 0
|
||||||
|
|
||||||
|
:fail
|
||||||
|
popd
|
||||||
|
echo Failed.
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
License of Minetest-c55 textures and sounds
|
License of Minetest-c55 textures and sounds
|
||||||
-------------------------------------------
|
-------------------------------------------
|
||||||
@@ -277,3 +291,21 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|||||||
IN THE SOFTWARE.
|
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)
|
IF(GETTEXT_FOUND)
|
||||||
SET(GETTEXT_PO_PATH ${CMAKE_SOURCE_DIR}/po)
|
SET(GETTEXT_PO_PATH ${CMAKE_SOURCE_DIR}/po)
|
||||||
SET(GETTEXT_MO_BUILD_PATH ${CMAKE_BINARY_DIR}/locale/<locale>/LC_MESSAGES)
|
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}/*")
|
FILE(GLOB GETTEXT_AVAILABLE_LOCALES RELATIVE ${GETTEXT_PO_PATH} "${GETTEXT_PO_PATH}/*")
|
||||||
LIST(REMOVE_ITEM GETTEXT_AVAILABLE_LOCALES minetest.pot)
|
LIST(REMOVE_ITEM GETTEXT_AVAILABLE_LOCALES minetest.pot)
|
||||||
MACRO(SET_MO_PATHS _buildvar _destvar _locale)
|
MACRO(SET_MO_PATHS _buildvar _destvar _locale)
|
||||||
|
|||||||
441
data/builtin.lua
@@ -1,441 +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,
|
|
||||||
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",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
pointable = false,
|
|
||||||
diggable = false,
|
|
||||||
buildable_to = true,
|
|
||||||
air_equivalent = true,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("ignore", {
|
|
||||||
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,
|
|
||||||
})
|
|
||||||
|
|
||||||
--
|
|
||||||
-- stackstring manipulation functions
|
|
||||||
-- example stackstring: 'craft "apple" 4'
|
|
||||||
-- example item: {type="craft", name="apple"}
|
|
||||||
-- example item: {type="tool", 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]+)')
|
|
||||||
if stacktype == "node" or stacktype == "craft" then
|
|
||||||
local itemtype = nil
|
|
||||||
local itemname = nil
|
|
||||||
local itemcount = nil
|
|
||||||
itemtype, itemname, itemcount = string.match(stackstring,
|
|
||||||
'([%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 == "tool" then
|
|
||||||
local itemtype = nil
|
|
||||||
local itemname = nil
|
|
||||||
local itemwear = nil
|
|
||||||
itemtype, itemname, itemwear = string.match(stackstring,
|
|
||||||
'([%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]+)')
|
|
||||||
stacktype = stacktype or ''
|
|
||||||
if stacktype ~= '' and stacktype ~= item.type then
|
|
||||||
return stackstring, false
|
|
||||||
end
|
|
||||||
if item.type == "node" or item.type == "craft" then
|
|
||||||
local itemtype = nil
|
|
||||||
local itemname = nil
|
|
||||||
local itemcount = nil
|
|
||||||
itemtype, itemname, itemcount = string.match(stackstring,
|
|
||||||
'([%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 == "tool" 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]+) "([^"]*)" (%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('node "TNT" 3')
|
|
||||||
assert(stack == 'node "TNT" 2')
|
|
||||||
assert(item.type == 'node')
|
|
||||||
assert(item.name == 'TNT')
|
|
||||||
|
|
||||||
stack, item = stackstring_take_item('craft "with spaces" 2')
|
|
||||||
assert(stack == 'craft "with spaces" 1')
|
|
||||||
assert(item.type == 'craft')
|
|
||||||
assert(item.name == 'with spaces')
|
|
||||||
|
|
||||||
stack, item = stackstring_take_item('craft "with spaces" 1')
|
|
||||||
assert(stack == '')
|
|
||||||
assert(item.type == 'craft')
|
|
||||||
assert(item.name == 'with spaces')
|
|
||||||
|
|
||||||
stack, item = stackstring_take_item('craft "s8df2kj3" 0')
|
|
||||||
assert(stack == '')
|
|
||||||
assert(item == nil)
|
|
||||||
|
|
||||||
stack, item = stackstring_take_item('tool "With Spaces" 32487')
|
|
||||||
assert(stack == '')
|
|
||||||
assert(item.type == 'tool')
|
|
||||||
assert(item.name == 'With Spaces')
|
|
||||||
assert(item.wear == 32487)
|
|
||||||
|
|
||||||
stack, success = stackstring_put_item('node "With Spaces" 40',
|
|
||||||
{type='node', name='With Spaces'})
|
|
||||||
assert(stack == 'node "With Spaces" 41')
|
|
||||||
assert(success == true)
|
|
||||||
|
|
||||||
stack, success = stackstring_put_item('craft "With Spaces" 40',
|
|
||||||
{type='craft', name='With Spaces'})
|
|
||||||
assert(stack == 'craft "With Spaces" 41')
|
|
||||||
assert(success == true)
|
|
||||||
|
|
||||||
stack, success = stackstring_put_item('tool "With Spaces" 32487',
|
|
||||||
{type='tool', name='With Spaces'})
|
|
||||||
assert(stack == 'tool "With Spaces" 32487')
|
|
||||||
assert(success == false)
|
|
||||||
|
|
||||||
stack, success = stackstring_put_item('node "With Spaces" 40',
|
|
||||||
{type='tool', name='With Spaces'})
|
|
||||||
assert(stack == 'node "With Spaces" 40')
|
|
||||||
assert(success == false)
|
|
||||||
|
|
||||||
assert(stackstring_put_stackstring('node "With Spaces" 2',
|
|
||||||
'node "With Spaces" 1') == 'node "With Spaces" 3')
|
|
||||||
end
|
|
||||||
test_stackstring()
|
|
||||||
|
|
||||||
--
|
|
||||||
-- NodeItem helpers
|
|
||||||
--
|
|
||||||
|
|
||||||
minetest.inventorycube = function(img1, img2, img3)
|
|
||||||
img2 = img2 or img1
|
|
||||||
img3 = img3 or img1
|
|
||||||
return "[inventorycube"
|
|
||||||
.. "{" .. img1:gsub("%^", "&")
|
|
||||||
.. "{" .. img2:gsub("%^", "&")
|
|
||||||
.. "{" .. img3:gsub("%^", "&")
|
|
||||||
end
|
|
||||||
|
|
||||||
--
|
|
||||||
-- 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, 'craft "' .. 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
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Default material types
|
|
||||||
--
|
|
||||||
|
|
||||||
function minetest.digprop_constanttime(time)
|
|
||||||
return {
|
|
||||||
diggability = "constant",
|
|
||||||
constant_time = time,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function minetest.digprop_stonelike(toughness)
|
|
||||||
return {
|
|
||||||
diggablity = "normal",
|
|
||||||
weight = toughness * 5,
|
|
||||||
crackiness = 1,
|
|
||||||
crumbliness = -0.1,
|
|
||||||
cuttability = -0.2,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function minetest.digprop_dirtlike(toughness)
|
|
||||||
return {
|
|
||||||
diggablity = "normal",
|
|
||||||
weight = toughness * 1.2,
|
|
||||||
crackiness = 0,
|
|
||||||
crumbliness = 1.2,
|
|
||||||
cuttability = -0.4,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function minetest.digprop_gravellike(toughness)
|
|
||||||
return {
|
|
||||||
diggablity = "normal",
|
|
||||||
weight = toughness * 2,
|
|
||||||
crackiness = 0.2,
|
|
||||||
crumbliness = 1.5,
|
|
||||||
cuttability = -1.0,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function minetest.digprop_woodlike(toughness)
|
|
||||||
return {
|
|
||||||
diggablity = "normal",
|
|
||||||
weight = toughness * 1.0,
|
|
||||||
crackiness = 0.75,
|
|
||||||
crumbliness = -1.0,
|
|
||||||
cuttability = 1.5,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function minetest.digprop_leaveslike(toughness)
|
|
||||||
return {
|
|
||||||
diggablity = "normal",
|
|
||||||
weight = toughness * (-0.5),
|
|
||||||
crackiness = 0,
|
|
||||||
crumbliness = 0,
|
|
||||||
cuttability = 2.0,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function minetest.digprop_glasslike(toughness)
|
|
||||||
return {
|
|
||||||
diggablity = "normal",
|
|
||||||
weight = toughness * 0.1,
|
|
||||||
crackiness = 2.0,
|
|
||||||
crumbliness = -1.0,
|
|
||||||
cuttability = -1.0,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Creative inventory
|
|
||||||
--
|
|
||||||
|
|
||||||
minetest.creative_inventory = {}
|
|
||||||
|
|
||||||
minetest.add_to_creative_inventory = function(itemstring)
|
|
||||||
table.insert(minetest.creative_inventory, itemstring)
|
|
||||||
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_dieplayers, minetest.register_on_dieplayer = make_registration()
|
|
||||||
minetest.registered_on_respawnplayers, minetest.register_on_respawnplayer = make_registration()
|
|
||||||
|
|
||||||
-- END
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
-- bucket (Minetest 0.4 mod)
|
|
||||||
-- A bucket, which can pick up water and lava
|
|
||||||
|
|
||||||
minetest.alias_craftitem("bucket", "bucket:bucket_empty")
|
|
||||||
minetest.alias_craftitem("bucket_water", "bucket:bucket_water")
|
|
||||||
minetest.alias_craftitem("bucket_lava", "bucket:bucket_lava")
|
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = 'craft "bucket:bucket_empty" 1',
|
|
||||||
recipe = {
|
|
||||||
{'craft "steel_ingot"', '', 'craft "steel_ingot"'},
|
|
||||||
{'', 'craft "steel_ingot"', ''},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craftitem("bucket:bucket_empty", {
|
|
||||||
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 == "default:water_source" then
|
|
||||||
minetest.env:add_node(pointed_thing.under, {name="air"})
|
|
||||||
player:add_to_inventory_later('craft "bucket:bucket_water" 1')
|
|
||||||
return true
|
|
||||||
elseif n.name == "default:lava_source" then
|
|
||||||
minetest.env:add_node(pointed_thing.under, {name="air"})
|
|
||||||
player:add_to_inventory_later('craft "bucket:bucket_lava" 1')
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craftitem("bucket: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 == "default:water_source" then
|
|
||||||
-- unchanged
|
|
||||||
elseif n.name == "default:water_flowing" or n.name == "default:lava_source" or n.name == "default:lava_flowing" then
|
|
||||||
minetest.env:add_node(pointed_thing.under, {name="default:water_source"})
|
|
||||||
else
|
|
||||||
minetest.env:add_node(pointed_thing.above, {name="default:water_source"})
|
|
||||||
end
|
|
||||||
player:add_to_inventory_later('craft "bucket:bucket_empty" 1')
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craftitem("bucket: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 == "default:lava_source" then
|
|
||||||
-- unchanged
|
|
||||||
elseif n.name == "default:water_source" or n.name == "default:water_flowing" or n.name == "default:lava_flowing" then
|
|
||||||
minetest.env:add_node(pointed_thing.under, {name="default:lava_source"})
|
|
||||||
else
|
|
||||||
minetest.env:add_node(pointed_thing.above, {name="default:lava_source"})
|
|
||||||
end
|
|
||||||
player:add_to_inventory_later('craft "bucket:bucket_empty" 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,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('tool "SteelPick" 0')
|
|
||||||
player:add_to_inventory('node "torch" 99')
|
|
||||||
player:add_to_inventory('tool "SteelAxe" 0')
|
|
||||||
player:add_to_inventory('tool "SteelShovel" 0')
|
|
||||||
player:add_to_inventory('node "cobble" 99')
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
-- legacy (Minetest 0.4 mod)
|
|
||||||
-- Provides as much backwards-compatibility as feasible
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Aliases to support loading 0.3 and old 0.4 worlds and inventories
|
|
||||||
--
|
|
||||||
|
|
||||||
minetest.alias_node("stone", "default:stone")
|
|
||||||
minetest.alias_node("dirt_with_grass", "default:dirt_with_grass")
|
|
||||||
minetest.alias_node("dirt_with_grass_footsteps", "default:dirt_with_grass_footsteps")
|
|
||||||
minetest.alias_node("dirt", "default:dirt")
|
|
||||||
minetest.alias_node("sand", "default:sand")
|
|
||||||
minetest.alias_node("gravel", "default:gravel")
|
|
||||||
minetest.alias_node("sandstone", "default:sandstone")
|
|
||||||
minetest.alias_node("clay", "default:clay")
|
|
||||||
minetest.alias_node("brick", "default:brick")
|
|
||||||
minetest.alias_node("tree", "default:tree")
|
|
||||||
minetest.alias_node("jungletree", "default:jungletree")
|
|
||||||
minetest.alias_node("junglegrass", "default:junglegrass")
|
|
||||||
minetest.alias_node("leaves", "default:leaves")
|
|
||||||
minetest.alias_node("cactus", "default:cactus")
|
|
||||||
minetest.alias_node("papyrus", "default:papyrus")
|
|
||||||
minetest.alias_node("bookshelf", "default:bookshelf")
|
|
||||||
minetest.alias_node("glass", "default:glass")
|
|
||||||
minetest.alias_node("wooden_fence", "default:fence_wood")
|
|
||||||
minetest.alias_node("rail", "default:rail")
|
|
||||||
minetest.alias_node("ladder", "default:ladder")
|
|
||||||
minetest.alias_node("wood", "default:wood")
|
|
||||||
minetest.alias_node("mese", "default:mese")
|
|
||||||
minetest.alias_node("cloud", "default:cloud")
|
|
||||||
minetest.alias_node("water_flowing", "default:water_flowing")
|
|
||||||
minetest.alias_node("water_source", "default:water_source")
|
|
||||||
minetest.alias_node("lava_flowing", "default:lava_flowing")
|
|
||||||
minetest.alias_node("lava_source", "default:lava_source")
|
|
||||||
minetest.alias_node("torch", "default:torch")
|
|
||||||
minetest.alias_node("sign_wall", "default:sign_wall")
|
|
||||||
minetest.alias_node("furnace", "default:furnace")
|
|
||||||
minetest.alias_node("chest", "default:chest")
|
|
||||||
minetest.alias_node("locked_chest", "default:chest_locked")
|
|
||||||
minetest.alias_node("cobble", "default:cobble")
|
|
||||||
minetest.alias_node("mossycobble", "default:mossycobble")
|
|
||||||
minetest.alias_node("steelblock", "default:steelblock")
|
|
||||||
minetest.alias_node("nyancat", "default:nyancat")
|
|
||||||
minetest.alias_node("nyancat_rainbow", "default:nyancat_rainbow")
|
|
||||||
minetest.alias_node("sapling", "default:sapling")
|
|
||||||
minetest.alias_node("apple", "default:apple")
|
|
||||||
|
|
||||||
minetest.alias_tool("WPick", "default:pick_wood")
|
|
||||||
minetest.alias_tool("STPick", "default:pick_stone")
|
|
||||||
minetest.alias_tool("SteelPick", "default:pick_steel")
|
|
||||||
minetest.alias_tool("MesePick", "default:pick_mese")
|
|
||||||
minetest.alias_tool("WShovel", "default:shovel_wood")
|
|
||||||
minetest.alias_tool("STShovel", "default:shovel_stone")
|
|
||||||
minetest.alias_tool("SteelShovel", "default:shovel_steel")
|
|
||||||
minetest.alias_tool("WAxe", "default:axe_wood")
|
|
||||||
minetest.alias_tool("STAxe", "default:axe_stone")
|
|
||||||
minetest.alias_tool("SteelAxe", "default:axe_steel")
|
|
||||||
minetest.alias_tool("WSword", "default:sword_wood")
|
|
||||||
minetest.alias_tool("STSword", "default:sword_stone")
|
|
||||||
minetest.alias_tool("SteelSword", "default:sword_steel")
|
|
||||||
|
|
||||||
minetest.alias_craftitem("Stick", "default:stick")
|
|
||||||
minetest.alias_craftitem("paper", "default:paper")
|
|
||||||
minetest.alias_craftitem("book", "default:book")
|
|
||||||
minetest.alias_craftitem("lump_of_coal", "default:coal_lump")
|
|
||||||
minetest.alias_craftitem("lump_of_iron", "default:iron_lump")
|
|
||||||
minetest.alias_craftitem("lump_of_clay", "default:clay_lump")
|
|
||||||
minetest.alias_craftitem("steel_ingot", "default:steel_ingot")
|
|
||||||
minetest.alias_craftitem("clay_brick", "default:clay_brick")
|
|
||||||
minetest.alias_craftitem("scorched_stuff", "default:scorched_stuff")
|
|
||||||
minetest.alias_craftitem("apple", "default:apple")
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Old items
|
|
||||||
--
|
|
||||||
|
|
||||||
minetest.register_craftitem(":rat", {
|
|
||||||
image = "rat.png",
|
|
||||||
cookresult_itemstring = 'craft "cooked_rat" 1',
|
|
||||||
on_drop = function(item, dropper, pos)
|
|
||||||
minetest.env:add_rat(pos)
|
|
||||||
return true
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craftitem(":cooked_rat", {
|
|
||||||
image = "cooked_rat.png",
|
|
||||||
cookresult_itemstring = 'craft "scorched_stuff" 1',
|
|
||||||
on_place_on_ground = minetest.craftitem_place_item,
|
|
||||||
on_use = minetest.craftitem_eat(6),
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craftitem(":firefly", {
|
|
||||||
image = "firefly.png",
|
|
||||||
on_drop = function(item, dropper, pos)
|
|
||||||
minetest.env:add_firefly(pos)
|
|
||||||
return true
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- END
|
|
||||||
85
doc/minetest.6
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
.\" 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
|
||||||
|
\-\-verbose
|
||||||
|
Print more 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)
|
||||||
64
doc/minetestserver.6
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
.\" 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
|
||||||
|
\-\-verbose
|
||||||
|
Print more 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)
|
||||||
95
games/mesetint/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 |
|
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 |
|
Before Width: | Height: | Size: 262 B After Width: | Height: | Size: 262 B |
|
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
|
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 301 B |
|
Before Width: | Height: | Size: 927 B After Width: | Height: | Size: 927 B |
|
Before Width: | Height: | Size: 245 B After Width: | Height: | Size: 245 B |