diff --git a/.clang-format b/.clang-format index d2e2f294..f1d51a04 100644 --- a/.clang-format +++ b/.clang-format @@ -2,7 +2,7 @@ BasedOnStyle: LLVM IndentWidth: 8 UseTab: Always BreakBeforeBraces: Custom -Standard: Cpp03 +Standard: Cpp11 BraceWrapping: AfterClass: true AfterControlStatement: false diff --git a/.gitignore b/.gitignore index 2ef4fa6d..7b5ecab6 100644 --- a/.gitignore +++ b/.gitignore @@ -22,9 +22,12 @@ tags !tags/ gtags.files .idea/* +# Codelite +*.project ## Files related to minetest development cycle /*.patch +*.diff # GNU Patch reject file *.rej @@ -43,13 +46,17 @@ gtags.files !/mods/minetest/mods_here.txt /worlds /world/ -/clientmods/mods.conf +/clientmods/* +!/clientmods/preview/ /client/mod_storage/ ## Configuration/log files minetest.conf debug.txt +## Other files generated by minetest +screenshot_*.png + ## Doxygen files doc/Doxyfile doc/html/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ef3b371a..d48dd5fc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,7 @@ variables: - make install artifacts: when: on_success - expire_in: 1h + expire_in: 2h paths: - artifact/* @@ -39,12 +39,12 @@ variables: - rm -Rf build/deb/minetest/usr/share/minetest/games/minetest/.git - sed -i 's/DATEPLACEHOLDER/'$(date +%y.%m.%d)'/g' build/deb/minetest/DEBIAN/control - sed -i 's/LEVELDB_PLACEHOLDER/'$LEVELDB_PKG'/g' build/deb/minetest/DEBIAN/control - - cd build/deb/ && dpkg-deb -b minetest/ + - cd build/deb/ && dpkg-deb -b minetest/ && mv minetest.deb ../../ artifacts: when: on_success - expire_in: 30 day + expire_in: 90 day paths: - - build/deb/*.deb + - ./*.deb .debpkg_install: &debpkg_install stage: deploy @@ -52,7 +52,7 @@ variables: - apt-get update -y - apt-get install -y libc6 libcurl3-gnutls libfreetype6 libirrlicht1.8 $LEVELDB_PKG liblua5.1-0 libluajit-5.1-2 libopenal1 libstdc++6 libvorbisfile3 libx11-6 zlib1g script: - - dpkg -i build/deb/*.deb + - dpkg -i ./*.deb ## ## Debian @@ -64,8 +64,13 @@ build:debian-8: <<: *build_definition image: debian:8 before_script: + - echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main" > /etc/apt/sources.list.d/uptodate-toolchain.list + - apt-key adv --keyserver keyserver.ubuntu.com --recv BA9EF27F - apt-get update -y - - apt-get -y install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev + - apt-get -y install build-essential gcc-6 g++-6 libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev + variables: + CC: gcc-6 + CXX: g++-6 package:debian-8: image: debian:8 @@ -115,11 +120,16 @@ deploy:debian-9: # Trusty build:ubuntu-14.04: - <<: *build_definition - image: ubuntu:trusty - before_script: - - apt-get update -y - - apt-get -y install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev + <<: *build_definition + image: ubuntu:trusty + before_script: + - echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main" > /etc/apt/sources.list.d/uptodate-toolchain.list + - apt-key adv --keyserver keyserver.ubuntu.com --recv BA9EF27F + - apt-get update -y + - apt-get -y install build-essential gcc-6 g++-6 libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev + variables: + CC: gcc-6 + CXX: g++-6 package:ubuntu-14.04: image: ubuntu:trusty @@ -140,11 +150,11 @@ deploy:ubuntu-14.04: # Xenial build:ubuntu-16.04: - <<: *build_definition - image: ubuntu:xenial - before_script: - - apt-get update -y - - apt-get -y install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev + <<: *build_definition + image: ubuntu:xenial + before_script: + - apt-get update -y + - apt-get -y install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev package:ubuntu-16.04: image: ubuntu:xenial @@ -165,11 +175,11 @@ deploy:ubuntu-16.04: # Yakkety build:ubuntu-16.10: - <<: *build_definition - image: ubuntu:yakkety - before_script: - - apt-get update -y - - apt-get -y install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev + <<: *build_definition + image: ubuntu:yakkety + before_script: + - apt-get update -y + - apt-get -y install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev package:ubuntu-16.10: image: ubuntu:yakkety @@ -190,11 +200,11 @@ deploy:ubuntu-16.10: # Zesty build:ubuntu-17.04: - <<: *build_definition - image: ubuntu:zesty - before_script: - - apt-get update -y - - apt-get -y install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev + <<: *build_definition + image: ubuntu:zesty + before_script: + - apt-get update -y + - apt-get -y install build-essential libirrlicht-dev cmake libbz2-dev libpng-dev libjpeg-dev libxxf86vm-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev package:ubuntu-17.04: image: ubuntu:zesty @@ -221,3 +231,80 @@ build:fedora-24: image: fedora:24 before_script: - dnf -y install make automake gcc gcc-c++ kernel-devel cmake libcurl* openal* libvorbis* libXxf86vm-devel libogg-devel freetype-devel mesa-libGL-devel zlib-devel jsoncpp-devel irrlicht-devel bzip2-libs gmp-devel sqlite-devel luajit-devel leveldb-devel ncurses-devel doxygen spatialindex-devel bzip2-devel + + +## +## Mingw for Windows +## + +.generic_win_template: &generic_win_template + image: ubuntu:xenial + before_script: + - apt-get update -y + - apt-get install -y p7zip-full wget unzip git cmake gettext + - wget http://minetest.kitsunemimi.pw/mingw-w64-${WIN_ARCH}_7.1.1_ubuntu14.04.7z -O mingw.7z > /dev/null + - sed -e "s|%PREFIX%|${WIN_ARCH}-w64-mingw32|" -e "s|%ROOTPATH%|/usr/${WIN_ARCH}-w64-mingw32|" < util/travis/toolchain_mingw.cmake.in > ${TOOLCHAIN_OUTPUT} + - 7z x -y -o/usr mingw.7z > /dev/null + +.build_win_template: &build_win_template + <<: *generic_win_template + stage: build + artifacts: + when: on_success + expire_in: 2h + paths: + - build/* + +.package_win_template: &package_win_template + <<: *generic_win_template + stage: package + script: + - cd build/minetest/_build + - make package + - cd ../../../ + - mkdir minetest-win-${WIN_ARCH} + - unzip build/minetest/_build/minetest-*-win*.zip -d minetest-win-${WIN_ARCH} + - cp /usr/${WIN_ARCH}-w64-mingw32/bin/libgcc*.dll minetest-win-${WIN_ARCH}/minetest-*-win*/bin + - cp /usr/${WIN_ARCH}-w64-mingw32/bin/libstdc++*.dll minetest-win-${WIN_ARCH}/minetest-*-win*/bin + - cp /usr/${WIN_ARCH}-w64-mingw32/bin/libwinpthread*.dll minetest-win-${WIN_ARCH}/minetest-*-win*/bin + artifacts: + when: on_success + expire_in: 90 day + paths: + - minetest-win-*/* + +build:win32: + <<: *build_win_template + script: + - ./util/buildbot/buildwin32.sh build + variables: + NO_PACKAGE: "1" + WIN_ARCH: "i686" + TOOLCHAIN_OUTPUT: "util/buildbot/toolchain_mingw.cmake" + +package:win32: + <<: *package_win_template + dependencies: + - build:win32 + variables: + NO_PACKAGE: "1" + WIN_ARCH: "i686" + TOOLCHAIN_OUTPUT: "util/buildbot/toolchain_mingw.cmake" + +build:win64: + <<: *build_win_template + script: + - ./util/buildbot/buildwin64.sh build + variables: + NO_PACKAGE: "1" + WIN_ARCH: "x86_64" + TOOLCHAIN_OUTPUT: "util/buildbot/toolchain_mingw64.cmake" + +package:win64: + <<: *package_win_template + dependencies: + - build:win64 + variables: + NO_PACKAGE: "1" + WIN_ARCH: "x86_64" + TOOLCHAIN_OUTPUT: "util/buildbot/toolchain_mingw64.cmake" diff --git a/.travis.yml b/.travis.yml index 57d934c9..123705fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: cpp before_install: ./util/travis/before_install.sh script: ./util/travis/script.sh sudo: required +dist: trusty notifications: email: false matrix: @@ -10,30 +11,81 @@ matrix: - env: PLATFORM=Win32 compiler: gcc os: linux + addons: + apt: + packages: ['gcc-mingw-w64-i686', 'g++-mingw-w64-i686', 'binutils-mingw-w64-i686'] + sources: &sources + - ubuntu-toolchain-r-test + - sourceline: 'deb http://mirrors.kernel.org/ubuntu xenial main universe' + - env: PLATFORM=Win64 compiler: gcc os: linux - - env: PLATFORM=Unix COMPILER=clang + addons: + apt: + packages: ['gcc-mingw-w64-x86-64', 'g++-mingw-w64-x86-64', 'binutils-mingw-w64-x86-64'] + sources: &sources + - ubuntu-toolchain-r-test + - sourceline: 'deb http://mirrors.kernel.org/ubuntu xenial main universe' + + - env: PLATFORM=Unix compiler: clang os: osx - - env: PLATFORM=Unix COMPILER=g++ + osx_image: xcode8 + + - env: PLATFORM=Unix COMPILER=gcc-6 compiler: gcc os: linux - - env: PLATFORM=Unix COMPILER=clang - compiler: clang - os: linux - - env: PLATFORM=Unix COMPILER=clang VALGRIND=1 - compiler: clang - os: linux - dist: trusty - - env: COMPILER=none LINT=1 - compiler: clang - os: linux - dist: trusty - - env: PLATFORM=Unix COMPILER=g++-6 + addons: + apt: + packages: ['gcc-6', 'g++-6'] + sources: &sources + - ubuntu-toolchain-r-test + + - env: PLATFORM=Unix COMPILER=gcc-7 compiler: gcc os: linux -addons: - apt: - sources: &sources - - ubuntu-toolchain-r-test + addons: + apt: + packages: ['gcc-7', 'g++-7'] + sources: &sources + - ubuntu-toolchain-r-test + + - env: PLATFORM=Unix COMPILER=clang-3.6 + compiler: clang + os: linux + addons: + apt: + packages: ['clang-3.6', 'clang++-3.6'] + sources: &sources + - llvm-toolchain-trusty-3.6 + + - env: PLATFORM=Unix COMPILER=clang-4.0 + compiler: clang + os: linux + addons: + apt: + packages: ['clang-4.0', 'clang++-4.0'] + sources: &sources + - llvm-toolchain-trusty-4.0 + + - env: PLATFORM=Unix COMPILER=clang-4.0 VALGRIND=1 + compiler: clang + os: linux + addons: + apt: + packages: ['valgrind', 'clang-4.0', 'clang++-4.0'] + sources: &sources + - llvm-toolchain-trusty-4.0 + + - env: LINT=1 + compiler: clang + os: linux + addons: + apt: + packages: ['clang-format-4.0'] + sources: &sources + - llvm-toolchain-trusty-4.0 + + + diff --git a/CMakeLists.txt b/CMakeLists.txt index f0ab264f..6bdae452 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,11 +9,13 @@ endif() project(minetest) set(PROJECT_NAME_CAPITALIZED "Voxel Adventures Client") +# Works only for cmake 3.1 and greater +set(CMAKE_CXX_STANDARD 11) # Also remember to set PROTOCOL_VERSION in network/networkprotocol.h when releasing set(VERSION_MAJOR 0) set(VERSION_MINOR 4) -set(VERSION_PATCH 15) +set(VERSION_PATCH 16) set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string") # Change to false for releases @@ -155,18 +157,22 @@ endif() install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/builtin" DESTINATION "${SHAREDIR}") -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/client" DESTINATION "${SHAREDIR}") -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/clientmods" DESTINATION "${SHAREDIR}") -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/games" DESTINATION "${SHAREDIR}" PATTERN ".git*" EXCLUDE) - -if(BUILD_CLIENT) - 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/mods_here.txt" DESTINATION "${SHAREDIR}/mods") install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/textures/texture_packs_here.txt" DESTINATION "${SHAREDIR}/textures") endif() +install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/games" DESTINATION "${SHAREDIR}" PATTERN ".git*" EXCLUDE) + +if(BUILD_CLIENT) + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/client/shaders" DESTINATION "${SHAREDIR}/client") + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/textures/base/pack" DESTINATION "${SHAREDIR}/textures/base") + if(RUN_IN_PLACE) + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/clientmods" DESTINATION "${SHAREDIR}") + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/client/serverlist" DESTINATION "${SHAREDIR}/client") + endif() +endif() + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/fonts" DESTINATION "${SHAREDIR}") install(FILES "README.txt" DESTINATION "${DOCDIR}") diff --git a/build/android/build.gradle b/build/android/build.gradle index 745952a2..1263b223 100644 --- a/build/android/build.gradle +++ b/build/android/build.gradle @@ -11,10 +11,10 @@ apply plugin: "com.android.application" android { compileSdkVersion 25 - buildToolsVersion "25.0.1" + buildToolsVersion "25.0.3" defaultConfig { - versionCode 16 + versionCode 17 versionName "${System.env.VERSION_STR}.${versionCode}" minSdkVersion 9 targetSdkVersion 9 diff --git a/build/android/jni/Android.mk b/build/android/jni/Android.mk index 7b741e04..22ef2090 100644 --- a/build/android/jni/Android.mk +++ b/build/android/jni/Android.mk @@ -124,7 +124,6 @@ LOCAL_SRC_FILES := \ jni/src/clientobject.cpp \ jni/src/clouds.cpp \ jni/src/collision.cpp \ - jni/src/content_abm.cpp \ jni/src/content_cao.cpp \ jni/src/content_cso.cpp \ jni/src/content_mapblock.cpp \ @@ -152,7 +151,7 @@ LOCAL_SRC_FILES := \ jni/src/gettext.cpp \ jni/src/guiChatConsole.cpp \ jni/src/guiEngine.cpp \ - jni/src/guiFileSelectMenu.cpp \ + jni/src/guiPathSelectMenu.cpp \ jni/src/guiFormSpecMenu.cpp \ jni/src/guiKeyChangeMenu.cpp \ jni/src/guiPasswordChange.cpp \ diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua index 2b8cc4ac..ed43a614 100644 --- a/builtin/client/chatcommands.lua +++ b/builtin/client/chatcommands.lua @@ -1,7 +1,7 @@ -- Minetest: builtin/client/chatcommands.lua -core.register_on_sending_chat_messages(function(message) +core.register_on_sending_chat_message(function(message) if message:sub(1,2) == ".." then return false end diff --git a/builtin/client/register.lua b/builtin/client/register.lua index 6b12ddec..cfc5abaa 100644 --- a/builtin/client/register.lua +++ b/builtin/client/register.lua @@ -61,8 +61,8 @@ end core.registered_globalsteps, core.register_globalstep = make_registration() core.registered_on_shutdown, core.register_on_shutdown = make_registration() core.registered_on_connect, core.register_on_connect = make_registration() -core.registered_on_receiving_chat_messages, core.register_on_receiving_chat_messages = make_registration() -core.registered_on_sending_chat_messages, core.register_on_sending_chat_messages = make_registration() +core.registered_on_receiving_chat_message, core.register_on_receiving_chat_message = make_registration() +core.registered_on_sending_chat_message, core.register_on_sending_chat_message = make_registration() core.registered_on_death, core.register_on_death = make_registration() core.registered_on_hp_modification, core.register_on_hp_modification = make_registration() core.registered_on_damage_taken, core.register_on_damage_taken = make_registration() diff --git a/builtin/common/chatcommands.lua b/builtin/common/chatcommands.lua index e8955c6b..52edda65 100644 --- a/builtin/common/chatcommands.lua +++ b/builtin/common/chatcommands.lua @@ -97,7 +97,7 @@ end if INIT == "client" then core.register_chatcommand("help", { - params = gettext("[all/]"), + params = gettext("[all | ]"), description = gettext("Get help for commands"), func = function(param) return do_help_cmd(nil, param) @@ -105,7 +105,7 @@ if INIT == "client" then }) else core.register_chatcommand("help", { - params = "[all/privs/]", + params = "[all | privs | ]", description = "Get help for commands or list privileges", func = do_help_cmd, }) diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index 68481f7c..f9b572d9 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -642,44 +642,26 @@ end local ESCAPE_CHAR = string.char(0x1b) --- Client-side mods don't have access to settings -if core.settings and core.settings:get_bool("disable_escape_sequences") then - - function core.get_color_escape_sequence(color) - return "" - end - - function core.get_background_escape_sequence(color) - return "" - end - - function core.colorize(color, message) - return message - end - -else - - function core.get_color_escape_sequence(color) - return ESCAPE_CHAR .. "(c@" .. color .. ")" - end - - function core.get_background_escape_sequence(color) - return ESCAPE_CHAR .. "(b@" .. color .. ")" - end - - function core.colorize(color, message) - local lines = tostring(message):split("\n", true) - local color_code = core.get_color_escape_sequence(color) - - for i, line in ipairs(lines) do - lines[i] = color_code .. line - end - - return table.concat(lines, "\n") .. core.get_color_escape_sequence("#ffffff") - end - +function core.get_color_escape_sequence(color) + return ESCAPE_CHAR .. "(c@" .. color .. ")" end +function core.get_background_escape_sequence(color) + return ESCAPE_CHAR .. "(b@" .. color .. ")" +end + +function core.colorize(color, message) + local lines = tostring(message):split("\n", true) + local color_code = core.get_color_escape_sequence(color) + + for i, line in ipairs(lines) do + lines[i] = color_code .. line + end + + return table.concat(lines, "\n") .. core.get_color_escape_sequence("#ffffff") +end + + function core.strip_foreground_colors(str) return (str:gsub(ESCAPE_CHAR .. "%(c@[^)]+%)", "")) end @@ -723,3 +705,28 @@ function core.pointed_thing_to_face_pos(placer, pointed_thing) end return fine_pos end + +function core.string_to_privs(str, delim) + assert(type(str) == "string") + delim = delim or ',' + local privs = {} + for _, priv in pairs(string.split(str, delim)) do + privs[priv:trim()] = true + end + return privs +end + +function core.privs_to_string(privs, delim) + assert(type(privs) == "table") + delim = delim or ',' + local list = {} + for priv, bool in pairs(privs) do + if bool then + list[#list + 1] = priv + end + end + return table.concat(list, delim) +end + +assert(core.string_to_privs("a,b").b == true) +assert(core.privs_to_string({a=true,b=true}) == "a,b") diff --git a/builtin/game/auth.lua b/builtin/game/auth.lua index b553e228..4174d40d 100644 --- a/builtin/game/auth.lua +++ b/builtin/game/auth.lua @@ -4,31 +4,6 @@ -- Authentication handler -- -function core.string_to_privs(str, delim) - assert(type(str) == "string") - delim = delim or ',' - local privs = {} - for _, priv in pairs(string.split(str, delim)) do - privs[priv:trim()] = true - end - return privs -end - -function core.privs_to_string(privs, delim) - assert(type(privs) == "table") - delim = delim or ',' - local list = {} - for priv, bool in pairs(privs) do - if bool then - list[#list + 1] = priv - end - end - return table.concat(list, delim) -end - -assert(core.string_to_privs("a,b").b == true) -assert(core.privs_to_string({a=true,b=true}) == "a,b") - core.auth_file_path = core.get_worldpath().."/auth.txt" core.auth_table = {} diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index ec7a1564..85aaf323 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -92,7 +92,7 @@ core.register_chatcommand("admin", { }) core.register_chatcommand("privs", { - params = "", + params = "[]", description = "Print privileges of player", func = function(caller, param) param = param:trim() @@ -145,7 +145,7 @@ local function handle_grant_command(caller, grantname, grantprivstr) end core.register_chatcommand("grant", { - params = " |all", + params = " ( | all)", description = "Give privilege to player", func = function(name, param) local grantname, grantprivstr = string.match(param, "([^ ]+) (.+)") @@ -157,7 +157,7 @@ core.register_chatcommand("grant", { }) core.register_chatcommand("grantme", { - params = "|all", + params = " | all", description = "Grant privileges to yourself", func = function(name, param) if param == "" then @@ -168,7 +168,7 @@ core.register_chatcommand("grantme", { }) core.register_chatcommand("revoke", { - params = " |all", + params = " ( | all)", description = "Remove privilege from player", privs = {}, func = function(name, param) @@ -305,7 +305,7 @@ core.register_chatcommand("remove_player", { }) core.register_chatcommand("teleport", { - params = ",, | | ,, | ", + params = ",, | | ( ,,) | ( )", description = "Teleport to player or position", privs = {teleport=true}, func = function(name, param) @@ -413,7 +413,7 @@ core.register_chatcommand("teleport", { }) core.register_chatcommand("set", { - params = "[-n] | ", + params = "([-n] ) | ", description = "Set or read server configuration setting", privs = {server=true}, func = function(name, param) @@ -468,9 +468,9 @@ local function emergeblocks_progress_update(ctx) end core.register_chatcommand("emergeblocks", { - params = "(here [radius]) | ( )", + params = "(here []) | ( )", description = "Load (or, if nonexistent, generate) map blocks " - .. "contained in area pos1 to pos2", + .. "contained in area pos1 to pos2 ( and must be in parentheses)", privs = {server=true}, func = function(name, param) local p1, p2 = parse_range_str(name, param) @@ -494,8 +494,9 @@ core.register_chatcommand("emergeblocks", { }) core.register_chatcommand("deleteblocks", { - params = "(here [radius]) | ( )", - description = "Delete map blocks contained in area pos1 to pos2", + params = "(here []) | ( )", + description = "Delete map blocks contained in area pos1 to pos2 " + .. "( and must be in parentheses)", privs = {server=true}, func = function(name, param) local p1, p2 = parse_range_str(name, param) @@ -513,8 +514,9 @@ core.register_chatcommand("deleteblocks", { }) core.register_chatcommand("fixlight", { - params = "(here [radius]) | ( )", - description = "Resets lighting in the area between pos1 and pos2", + params = "(here []) | ( )", + description = "Resets lighting in the area between pos1 and pos2 " + .. "( and must be in parentheses)", privs = {server = true}, func = function(name, param) local p1, p2 = parse_range_str(name, param) @@ -661,7 +663,7 @@ core.register_on_punchnode(function(pos, node, puncher) end) core.register_chatcommand("rollback_check", { - params = "[] [] [limit]", + params = "[] [] []", description = "Check who last touched a node or a node near it" .. " within the time specified by . Default: range = 0," .. " seconds = 86400 = 24h, limit = 5", @@ -714,7 +716,7 @@ core.register_chatcommand("rollback_check", { }) core.register_chatcommand("rollback", { - params = " [] | : []", + params = "( []) | (: [])", description = "Revert actions of a player. Default for is 60", privs = {rollback=true}, func = function(name, param) @@ -806,8 +808,8 @@ core.register_chatcommand("days", { }) core.register_chatcommand("shutdown", { - description = "Shutdown server", - params = "[delay_in_seconds(0..inf) or -1 for cancel] [reconnect] [message]", + params = "[ | -1] [reconnect] []", + description = "Shutdown server (-1 cancels a delayed shutdown)", privs = {server=true}, func = function(name, param) local delay, reconnect, message = param:match("([^ ][-]?[0-9]+)([^ ]+)(.*)") @@ -845,7 +847,7 @@ core.register_chatcommand("ban", { }) core.register_chatcommand("unban", { - params = "", + params = " | ", description = "Remove IP ban", privs = {ban=true}, func = function(name, param) @@ -858,7 +860,7 @@ core.register_chatcommand("unban", { }) core.register_chatcommand("kick", { - params = " [reason]", + params = " []", description = "Kick a player", privs = {kick=true}, func = function(name, param) @@ -877,7 +879,7 @@ core.register_chatcommand("kick", { }) core.register_chatcommand("clearobjects", { - params = "[full|quick]", + params = "[full | quick]", description = "Clear all objects in world", privs = {server=true}, func = function(name, param) @@ -923,7 +925,7 @@ core.register_chatcommand("msg", { }) core.register_chatcommand("last-login", { - params = "[name]", + params = "[]", description = "Get the last login time of a player", func = function(name, param) if param == "" then @@ -940,7 +942,7 @@ core.register_chatcommand("last-login", { }) core.register_chatcommand("clearinv", { - params = "[name]", + params = "[]", description = "Clear the inventory of yourself or another player", func = function(name, param) local player diff --git a/builtin/mainmenu/dlg_settings_advanced.lua b/builtin/mainmenu/dlg_settings_advanced.lua index 206ce162..cac9f698 100644 --- a/builtin/mainmenu/dlg_settings_advanced.lua +++ b/builtin/mainmenu/dlg_settings_advanced.lua @@ -196,7 +196,7 @@ local function parse_setting_line(settings, line, read_all, base_level, allow_se return end - if setting_type == "path" then + if setting_type == "path" or setting_type == "filepath" then local default = remaining_line:match("^(.*)$") if not default then @@ -206,7 +206,7 @@ local function parse_setting_line(settings, line, read_all, base_level, allow_se table.insert(settings, { name = name, readable_name = readable_name, - type = "path", + type = setting_type, default = default, comment = current_comment, }) @@ -504,14 +504,14 @@ local function create_change_setting_formspec(dialogdata) end formspec = formspec .. ";" .. selected_index .. "]" - elseif setting.type == "path" then + elseif setting.type == "path" or setting.type == "filepath" then local current_value = dialogdata.selected_path if not current_value then current_value = get_current_value(setting) end formspec = formspec .. "field[0.5,4;7.5,1;te_setting_value;;" .. core.formspec_escape(current_value) .. "]" - .. "button[8,3.75;2,1;btn_browser_path;" .. fgettext("Browse") .. "]" + .. "button[8,3.75;2,1;btn_browser_" .. setting.type .. ";" .. fgettext("Browse") .. "]" else -- TODO: fancy input for float, int, flags, noise_params, v3f @@ -606,7 +606,13 @@ local function handle_change_setting_buttons(this, fields) end if fields["btn_browser_path"] then - core.show_file_open_dialog("dlg_browse_path", fgettext_ne("Select path")) + core.show_path_select_dialog("dlg_browse_path", + fgettext_ne("Select directory"), false) + end + + if fields["btn_browser_filepath"] then + core.show_path_select_dialog("dlg_browse_path", + fgettext_ne("Select file"), true) end if fields["dlg_browse_path_accepted"] then diff --git a/builtin/mainmenu/tab_credits.lua b/builtin/mainmenu/tab_credits.lua index ff47dbb2..b0235225 100644 --- a/builtin/mainmenu/tab_credits.lua +++ b/builtin/mainmenu/tab_credits.lua @@ -19,61 +19,68 @@ local core_developers = { "Perttu Ahola (celeron55) ", - "Ryan Kwolek (kwolekr) ", "sfan5 ", - "kahrl ", - "sapier", "ShadowNinja ", "Nathanaël Courant (Nore/Ekdohibs) ", "Loic Blot (nerzhul/nrz) ", - "Matt Gregory (paramat)", - "est31 ", + "paramat", "Craig Robbins (Zeno) ", "Auke Kok (sofar) ", - "Andrew Ward (rubenwardy) ", + "rubenwardy ", + "Krock/SmallJoker ", } local active_contributors = { - "Duane Robertson ", - "SmallJoker ", - "Lars Hofhansl ", - "Jeija ", - "Gregory Currie (gregorycu)", - "Sokomine ", - "TeTpaAka", - "Jean-Patrick G (kilbith) ", - "Diego Martínez (kaeza) ", - "Dániel Juhász (juhdanad) ", - "Rogier ", + "red-001 [CSM & Menu fixes]", + "Dániel Juhász (juhdanad) [Audiovisuals: lighting]", + "numberZero [Audiovisuals: meshgen]", + "Lars Hofhansl [Occulusion culling, fixes]", + "Jean-Patrick G (kilbith) [Audiovisuals]", + "Vincent Glize (Dumbeldor) [CSM]", + "bigfoot547 [CSM]", + "Rogier [Fixes]", + "Wuzzy [Audiovisuals]", + "Shara/Ezhh [Settings]", } local previous_core_developers = { "BlockMen", - "Maciej Kasatkin (RealBadAngel) ", + "Maciej Kasatkin (RealBadAngel) [RIP]", "Lisa Milne (darkrose) ", "proller", "Ilya Zhuravlev (xyz) ", "PilzAdam ", + "est31 ", + "kahrl ", + "Ryan Kwolek (kwolekr) ", + "sapier", } local previous_contributors = { - "Vanessa Ezekowitz (VanessaE) ", - "Jurgen Doser (doserj) ", - "MirceaKitsune ", - "dannydark ", - "0gb.us <0gb.us@0gb.us>", - "Guiseppe Bilotta (Oblomov) ", - "Jonathan Neuschafer ", - "Nils Dagsson Moskopp (erlehmann) ", - "Břetislav Štec (t0suj4/TBC_x)", - "Aaron Suen ", - "Constantin Wenger (SpeedProg) ", - "matttpt ", - "JacobF ", - "TriBlade9 ", - "Zefram ", + "Gregory Currie (gregorycu) [optimisation]", + "Diego Martínez (kaeza) ", + "T4im [Profiler]", + "TeTpaAka [Hand overriding, nametag colors]", + "HybridDog [Fixes]", + "Duane Robertson [MGValleys]", + "neoascetic [OS X Fixes]", + "TriBlade9 [Audiovisuals]", + "Jurgen Doser (doserj) [Fixes]", + "MirceaKitsune [Audiovisuals]", + "Guiseppe Bilotta (Oblomov) [Fixes]", + "matttpt [Fixes]", + "Nils Dagsson Moskopp (erlehmann) [Minetest Logo]", + "Jeija [HTTP, particles]", } +local function buildCreditList(source) + local ret = {} + for i = 1, #source do + ret[i] = core.formspec_escape(source[i]) + end + return table.concat(ret, ",,") +end + return { name = "credits", caption = fgettext("Credits"), @@ -87,13 +94,13 @@ return { "tableoptions[background=#00000000;highlight=#00000000;border=false]" .. "table[3.5,-0.25;8.5,6.05;list_credits;" .. "#FFFF00," .. fgettext("Core Developers") .. ",," .. - table.concat(core_developers, ",,") .. ",,," .. + buildCreditList(core_developers) .. ",,," .. "#FFFF00," .. fgettext("Active Contributors") .. ",," .. - table.concat(active_contributors, ",,") .. ",,," .. + buildCreditList(active_contributors) .. ",,," .. "#FFFF00," .. fgettext("Previous Core Developers") ..",," .. - table.concat(previous_core_developers, ",,") .. ",,," .. + buildCreditList(previous_core_developers) .. ",,," .. "#FFFF00," .. fgettext("Previous Contributors") .. ",," .. - table.concat(previous_contributors, ",,") .. "," .. + buildCreditList(previous_contributors) .. "," .. ";1]" end } diff --git a/builtin/mainmenu/tab_settings.lua b/builtin/mainmenu/tab_settings.lua index 5a8cc19b..fada3333 100644 --- a/builtin/mainmenu/tab_settings.lua +++ b/builtin/mainmenu/tab_settings.lua @@ -247,17 +247,20 @@ local function formspec(tabview, name, tabdata) .. dump(core.settings:get_bool("enable_waving_plants")) .. "]" else tab_string = tab_string .. - "tablecolumns[color;text]" .. - "tableoptions[background=#00000000;highlight=#00000000;border=false]" .. - "table[8.33,0.7;3.5,4;shaders;" .. - "#888888," .. fgettext("Bump Mapping") .. "," .. - "#888888," .. fgettext("Tone Mapping") .. "," .. - "#888888," .. fgettext("Normal Mapping") .. "," .. - "#888888," .. fgettext("Parallax Occlusion") .. "," .. - "#888888," .. fgettext("Waving Water") .. "," .. - "#888888," .. fgettext("Waving Leaves") .. "," .. - "#888888," .. fgettext("Waving Plants") .. "," .. - ";1]" + "label[8.38,0.7;" .. core.colorize("#888888", + fgettext("Bump Mapping")) .. "]" .. + "label[8.38,1.2;" .. core.colorize("#888888", + fgettext("Tone Mapping")) .. "]" .. + "label[8.38,1.7;" .. core.colorize("#888888", + fgettext("Normal Mapping")) .. "]" .. + "label[8.38,2.2;" .. core.colorize("#888888", + fgettext("Parallax Occlusion")) .. "]" .. + "label[8.38,2.7;" .. core.colorize("#888888", + fgettext("Waving Water")) .. "]" .. + "label[8.38,3.2;" .. core.colorize("#888888", + fgettext("Waving Leaves")) .. "]" .. + "label[8.38,3.7;" .. core.colorize("#888888", + fgettext("Waving Plants")) .. "]" end return tab_string diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 3758097b..53fb2385 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -12,6 +12,7 @@ # - float # - enum # - path +# - filepath # - key (will be ignored in GUI, since a special key change dialog exists) # - flags # - noise_params @@ -31,6 +32,8 @@ # - default value1,value2,... # * path: # - default (if default is not specified then "" is set) +# * filepath: +# - default (if default is not specified then "" is set) # * key: # - default # * flags: @@ -101,7 +104,7 @@ repeat_rightclick_time (Rightclick repetition interval) float 0.25 # Enable random user input (only used for testing). random_input (Random input) bool false -# Continuous forward movement (only used for testing). +# Continuous forward movement, toggled by autoforward key. continuous_forward (Continuous forward) bool false # Enable Joysticks @@ -206,9 +209,9 @@ keymap_increase_volume (Inc. volume key) key # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keymap_decrease_volume (Dec. volume key) key -# Key for toggling autorun. +# Key for toggling autoforward. # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 -keymap_autorun (Autorun key) key +keymap_autoforward (Automatic forwards key) key # Key for toggling cinematic mode. # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 @@ -477,10 +480,10 @@ pause_fps_max (FPS in pause menu) int 20 viewing_range (Viewing range) int 100 20 4000 # Width component of the initial window size. -screenW (Screen width) int 800 +screen_w (Screen width) int 800 # Height component of the initial window size. -screenH (Screen height) int 600 +screen_h (Screen height) int 600 # Save window size automatically when modified. autosave_screensize (Autosave Screen Size) bool true @@ -642,7 +645,7 @@ tooltip_show_delay (Tooltip delay) int 400 freetype (Freetype fonts) bool true # Path to TrueTypeFont or bitmap. -font_path (Font path) path fonts/liberationsans.ttf +font_path (Font path) filepath fonts/liberationsans.ttf font_size (Font size) int 16 @@ -652,12 +655,12 @@ font_shadow (Font shadow) int 1 # Font shadow alpha (opaqueness, between 0 and 255). font_shadow_alpha (Font shadow alpha) int 127 0 255 -mono_font_path (Monospace font path) path fonts/liberationmono.ttf +mono_font_path (Monospace font path) filepath fonts/liberationmono.ttf mono_font_size (Monospace font size) int 15 # This font will be used for certain languages. -fallback_font_path (Fallback font) path fonts/DroidSansFallbackFull.ttf +fallback_font_path (Fallback font) filepath fonts/DroidSansFallbackFull.ttf fallback_font_size (Fallback font size) int 15 fallback_font_shadow (Fallback font shadow) int 1 fallback_font_shadow_alpha (Fallback font shadow alpha) int 128 0 255 @@ -721,10 +724,9 @@ server_announce (Announce server) bool false # If you want to announce your ipv6 address, use serverlist_url = v6.servers.minetest.net. serverlist_url (Serverlist URL) string servers.minetest.net -# Disable escape sequences, e.g. chat coloring. -# Use this if you want to run a server with pre-0.4.14 clients and you want to disable -# the escape sequences generated by mods. -disable_escape_sequences (Disable escape sequences) bool false +# Remove color codes from incoming chat messages +# Use this to stop players from being able to use color in their messages +strip_color_codes (Strip color codes) bool false [*Network] @@ -886,7 +888,6 @@ movement_speed_crouch (Crouch speed) float 1.35 movement_speed_fast (Fast mode speed) float 20 movement_speed_climb (Climbing speed) float 3 movement_speed_jump (Jumping speed) float 6.5 -movement_speed_descend (Descending speed) float 6 movement_liquid_fluidity (Liquid fluidity) float 1 movement_liquid_fluidity_smooth (Liquid fluidity smoothing) float 0.5 movement_liquid_sink (Liquid sink) float 10 diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index f3992612..809e4f01 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -30,13 +30,13 @@ core.register_on_item_use(function(itemstack, pointed_thing) end) -- This is an example function to ensure it's working properly, should be removed before merge -core.register_on_receiving_chat_messages(function(message) +core.register_on_receiving_chat_message(function(message) print("[PREVIEW] Received message " .. message) return false end) -- This is an example function to ensure it's working properly, should be removed before merge -core.register_on_sending_chat_messages(function(message) +core.register_on_sending_chat_message(function(message) print("[PREVIEW] Sending message " .. message) return false end) @@ -150,3 +150,8 @@ core.register_on_punchnode(function(pos, node) return false end) +core.register_chatcommand("privs", { + func = function(param) + return true, core.privs_to_string(minetest.get_privilege_list()) + end, +}) diff --git a/doc/client_lua_api.md b/doc/client_lua_api.md index b3e494cc..43b33ac9 100644 --- a/doc/client_lua_api.md +++ b/doc/client_lua_api.md @@ -1,4 +1,4 @@ -Minetest Lua Client Modding API Reference 0.4.15 +Minetest Lua Client Modding API Reference 0.4.16 ================================================ * More information at * Developer Wiki: @@ -648,10 +648,10 @@ Call these functions only at load time! semi-frequent intervals as well as on server shutdown. * `minetest.register_on_connect(func())` * Called at the end of client connection (when player is loaded onto map) -* `minetest.register_on_receiving_chat_message(func(name, message))` +* `minetest.register_on_receiving_chat_message(func(message))` * Called always when a client receive a message * Return `true` to mark the message as handled, which means that it will not be shown to chat -* `minetest.register_on_sending_chat_message(func(name, message))` +* `minetest.register_on_sending_chat_message(func(message))` * Called always when a client send a message from chat * Return `true` to mark the message as handled, which means that it will not be sent to server * `minetest.register_chatcommand(cmd, chatcommand definition)` @@ -676,7 +676,7 @@ Call these functions only at load time! * Called when the local player punches a node * Newest functions are called first * If any function returns true, the punch is ignored -* `minetest.register_on_placenode(function(pointed_thing, node))` +* `minetest.register_on_placenode(function(pointed_thing, node))` * Called when a node has been placed * `minetest.register_on_item_use(func(item, pointed_thing))` * Called when the local player uses an item. @@ -730,6 +730,13 @@ Call these functions only at load time! * `minetest.localplayer` * Reference to the LocalPlayer object. See [`LocalPlayer`](#localplayer) class reference for methods. +### Privileges +* `minetest.get_privilege_list()` + * Returns a list of privileges the currect player has in the format `{priv1=true,...}` +* `minetest.string_to_privs(str)`: returns `{priv1=true,...}` +* `minetest.privs_to_string(privs)`: returns `"priv1,priv2,..."` + * Convert between two privilege representations + ### Client Environment * `minetest.get_player_names()` * Returns list of player names on server @@ -1117,15 +1124,15 @@ The following functions provide escape sequences: `minetest.get_color_escape_sequence(color) .. message .. minetest.get_color_escape_sequence("#ffffff")` -* `color.get_background_escape_sequence(color)` +* `minetest.get_background_escape_sequence(color)` * `color` is a [ColorString](#colorstring) * The escape sequence sets the background of the whole text element to `color`. Only defined for item descriptions and tooltips. -* `color.strip_foreground_colors(str)` +* `minetest.strip_foreground_colors(str)` * Removes foreground colors added by `get_color_escape_sequence`. -* `color.strip_background_colors(str)` +* `minetest.strip_background_colors(str)` * Removes background colors added by `get_background_escape_sequence`. -* `color.strip_colors(str)` +* `minetest.strip_colors(str)` * Removes all color escape sequences. `ColorString` diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 76244646..28067eef 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1,4 +1,4 @@ -Minetest Lua Modding API Reference 0.4.15 +Minetest Lua Modding API Reference 0.4.16 ========================================= * More information at * Developer Wiki: @@ -186,7 +186,11 @@ Naming convention for registered textual names ---------------------------------------------- Registered names should generally be in this format: - "modname:" ( can have characters a-zA-Z0-9_) + `modname:` + +`` can have these characters: + + a-zA-Z0-9_ This is to prevent conflicting names from corrupting maps and is enforced by the mod loader. @@ -209,7 +213,7 @@ The `:` prefix can also be used for maintaining backwards compatibility. ### Aliases Aliases can be added by using `minetest.register_alias(name, convert_to)` or -`minetest.register_alias_force(name, convert_to). +`minetest.register_alias_force(name, convert_to)`. This will make Minetest to convert things called name to things called `convert_to`. @@ -309,10 +313,10 @@ Example: default_sandstone.png^[resize:16x16 #### `[opacity:` - Makes the base image transparent according to the given ratio. - r must be between 0 and 255. - 0 means totally transparent. - 255 means totally opaque. +Makes the base image transparent according to the given ratio. + +`r` must be between 0 and 255. +0 means totally transparent. 255 means totally opaque. Example: @@ -426,6 +430,167 @@ Result is more like what you'd expect if you put a color on top of another color. Meaning white surfaces get a lot of your new color while black parts don't change very much. +Hardware coloring +----------------- +The goal of hardware coloring is to simplify the creation of +colorful nodes. If your textures use the same pattern, and they only +differ in their color (like colored wool blocks), you can use hardware +coloring instead of creating and managing many texture files. +All of these methods use color multiplication (so a white-black texture +with red coloring will result in red-black color). + +### Static coloring +This method is useful if you wish to create nodes/items with +the same texture, in different colors, each in a new node/item definition. + +#### Global color +When you register an item or node, set its `color` field (which accepts a +`ColorSpec`) to the desired color. + +An `ItemStack`s static color can be overwritten by the `color` metadata +field. If you set that field to a `ColorString`, that color will be used. + +#### Tile color +Each tile may have an individual static color, which overwrites every +other coloring methods. To disable the coloring of a face, +set its color to white (because multiplying with white does nothing). +You can set the `color` property of the tiles in the node's definition +if the tile is in table format. + +### Palettes +For nodes and items which can have many colors, a palette is more +suitable. A palette is a texture, which can contain up to 256 pixels. +Each pixel is one possible color for the node/item. +You can register one node/item, which can have up to 256 colors. + +#### Palette indexing +When using palettes, you always provide a pixel index for the given +node or `ItemStack`. The palette is read from left to right and from +top to bottom. If the palette has less than 256 pixels, then it is +stretched to contain exactly 256 pixels (after arranging the pixels +to one line). The indexing starts from 0. + +Examples: +* 16x16 palette, index = 0: the top left corner +* 16x16 palette, index = 4: the fifth pixel in the first row +* 16x16 palette, index = 16: the pixel below the top left corner +* 16x16 palette, index = 255: the bottom right corner +* 2 (width)x4 (height) palette, index=31: the top left corner. + The palette has 8 pixels, so each pixel is stretched to 32 pixels, + to ensure the total 256 pixels. +* 2x4 palette, index=32: the top right corner +* 2x4 palette, index=63: the top right corner +* 2x4 palette, index=64: the pixel below the top left corner + +#### Using palettes with items +When registering an item, set the item definition's `palette` field to +a texture. You can also use texture modifiers. + +The `ItemStack`'s color depends on the `palette_index` field of the +stack's metadata. `palette_index` is an integer, which specifies the +index of the pixel to use. + +#### Linking palettes with nodes +When registering a node, set the item definition's `palette` field to +a texture. You can also use texture modifiers. +The node's color depends on its `param2`, so you also must set an +appropriate `drawtype`: +* `drawtype = "color"` for nodes which use their full `param2` for + palette indexing. These nodes can have 256 different colors. + The palette should contain 256 pixels. +* `drawtype = "colorwallmounted"` for nodes which use the first + five bits (most significant) of `param2` for palette indexing. + The remaining three bits are describing rotation, as in `wallmounted` + draw type. Division by 8 yields the palette index (without stretching the + palette). These nodes can have 32 different colors, and the palette + should contain 32 pixels. + Examples: + * `param2 = 17` is 2 * 8 + 1, so the rotation is 1 and the third (= 2 + 1) + pixel will be picked from the palette. + * `param2 = 35` is 4 * 8 + 3, so the rotation is 3 and the fifth (= 4 + 1) + pixel will be picked from the palette. +* `drawtype = "colorfacedir"` for nodes which use the first + three bits of `param2` for palette indexing. The remaining + five bits are describing rotation, as in `facedir` draw type. + Division by 32 yields the palette index (without stretching the + palette). These nodes can have 8 different colors, and the + palette should contain 8 pixels. + Examples: + * `param2 = 17` is 0 * 32 + 17, so the rotation is 17 and the + first (= 0 + 1) pixel will be picked from the palette. + * `param2 = 35` is 1 * 32 + 3, so the rotation is 3 and the + second (= 1 + 1) pixel will be picked from the palette. + +To colorize a node on the map, set its `param2` value (according +to the node's draw type). + +### Conversion between nodes in the inventory and the on the map +Static coloring is the same for both cases, there is no need +for conversion. + +If the `ItemStack`'s metadata contains the `color` field, it will be +lost on placement, because nodes on the map can only use palettes. + +If the `ItemStack`'s metadata contains the `palette_index` field, you +currently must manually convert between it and the node's `param2` with +custom `on_place` and `on_dig` callbacks. + +### Colored items in craft recipes +Craft recipes only support item strings, but fortunately item strings +can also contain metadata. Example craft recipe registration: + + local stack = ItemStack("wool:block") + dyed:get_meta():set_int("palette_index", 3) -- add index + minetest.register_craft({ + output = dyed:to_string(), -- convert to string + type = "shapeless", + recipe = { + "wool:block", + "dye:red", + }, + }) + +Metadata field filtering in the `recipe` field are not supported yet, +so the craft output is independent of the color of the ingredients. + +Soft texture overlay +-------------------- +Sometimes hardware coloring is not enough, because it affects the +whole tile. Soft texture overlays were added to Minetest to allow +the dynamic coloring of only specific parts of the node's texture. +For example a grass block may have colored grass, while keeping the +dirt brown. + +These overlays are 'soft', because unlike texture modifiers, the layers +are not merged in the memory, but they are simply drawn on top of each +other. This allows different hardware coloring, but also means that +tiles with overlays are drawn slower. Using too much overlays might +cause FPS loss. + +To define an overlay, simply set the `overlay_tiles` field of the node +definition. These tiles are defined in the same way as plain tiles: +they can have a texture name, color etc. +To skip one face, set that overlay tile to an empty string. + +Example (colored grass block): + + minetest.register_node("default:dirt_with_grass", { + description = "Dirt with Grass", + -- Regular tiles, as usual + -- The dirt tile disables palette coloring + tiles = {{name = "default_grass.png"}, + {name = "default_dirt.png", color = "white"}}, + -- Overlay tiles: define them in the same style + -- The top and bottom tile does not have overlay + overlay_tiles = {"", "", + {name = "default_grass_side.png", tileable_vertical = false}}, + -- Global color, used in inventory + color = "green", + -- Palette in the world + paramtype2 = "color", + palette = "default_foilage.png", + }) + Sounds ------ Only Ogg Vorbis files are supported. @@ -457,12 +622,14 @@ Examples of sound parameter tables: { gain = 1.0, -- default fade = 0.0, -- default, change to a value > 0 to fade the sound in + pitch = 1.0, -- default } -- Play locationless to one player { to_player = name, gain = 1.0, -- default fade = 0.0, -- default, change to a value > 0 to fade the sound in + pitch = 1.0, -- default } -- Play locationless to one player, looped { @@ -493,6 +660,7 @@ one player using `to_player = name,` * e.g. `{}` * e.g. `{name = "default_place_node"}` * e.g. `{name = "default_place_node", gain = 1.0}` +* e.g. `{name = "default_place_node", gain = 1.0, pitch = 1.0}` Registered definitions of stuff ------------------------------- @@ -515,7 +683,7 @@ the global `minetest.registered_*` tables. * `minetest.unregister_item(name)` * Unregisters the item name from engine, and deletes the entry with key * `name` from `minetest.registered_items` and from the associated item - * table according to its nature: minetest.registered_nodes[] etc + * table according to its nature: `minetest.registered_nodes[]` etc * `minetest.register_biome(biome definition)` * returns an integer uniquely identifying the registered biome @@ -593,9 +761,9 @@ They are represented by a table: {name="name", param1=num, param2=num} -`param1` and `param2` are 8-bit integers. The engine uses them for certain -automated functions. If you don't use these functions, you can use them to -store arbitrary values. +`param1` and `param2` are 8-bit integers ranging from 0 to 255. The engine uses +them for certain automated functions. If you don't use these functions, you can +use them to store arbitrary values. The functions of `param1` and `param2` are determined by certain fields in the node definition: @@ -664,15 +832,6 @@ node definition: ^ Only valid for "glasslike_framed" or "glasslike_framed_optional" drawtypes. param2 defines 64 levels of internal liquid. Liquid texture is defined using `special_tiles = {"modname_tilename.png"},` - collision_box = { - type = "fixed", - fixed = { - {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, - }, - }, - ^ defines list of collision boxes for the node. If empty, collision boxes - will be the same as nodeboxes, in case of any other nodes will be full cube - as in the example above. Nodes can also contain extra data. See "Node Metadata". @@ -823,6 +982,7 @@ If no flags are specified (or defaults is), 2D noise is eased and 3D noise is no Accumulates the absolute value of each noise gradient result. Noise parameters format example for 2D or 3D perlin noise or perlin noise maps: + np_terrain = { offset = 0, scale = 1, @@ -833,8 +993,8 @@ Noise parameters format example for 2D or 3D perlin noise or perlin noise maps: lacunarity = 2.0, flags = "defaults, absvalue" } - ^ A single noise parameter table can be used to get 2D or 3D noise, - when getting 2D noise spread.z is ignored. + ^ A single noise parameter table can be used to get 2D or 3D noise, + when getting 2D noise spread.z is ignored. Ore types @@ -906,14 +1066,15 @@ to small changes. The following is a decent set of parameters to work from: }, noise_threshold = 1.6 -WARNING: Use this ore type *very* sparingly since it is ~200x more +**WARNING**: Use this ore type *very* sparingly since it is ~200x more computationally expensive than any other ore. Ore attributes -------------- See section "Flag Specifier Format". -Currently supported flags: `absheight` +Currently supported flags: +`absheight`, `puff_cliffs`, `puff_additive_composition`. ### `absheight` Also produce this same ore between the height range of `-y_max` and `-y_min`. @@ -969,6 +1130,7 @@ in the form of a table. This table specifies the following fields: previous contents (default: false) About probability values: + * A probability value of `0` or `1` means that node will never appear (0% chance). * A probability value of `254` or `255` means the node will always appear (100% chance). * If the probability value `p` is greater than `1`, then there is a @@ -1123,16 +1285,32 @@ There are three kinds of items: nodes, tools and craftitems. things according to `tool_capabilities`. * Craftitem (`register_craftitem`): A miscellaneous item. +### Amount and wear +All item stacks have an amount between 0 to 65535. It is 1 by +default. Tool item stacks can not have an amount greater than 1. + +Tools use a wear (=damage) value ranging from 0 to 65535. The +value 0 is the default and used is for unworn tools. The values +1 to 65535 are used for worn tools, where a higher value stands for +a higher wear. Non-tools always have a wear value of 0. + ### Item formats Items and item stacks can exist in three formats: Serializes, table format and `ItemStack`. #### Serialized -This is called "stackstring" or "itemstring": +This is called "stackstring" or "itemstring". It is a simple string with +1-3 components: the full item identifier, an optional amount and an optional +wear value. Syntax: -* e.g. `'default:dirt 5'` -* e.g. `'default:pick_wood 21323'` -* e.g. `'default:apple'` + [[ ]] + +Examples: + +* `'default:apple'`: 1 apple +* `'default:dirt 5'`: 5 dirt +* `'default:pick_stone'`: a new stone pickaxe +* `'default:pick_wood 1 21323'`: a wooden pickaxe, ca. 1/3 worn out #### Table format Examples: @@ -1226,6 +1404,9 @@ Another example: Make red wool from white wool and red dye: ### Special groups * `immortal`: Disables the group damage system for an entity +* `punch_operable`: For entities; disables the regular damage mechanism for + players punching it by hand or a non-tool item, so that it can do something + else than take damage. * `level`: Can be used to give an additional sense of progression in the game. * A larger level will cause e.g. a weapon of a lower level make much less damage, and get worn out much faster, or not be able to get drops @@ -1264,6 +1445,7 @@ Another example: Make red wool from white wool and red dye: ### Examples of custom groups Item groups are often used for defining, well, _groups of items_. + * `meat`: any meat-kind of a thing (rating might define the size or healing ability or be irrelevant -- it is not defined as of yet) * `eatable`: anything that can be eaten. Rating might define HP gain in half @@ -1484,7 +1666,7 @@ Item metadata only contains a key-value store. Some of the values in the key-value store are handled specially: -* `description`: Set the itemstack's description. Defaults to idef.description +* `description`: Set the item stack's description. Defaults to `idef.description` * `color`: A `ColorString`, which sets the stack's color. * `palette_index`: If the item has a palette, this is used to get the current color from the palette. @@ -1546,7 +1728,7 @@ examples. #### `container[,]` * Start of a container block, moves all physical elements in the container by (X, Y) -* Must have matching container_end +* Must have matching `container_end` * Containers can be nested, in which case the offsets are added (child containers are relative to parent containers) @@ -1631,7 +1813,7 @@ examples. #### `field[,;,;;