Added all the files from minetest
|
@ -0,0 +1,123 @@
|
||||||
|
cmake_minimum_required(VERSION 2.6)
|
||||||
|
if(${CMAKE_VERSION} STREQUAL "2.8.2")
|
||||||
|
# bug http://vtk.org/Bug/view.php?id=11020
|
||||||
|
message( WARNING "CMake/CPack version 2.8.2 will not create working .deb packages!")
|
||||||
|
endif(${CMAKE_VERSION} STREQUAL "2.8.2")
|
||||||
|
|
||||||
|
# This can be read from ${PROJECT_NAME} after project() is called
|
||||||
|
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-20120122-1)
|
||||||
|
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
||||||
|
|
||||||
|
MESSAGE(STATUS "*** Will build version ${VERSION_STRING} ***")
|
||||||
|
|
||||||
|
# Configuration options
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(RUN_IN_PLACE 1 CACHE BOOL "Run directly in source directory structure")
|
||||||
|
else()
|
||||||
|
set(RUN_IN_PLACE 0 CACHE BOOL "Run directly in source directory structure")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(BUILD_CLIENT 1 CACHE BOOL "Build client")
|
||||||
|
if(WIN32)
|
||||||
|
set(BUILD_SERVER 0 CACHE BOOL "Build server")
|
||||||
|
else()
|
||||||
|
set(BUILD_SERVER 1 CACHE BOOL "Build server")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(WARN_ALL 1 CACHE BOOL "Enable -Wall for Release build")
|
||||||
|
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
# Default to release
|
||||||
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Included stuff
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
||||||
|
include(${CMAKE_SOURCE_DIR}/cmake/Modules/misc.cmake)
|
||||||
|
|
||||||
|
# This is done here so that relative search paths are more reasnable
|
||||||
|
find_package(Irrlicht)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Installation
|
||||||
|
#
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(DATADIR "data")
|
||||||
|
set(BINDIR "bin")
|
||||||
|
set(DOCDIR "doc")
|
||||||
|
set(EXAMPLE_CONF_DIR ".")
|
||||||
|
elseif(APPLE)
|
||||||
|
# random placeholders
|
||||||
|
set(DATADIR "share/${PROJECT_NAME}")
|
||||||
|
set(BINDIR "bin")
|
||||||
|
set(DOCDIR "share/doc/${PROJECT_NAME}")
|
||||||
|
set(EXAMPLE_CONF_DIR ".")
|
||||||
|
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}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(FILES "README.txt" DESTINATION "${DOCDIR}")
|
||||||
|
install(FILES "doc/changelog.txt" DESTINATION "${DOCDIR}")
|
||||||
|
install(FILES "minetest.conf.example" DESTINATION "${DOCDIR}")
|
||||||
|
|
||||||
|
#
|
||||||
|
# Subdirectories
|
||||||
|
# Be sure to add all relevant definitions above this
|
||||||
|
#
|
||||||
|
|
||||||
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
# CPack
|
||||||
|
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An InfiniMiner/Minecraft inspired game")
|
||||||
|
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
|
||||||
|
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
|
||||||
|
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
|
||||||
|
set(CPACK_PACKAGE_VENDOR "celeron55")
|
||||||
|
set(CPACK_PACKAGE_CONTACT "Perttu Ahola <celeron55@gmail.com>")
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
# For some reason these aren't copied otherwise
|
||||||
|
# NOTE: For some reason now it seems to work without these
|
||||||
|
#if(BUILD_CLIENT)
|
||||||
|
# install(FILES bin/minetest.exe DESTINATION bin)
|
||||||
|
#endif()
|
||||||
|
#if(BUILD_SERVER)
|
||||||
|
# install(FILES bin/minetestserver.exe DESTINATION bin)
|
||||||
|
#endif()
|
||||||
|
|
||||||
|
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32")
|
||||||
|
|
||||||
|
set(CPACK_GENERATOR ZIP)
|
||||||
|
|
||||||
|
# This might be needed for some installer
|
||||||
|
#set(CPACK_PACKAGE_EXECUTABLES bin/minetest.exe "Minetest" bin/minetestserver.exe "Minetest Server")
|
||||||
|
elseif(APPLE)
|
||||||
|
# TODO
|
||||||
|
# see http://cmake.org/Wiki/CMake:CPackPackageGenerators#Bundle_.28OSX_only.29
|
||||||
|
#
|
||||||
|
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-osx")
|
||||||
|
set(CPACK_PACKAGE_ICON "")
|
||||||
|
set(CPACK_BUNDLE_NAME ${PROJECT_NAME})
|
||||||
|
set(CPACK_BUNDLE_ICON "")
|
||||||
|
set(CPACK_BUNDLE_PLIST "")
|
||||||
|
set(CPACK_BUNDLE_STARTUP_COMMAND "Contents/MacOS/${PROJECT_NAME}")
|
||||||
|
set(CPACK_GENERATOR "Bundle")
|
||||||
|
else()
|
||||||
|
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-linux")
|
||||||
|
set(CPACK_GENERATOR TGZ)
|
||||||
|
set(CPACK_SOURCE_GENERATOR TGZ)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CPack)
|
||||||
|
|
|
@ -0,0 +1,279 @@
|
||||||
|
Minetest-c55
|
||||||
|
---------------
|
||||||
|
An InfiniMiner/Minecraft inspired game.
|
||||||
|
Copyright (c) 2010-2011 Perttu Ahola <celeron55@gmail.com>
|
||||||
|
(see source files for other contributors)
|
||||||
|
|
||||||
|
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/
|
||||||
|
- doc/ directory of source distribution
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
Controls:
|
||||||
|
---------
|
||||||
|
- See the in-game pause menu
|
||||||
|
- 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
|
||||||
|
|
||||||
|
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:
|
||||||
|
--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:
|
||||||
|
---------------------
|
||||||
|
- Use --help
|
||||||
|
|
||||||
|
Compiling on GNU/Linux:
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
Install dependencies. Here's an example for Debian/Ubuntu:
|
||||||
|
$ apt-get install build-essential libirrlicht-dev cmake libbz2-dev libpng12-dev libjpeg8-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev
|
||||||
|
|
||||||
|
Download source, extract (this is the URL to the latest of source repository, which might not work at all times):
|
||||||
|
$ wget https://github.com/celeron55/minetest/tarball/master -O master.tar.gz
|
||||||
|
$ tar xf master.tar.gz
|
||||||
|
$ cd celeron55-minetest-286edd4 (or similar)
|
||||||
|
|
||||||
|
Build a version that runs directly from the source directory:
|
||||||
|
$ cmake . -DRUN_IN_PLACE=1
|
||||||
|
$ make -j2
|
||||||
|
|
||||||
|
Run it:
|
||||||
|
$ cd bin
|
||||||
|
$ ./minetest
|
||||||
|
|
||||||
|
- Use cmake . -LH to see all CMake options and their current state
|
||||||
|
- If you want to install it system-wide (or are making a distribution package), you will want to use -DRUN_IN_PLACE=0
|
||||||
|
- You can build a bare server or a bare client by specifying -DBUILD_CLIENT=0 or -DBUILD_SERVER=0
|
||||||
|
- You can select between Release and Debug build by -DCMAKE_BUILD_TYPE=<Debug or Release>
|
||||||
|
- Debug build is slower, but gives much more useful output in a debugger
|
||||||
|
|
||||||
|
Compiling on Windows:
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
- You need:
|
||||||
|
* CMake:
|
||||||
|
http://www.cmake.org/cmake/resources/software.html
|
||||||
|
* MinGW or Visual Studio
|
||||||
|
http://www.mingw.org/
|
||||||
|
http://msdn.microsoft.com/en-us/vstudio/default
|
||||||
|
* Irrlicht SDK 1.7:
|
||||||
|
http://irrlicht.sourceforge.net/downloads.html
|
||||||
|
* Zlib headers (zlib125.zip)
|
||||||
|
http://www.winimage.com/zLibDll/index.html
|
||||||
|
* Zlib library (zlibwapi.lib and zlibwapi.dll from zlib125dll.zip):
|
||||||
|
http://www.winimage.com/zLibDll/index.html
|
||||||
|
* Optional: gettext bibrary and tools:
|
||||||
|
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
|
||||||
|
- 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/")
|
||||||
|
- 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):
|
||||||
|
-----------------
|
||||||
|
+ DIR
|
||||||
|
- zlib-1.2.5.tar.gz
|
||||||
|
- zlib125dll.zip
|
||||||
|
- irrlicht-1.7.1.zip
|
||||||
|
- 110214175330.zip (or whatever, this is the minetest source)
|
||||||
|
+ zlib-1.2.5
|
||||||
|
- zlib.h
|
||||||
|
+ win32
|
||||||
|
...
|
||||||
|
+ zlib125dll
|
||||||
|
- readme.txt
|
||||||
|
+ dll32
|
||||||
|
...
|
||||||
|
+ irrlicht-1.7.1
|
||||||
|
+ lib
|
||||||
|
+ include
|
||||||
|
...
|
||||||
|
+ gettext (optional)
|
||||||
|
+bin
|
||||||
|
+include
|
||||||
|
+lib
|
||||||
|
+ minetest
|
||||||
|
+ src
|
||||||
|
+ doc
|
||||||
|
- CMakeLists.txt
|
||||||
|
...
|
||||||
|
-----------------
|
||||||
|
- Start up the CMake GUI
|
||||||
|
- Select "Browse Source..." and select DIR/minetest
|
||||||
|
- Now, if using MSVC:
|
||||||
|
- Select "Browse Build..." and select DIR/minetest-build
|
||||||
|
- Else if using MinGW:
|
||||||
|
- Select "Browse Build..." and select DIR/minetest
|
||||||
|
- Select "Configure"
|
||||||
|
- Select your compiler
|
||||||
|
- It will warn about missing stuff, ignore that at this point. (later don't)
|
||||||
|
- Make sure the configuration is as follows
|
||||||
|
(note that the versions may differ for you):
|
||||||
|
-----------------
|
||||||
|
BUILD_CLIENT [X]
|
||||||
|
BUILD_SERVER [ ]
|
||||||
|
CMAKE_BUILD_TYPE Release
|
||||||
|
CMAKE_INSTALL_PREFIX DIR/minetest-install
|
||||||
|
IRRLICHT_SOURCE_DIR DIR/irrlicht-1.7.1
|
||||||
|
RUN_IN_PLACE [X]
|
||||||
|
WARN_ALL [ ]
|
||||||
|
ZLIB_DLL DIR/zlib125dll/dll32/zlibwapi.dll
|
||||||
|
ZLIB_INCLUDE_DIR DIR/zlib-1.2.5
|
||||||
|
ZLIB_LIBRARIES DIR/zlib125dll/dll32/zlibwapi.lib
|
||||||
|
GETTEXT_BIN_DIR DIR/gettext/bin
|
||||||
|
GETTEXT_INCLUDE_DIR DIR/gettext/include
|
||||||
|
GETTEXT_LIBRARIES DIR/gettext/lib/intl.lib
|
||||||
|
GETTEXT_MSGFMT DIR/gettext/bin/msgfmt
|
||||||
|
-----------------
|
||||||
|
- Hit "Configure"
|
||||||
|
- Hit "Configure" once again 8)
|
||||||
|
- If something is still coloured red, you have a problem.
|
||||||
|
- Hit "Generate"
|
||||||
|
If using MSVC:
|
||||||
|
- Open the generated minetest.sln
|
||||||
|
- The project defaults to the "Debug" configuration. Make very sure to
|
||||||
|
select "Release", unless you want to debug some stuff (it's slower
|
||||||
|
and might not even work at all)
|
||||||
|
- Build the ALL_BUILD project
|
||||||
|
- Build the INSTALL project
|
||||||
|
- You should now have a working game with the executable in
|
||||||
|
DIR/minetest-install/bin/minetest.exe
|
||||||
|
- Additionally you may create a zip package by building the PACKAGE
|
||||||
|
project.
|
||||||
|
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 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 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%
|
||||||
|
"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" INSTALL.vcxproj /p:Configuration=Release
|
||||||
|
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" PACKAGE.vcxproj /p:Configuration=Release
|
||||||
|
popd
|
||||||
|
|
||||||
|
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 source code
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
Minetest-c55
|
||||||
|
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
Irrlicht
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This program uses the Irrlicht Engine. http://irrlicht.sourceforge.net/
|
||||||
|
|
||||||
|
The Irrlicht Engine License
|
||||||
|
|
||||||
|
Copyright © 2002-2005 Nikolaus Gebhardt
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute
|
||||||
|
it freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you
|
||||||
|
must not claim that you wrote the original software. If you use
|
||||||
|
this software in a product, an acknowledgment in the product
|
||||||
|
documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must
|
||||||
|
not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
|
||||||
|
JThread
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This program uses the JThread library. License for JThread follows:
|
||||||
|
|
||||||
|
Copyright (c) 2000-2006 Jori Liesenborgs (jori.liesenborgs@gmail.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
to deal in the Software without restriction, including without limitation
|
||||||
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included
|
||||||
|
in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
IN THE SOFTWARE.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
# Package finder for gettext libs and include files
|
||||||
|
|
||||||
|
SET(CUSTOM_GETTEXT_PATH "${PROJECT_SOURCE_DIR}/../../gettext"
|
||||||
|
CACHE FILEPATH "path to custom gettext")
|
||||||
|
|
||||||
|
# by default
|
||||||
|
SET(GETTEXT_FOUND FALSE)
|
||||||
|
|
||||||
|
FIND_PATH(GETTEXT_INCLUDE_DIR
|
||||||
|
NAMES libintl.h
|
||||||
|
PATHS "${CUSTOM_GETTEXT_PATH}/include"
|
||||||
|
DOC "gettext include directory")
|
||||||
|
|
||||||
|
FIND_PROGRAM(GETTEXT_MSGFMT
|
||||||
|
NAMES msgfmt
|
||||||
|
PATHS "${CUSTOM_GETTEXT_PATH}/bin"
|
||||||
|
DOC "path to msgfmt")
|
||||||
|
|
||||||
|
# modern Linux, as well as Mac, seem to not need require special linking
|
||||||
|
# they do not because gettext is part of glibc
|
||||||
|
# TODO check the requirements on other BSDs and older Linux
|
||||||
|
IF (WIN32)
|
||||||
|
IF(MSVC)
|
||||||
|
SET(GETTEXT_LIB_NAMES
|
||||||
|
libintl.lib intl.lib libintl3.lib intl3.lib)
|
||||||
|
ELSE()
|
||||||
|
SET(GETTEXT_LIB_NAMES
|
||||||
|
libintl.dll.a intl.dll.a libintl3.dll.a intl3.dll.a)
|
||||||
|
ENDIF()
|
||||||
|
FIND_LIBRARY(GETTEXT_LIBRARY
|
||||||
|
NAMES ${GETTEXT_LIB_NAMES}
|
||||||
|
PATHS "${CUSTOM_GETTEXT_PATH}/lib"
|
||||||
|
DOC "gettext *intl*.lib")
|
||||||
|
FIND_FILE(GETTEXT_DLL
|
||||||
|
NAMES libintl.dll intl.dll libintl3.dll intl3.dll
|
||||||
|
PATHS "${CUSTOM_GETTEXT_PATH}/bin" "${CUSTOM_GETTEXT_PATH}/lib"
|
||||||
|
DOC "gettext *intl*.dll")
|
||||||
|
FIND_FILE(GETTEXT_ICONV_DLL
|
||||||
|
NAMES libiconv2.dll
|
||||||
|
PATHS "${CUSTOM_GETTEXT_PATH}/bin" "${CUSTOM_GETTEXT_PATH}/lib"
|
||||||
|
DOC "gettext *iconv*.lib")
|
||||||
|
ENDIF(WIN32)
|
||||||
|
|
||||||
|
IF(GETTEXT_INCLUDE_DIR AND GETTEXT_MSGFMT)
|
||||||
|
IF (WIN32)
|
||||||
|
# in the Win32 case check also for the extra linking requirements
|
||||||
|
IF(GETTEXT_LIBRARY AND GETTEXT_DLL AND GETTEXT_ICONV_DLL)
|
||||||
|
SET(GETTEXT_FOUND TRUE)
|
||||||
|
ENDIF()
|
||||||
|
ELSE(WIN32)
|
||||||
|
# *BSD variants require special linkage as they don't use glibc
|
||||||
|
IF(${CMAKE_SYSTEM_NAME} MATCHES "BSD")
|
||||||
|
SET(GETTEXT_LIBRARY "intl")
|
||||||
|
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "BSD")
|
||||||
|
SET(GETTEXT_FOUND TRUE)
|
||||||
|
ENDIF(WIN32)
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
STRING(REPLACE "<locale>" ${_locale} ${_buildvar} ${GETTEXT_MO_BUILD_PATH})
|
||||||
|
STRING(REPLACE "<locale>" ${_locale} ${_destvar} ${GETTEXT_MO_DEST_PATH})
|
||||||
|
ENDMACRO(SET_MO_PATHS)
|
||||||
|
ELSE()
|
||||||
|
SET(GETTEXT_INCLUDE_DIR "")
|
||||||
|
SET(GETTEXT_LIBRARY "")
|
||||||
|
ENDIF()
|
|
@ -0,0 +1,94 @@
|
||||||
|
#FindIrrlicht.cmake
|
||||||
|
|
||||||
|
set(IRRLICHT_SOURCE_DIR "" CACHE PATH "Path to irrlicht source directory (optional)")
|
||||||
|
|
||||||
|
if( UNIX )
|
||||||
|
# Unix
|
||||||
|
else( UNIX )
|
||||||
|
# Windows
|
||||||
|
endif( UNIX )
|
||||||
|
|
||||||
|
# Find include directory
|
||||||
|
|
||||||
|
if(NOT IRRLICHT_SOURCE_DIR STREQUAL "")
|
||||||
|
set(IRRLICHT_SOURCE_DIR_INCLUDE
|
||||||
|
"${IRRLICHT_SOURCE_DIR}/include"
|
||||||
|
)
|
||||||
|
|
||||||
|
set(IRRLICHT_LIBRARY_NAMES libIrrlicht.a Irrlicht Irrlicht.lib)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
if(MSVC)
|
||||||
|
set(IRRLICHT_SOURCE_DIR_LIBS "${IRRLICHT_SOURCE_DIR}/lib/Win32-visualstudio")
|
||||||
|
set(IRRLICHT_LIBRARY_NAMES Irrlicht.lib)
|
||||||
|
else()
|
||||||
|
set(IRRLICHT_SOURCE_DIR_LIBS "${IRRLICHT_SOURCE_DIR}/lib/Win32-gcc")
|
||||||
|
set(IRRLICHT_LIBRARY_NAMES libIrrlicht.a libIrrlicht.dll.a)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(IRRLICHT_SOURCE_DIR_LIBS "${IRRLICHT_SOURCE_DIR}/lib/Linux")
|
||||||
|
set(IRRLICHT_LIBRARY_NAMES libIrrlicht.a)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
FIND_PATH(IRRLICHT_INCLUDE_DIR NAMES irrlicht.h
|
||||||
|
PATHS
|
||||||
|
${IRRLICHT_SOURCE_DIR_INCLUDE}
|
||||||
|
NO_DEFAULT_PATH
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_LIBRARY(IRRLICHT_LIBRARY NAMES ${IRRLICHT_LIBRARY_NAMES}
|
||||||
|
PATHS
|
||||||
|
${IRRLICHT_SOURCE_DIR_LIBS}
|
||||||
|
NO_DEFAULT_PATH
|
||||||
|
)
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
|
FIND_PATH(IRRLICHT_INCLUDE_DIR NAMES irrlicht.h
|
||||||
|
PATHS
|
||||||
|
/usr/local/include/irrlicht
|
||||||
|
/usr/include/irrlicht
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_LIBRARY(IRRLICHT_LIBRARY NAMES libIrrlicht.a Irrlicht
|
||||||
|
PATHS
|
||||||
|
/usr/local/lib
|
||||||
|
/usr/lib
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
MESSAGE(STATUS "IRRLICHT_SOURCE_DIR = ${IRRLICHT_SOURCE_DIR}")
|
||||||
|
MESSAGE(STATUS "IRRLICHT_INCLUDE_DIR = ${IRRLICHT_INCLUDE_DIR}")
|
||||||
|
MESSAGE(STATUS "IRRLICHT_LIBRARY = ${IRRLICHT_LIBRARY}")
|
||||||
|
|
||||||
|
# On windows, find the dll for installation
|
||||||
|
if(WIN32)
|
||||||
|
if(MSVC)
|
||||||
|
FIND_FILE(IRRLICHT_DLL NAMES Irrlicht.dll
|
||||||
|
PATHS
|
||||||
|
"${IRRLICHT_SOURCE_DIR}/bin/Win32-VisualStudio"
|
||||||
|
DOC "Path of the Irrlicht dll (for installation)"
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
FIND_FILE(IRRLICHT_DLL NAMES Irrlicht.dll
|
||||||
|
PATHS
|
||||||
|
"${IRRLICHT_SOURCE_DIR}/bin/Win32-gcc"
|
||||||
|
DOC "Path of the Irrlicht dll (for installation)"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
MESSAGE(STATUS "IRRLICHT_DLL = ${IRRLICHT_DLL}")
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set IRRLICHT_FOUND to TRUE if
|
||||||
|
# all listed variables are TRUE
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(IRRLICHT DEFAULT_MSG IRRLICHT_LIBRARY IRRLICHT_INCLUDE_DIR)
|
||||||
|
|
||||||
|
IF(IRRLICHT_FOUND)
|
||||||
|
SET(IRRLICHT_LIBRARIES ${IRRLICHT_LIBRARY})
|
||||||
|
ELSE(IRRLICHT_FOUND)
|
||||||
|
SET(IRRLICHT_LIBRARIES)
|
||||||
|
ENDIF(IRRLICHT_FOUND)
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED(IRRLICHT_LIBRARY IRRLICHT_INCLUDE_DIR IRRLICHT_DLL)
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Look for jthread, use our own if not found
|
||||||
|
|
||||||
|
FIND_PATH(JTHREAD_INCLUDE_DIR jthread.h)
|
||||||
|
|
||||||
|
FIND_LIBRARY(JTHREAD_LIBRARY NAMES jthread)
|
||||||
|
|
||||||
|
IF(JTHREAD_LIBRARY AND JTHREAD_INCLUDE_DIR)
|
||||||
|
SET( JTHREAD_FOUND TRUE )
|
||||||
|
ENDIF(JTHREAD_LIBRARY AND JTHREAD_INCLUDE_DIR)
|
||||||
|
|
||||||
|
IF(JTHREAD_FOUND)
|
||||||
|
MESSAGE(STATUS "Found system jthread header file in ${JTHREAD_INCLUDE_DIR}")
|
||||||
|
MESSAGE(STATUS "Found system jthread library ${JTHREAD_LIBRARY}")
|
||||||
|
ELSE(JTHREAD_FOUND)
|
||||||
|
SET(JTHREAD_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/jthread)
|
||||||
|
SET(JTHREAD_LIBRARY jthread)
|
||||||
|
MESSAGE(STATUS "Using project jthread library")
|
||||||
|
ENDIF(JTHREAD_FOUND)
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Look for sqlite3, use our own if not found
|
||||||
|
|
||||||
|
FIND_PATH(SQLITE3_INCLUDE_DIR sqlite3.h)
|
||||||
|
|
||||||
|
FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite3)
|
||||||
|
|
||||||
|
IF(SQLITE3_LIBRARY AND SQLITE3_INCLUDE_DIR)
|
||||||
|
SET( SQLITE3_FOUND TRUE )
|
||||||
|
ENDIF(SQLITE3_LIBRARY AND SQLITE3_INCLUDE_DIR)
|
||||||
|
|
||||||
|
IF(SQLITE3_FOUND)
|
||||||
|
MESSAGE(STATUS "Found system sqlite3 header file in ${SQLITE3_INCLUDE_DIR}")
|
||||||
|
MESSAGE(STATUS "Found system sqlite3 library ${SQLITE3_LIBRARY}")
|
||||||
|
ELSE(SQLITE3_FOUND)
|
||||||
|
SET(SQLITE3_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/sqlite)
|
||||||
|
SET(SQLITE3_LIBRARY sqlite3)
|
||||||
|
MESSAGE(STATUS "Using project sqlite3 library")
|
||||||
|
ENDIF(SQLITE3_FOUND)
|
|
@ -0,0 +1,21 @@
|
||||||
|
#
|
||||||
|
# Random macros
|
||||||
|
#
|
||||||
|
|
||||||
|
# Not used ATM
|
||||||
|
|
||||||
|
MACRO (GETDATETIME RESULT)
|
||||||
|
IF (WIN32)
|
||||||
|
EXECUTE_PROCESS(COMMAND "cmd" /C echo %date% %time% OUTPUT_VARIABLE ${RESULT})
|
||||||
|
string(REGEX REPLACE "\n" "" ${RESULT} "${${RESULT}}")
|
||||||
|
ELSEIF(UNIX)
|
||||||
|
EXECUTE_PROCESS(COMMAND "date" "+%Y-%m-%d_%H:%M:%S" OUTPUT_VARIABLE ${RESULT})
|
||||||
|
string(REGEX REPLACE "\n" "" ${RESULT} "${${RESULT}}")
|
||||||
|
ELSE (WIN32)
|
||||||
|
MESSAGE(SEND_ERROR "date not implemented")
|
||||||
|
SET(${RESULT} "Unknown")
|
||||||
|
ENDIF (WIN32)
|
||||||
|
|
||||||
|
string(REGEX REPLACE " " "_" ${RESULT} "${${RESULT}}")
|
||||||
|
ENDMACRO (GETDATETIME)
|
||||||
|
|
|
@ -0,0 +1,872 @@
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
mp = def.material
|
||||||
|
tp = wielded:get_tool_digging_properties()
|
||||||
|
dp = minetest.get_digging_properties(mp, 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_digging_properties = 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"},
|
||||||
|
material = {
|
||||||
|
diggablity = "normal",
|
||||||
|
weight = 0,
|
||||||
|
crackiness = 0,
|
||||||
|
crumbliness = 0,
|
||||||
|
cuttability = 0,
|
||||||
|
flammability = 0,
|
||||||
|
},
|
||||||
|
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_digging_properties = 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_digging_properties = 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_digging_properties = 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_digging_properties == 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_digging_properties = {
|
||||||
|
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(":", {
|
||||||
|
type = "none",
|
||||||
|
wield_image = "wieldhand.png",
|
||||||
|
wield_scale = {x=1,y=1,z=2.5},
|
||||||
|
tool_digging_properties = {
|
||||||
|
full_punch_interval = 2.0,
|
||||||
|
basetime = 0.5,
|
||||||
|
dt_weight = 1,
|
||||||
|
dt_crackiness = 0,
|
||||||
|
dt_crumbliness = -1,
|
||||||
|
dt_cuttability = 0,
|
||||||
|
basedurability = 50,
|
||||||
|
dd_weight = 0,
|
||||||
|
dd_crackiness = 0,
|
||||||
|
dd_crumbliness = 0,
|
||||||
|
dd_cuttability = 0,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
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,
|
||||||
|
})
|
||||||
|
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
--
|
||||||
|
|
||||||
|
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
|
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 498 B |
After Width: | Height: | Size: 582 B |
After Width: | Height: | Size: 710 B |
After Width: | Height: | Size: 489 B |
|
@ -0,0 +1,2 @@
|
||||||
|
default
|
||||||
|
|
|
@ -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,
|
||||||
|
})
|
After Width: | Height: | Size: 329 B |
After Width: | Height: | Size: 363 B |
After Width: | Height: | Size: 369 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 203 B |
After Width: | Height: | Size: 292 B |
After Width: | Height: | Size: 597 B |
After Width: | Height: | Size: 604 B |
After Width: | Height: | Size: 279 B |
After Width: | Height: | Size: 236 B |
After Width: | Height: | Size: 167 B |
After Width: | Height: | Size: 224 B |
After Width: | Height: | Size: 151 B |
After Width: | Height: | Size: 142 B |
After Width: | Height: | Size: 613 B |
After Width: | Height: | Size: 249 B |
After Width: | Height: | Size: 210 B |
After Width: | Height: | Size: 118 B |
After Width: | Height: | Size: 933 B |
After Width: | Height: | Size: 830 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 539 B |
After Width: | Height: | Size: 246 B |
After Width: | Height: | Size: 236 B |
After Width: | Height: | Size: 978 B |
After Width: | Height: | Size: 874 B |
After Width: | Height: | Size: 856 B |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 591 B |
After Width: | Height: | Size: 936 B |
After Width: | Height: | Size: 672 B |
After Width: | Height: | Size: 502 B |
After Width: | Height: | Size: 507 B |
After Width: | Height: | Size: 395 B |
After Width: | Height: | Size: 357 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 203 B |
After Width: | Height: | Size: 952 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 965 B |
After Width: | Height: | Size: 303 B |
After Width: | Height: | Size: 410 B |
After Width: | Height: | Size: 203 B |
After Width: | Height: | Size: 260 B |
After Width: | Height: | Size: 242 B |
After Width: | Height: | Size: 366 B |
After Width: | Height: | Size: 507 B |
After Width: | Height: | Size: 555 B |
After Width: | Height: | Size: 545 B |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 772 B |
After Width: | Height: | Size: 502 B |
After Width: | Height: | Size: 233 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 489 B |
After Width: | Height: | Size: 219 B |
After Width: | Height: | Size: 207 B |
After Width: | Height: | Size: 182 B |
After Width: | Height: | Size: 806 B |
After Width: | Height: | Size: 161 B |
After Width: | Height: | Size: 186 B |
After Width: | Height: | Size: 264 B |
After Width: | Height: | Size: 252 B |
After Width: | Height: | Size: 927 B |
After Width: | Height: | Size: 271 B |
After Width: | Height: | Size: 216 B |
After Width: | Height: | Size: 291 B |
After Width: | Height: | Size: 931 B |
After Width: | Height: | Size: 262 B |
After Width: | Height: | Size: 203 B |
After Width: | Height: | Size: 301 B |
After Width: | Height: | Size: 927 B |
After Width: | Height: | Size: 245 B |
After Width: | Height: | Size: 203 B |
After Width: | Height: | Size: 255 B |
After Width: | Height: | Size: 925 B |
After Width: | Height: | Size: 913 B |
After Width: | Height: | Size: 917 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 518 B |