Luanti Voxel Game Engine

repository·master·Indexed 11 days ago

https://github.com/luanti-org/luanti

A free, open-source voxel game engine designed for easy modding and game creation. The documentation covers engine compilation across GNU/Linux, Windows, and MacOS using CMake, as well as detailed guides for server-side modding (Lua API), client-side content, mainmenu scripting, and low-level world formats and network protocols. It includes resources for engine developers, such as IDE configuration, profiling, and a roadmap for version 6.0.0.

Tokens
116.4K
Snippets
306
Records
546
Agent score
95%

What's inside Luanti

  1. Overview of Luanti

    master
    Luanti (formerly Minetest) is a free, open-source voxel game engine designed for easy modding and game creation. It provides a platform for developers to build games and for players to experience voxel-based worlds.
  2. Overview of TinierGLTF

    master

    TinierGLTF is a lightweight, modern glTF deserializer designed for C++17. It functions by mapping glTF JSON objects directly into appropriate C++ structures. It is specifically designed to be safe for loading untrusted input and is tailored for use within Luanti.

    Key Capabilities:

    • Deserialization: Maps JSON glTF data to C++ structures.
    • Safety: Designed to handle untrusted input safely.
    • Schema Validation: Validates input against the glTF JSON schema (including indices and miscellaneous fields).

    Limitations (What it does NOT do):

    • No Serialization: It cannot convert C++ structures back into glTF files.
    • No Image Loading: It does not handle the loading or decoding of image data.
    • No Resource Resolution: It does not resolve external file references or URIs.
    • No Extension Support: It does not support glTF extensions.
  3. Use the Test Nodes mod for engine feature testing

    master

    The testnodes mod is a development utility containing minimal nodes designed to isolate and test specific Luanti engine features. Use these nodes to verify implementation of:

    • drawtypes: Testing how different node textures and rendering modes behave.
    • paramtype2: Testing node interaction parameters (e.g., how nodes react to being clicked or used).
    • Node Properties: Verifying specific physics or interaction properties such as damage, drowning, falling, and other engine-level attributes.

    Because these nodes are kept as minimal as possible, they are ideal for debugging specific engine behaviors without the interference of complex node logic.

  4. Test ABM behaviors with the testabms mod

    master

    The testabms mod provides a set of nodes designed to test various Area Break Modification (ABM) behaviors in Luanti. By placing these specific nodes in a game world, you can verify how different ABM fields affect node behavior.

    Supported ABM field tests include:

    • chance: Tests probabilistic execution.
    • interval: Tests execution based on time intervals.
    • min_y and max_y: Tests execution restricted to specific vertical ranges.
    • neighbor: Tests execution based on the presence of specific neighbors.
    • without_neighbor: Tests execution based on the absence of specific neighbors.
  5. Understand texture loading priority

    master

    Luanti looks up texture names in a specific order. If a texture is defined in multiple places, the one higher in the list takes precedence. The order from lowest to highest priority is:

    1. Client: $path_share/textures/base/pack
    2. Server: Mod-provided textures (in their textures directory)
    3. Server: Game textures (in <game path>/textures)
    4. Server: $path_share/textures/server
    5. Server: override.txt in the path specified by the texture_path setting
    6. Server: override.txt in <game path>/textures
    7. Client: Path specified by the texture_path setting
    8. Client: override.txt in the path specified by the texture_path setting
  6. Understand item and stack identifiers

    master

    Luanti uses several special identifiers to represent specific states or empty items:

    • "unknown": Represents any item that has not been registered.
    • "air": The node that appears where no other node exists.
    • "ignore": Represents unloaded mapblocks or nodes not yet set by the map generator. It also appears outside map boundaries.
    • "" (empty string): Represents the player's hand when no item is wielded. It acts as a fallback for range and tool capabilities. Note that "" cannot be used as an ItemStack object because it represents an empty stack and cannot be stored in an inventory.
  7. Follow naming conventions for registered names

    master

    To prevent name collisions, all registered textual names (items, nodes, entities) should follow the format: modname:<whatever>

    Where <whatever> consists of characters a-zA-Z0-9_.

    Overriding names: You can override a registration from another mod by prefixing the name with a colon (:). For example, to redefine experimental:tnt, use: :experimental:tnt (Note: The mod performing the override must have experimental listed as a dependency).

    experimental:tnt
  8. Configure Ore Generation Types

    master

    Luanti supports several ore generation types to control how ores are distributed in the world. Each type uses different parameters for shape and density.

    Available Ore Types

    • scatter: Randomly chooses locations to generate clusters. Use noise_params and noise_threshold to create non-uniform distributions.
    • sheet: Creates a blob-shaped sheet using 2D value noise. It consists of vertical columns with heights between column_height_min and column_height_max. Use column_midpoint_factor (0 to 1) to control if columns grow upward (1), downward (0), or both (0.5).
    • puff: Creates cloud-like puffs using 2D noise. Vertical displacement is controlled by np_puff_top and np_puff_bottom noise parameters.
    • blob: Creates deformed spheres using 3D value noise. Maximum size is determined by clust_size.
    • vein: Creates veins using the intersection of two 3D value noise instances. This type is highly sensitive to parameters and is ~200x more computationally expensive than other types. Use random_factor (default 1) to vary density.
    • stratum: Creates a continuous, undulating horizontal layer across the world. Use noise_params for the Y coordinate of the midpoint and np_stratum_thickness (or stratum_thickness for constant thickness) for vertical thickness. Use y_min and y_max to limit generation range.
  9. Use Mod Channels for Communication

    master

    Mod channels allow for asynchronous communication between the client and server mods.

    1. Join a channel: Use core.mod_channel_join(channel_name). Note that this is asynchronous; the client must wait for the server to acknowledge the join request.
    2. Listen for messages: Register a callback using core.register_on_modchannel_message(function(channel_name, sender, message)).
    3. Listen for signals: Register a callback using core.register_on_modchannel_signal(function(channel_name, signal)) to react to channel state changes.

    Signal IDs:

    • 0: join_ok
    • 1: join_failed
    • 2: leave_ok
    • 3: leave_failed
    • 4: event_on_not_joined_channel
    • 5: state_changed
  10. Understand Fractal Value Noise and NoiseParams

    master

    Fractal value noise is used during map generation to create natural-looking variations (terrain, biomes, ores) by combining multiple 'octaves' of simple noise. Each octave adds finer detail.

    NoiseParams Reference

    When configuring noise, you use a NoiseParams table with the following keys:

    • offset: Added to the final result. Can be positive or negative.
    • scale: Multiplier for the combined octaves. Can be positive or negative.
    • spread: A vector {x, y, z} representing the 'wavelength' or scale of the largest structures. Positive numbers only.
    • seed: An integer in the [s32] range. Identical seeds produce identical patterns.
    • octaves: Number of noise generators (1 to 65535). Higher values add detail but increase CPU load. Warning: If any octave's wavelength falls below 1, an error occurs.
    • persistence (or persist): Controls 'roughness'. Determines how much the amplitude of each octave decreases. Typically between 0.3 and 1.0 (0.5 is common).
    • lacunarity: Controls how much the wavelength decreases per octave. Must be $\ge 1.0$. Common value is 2.0.
    • flags: A comma-separated string of supported flags:
      • defaults: Enables auto-selection of eased/not-eased.
      • eased: Applies a quintic S-curve to noise gradients for smooth, rolling noise. (2D is eased by default; 3D is not eased by default to save performance).
      • noeased: Disables easing for sharp, gridded noise.
      • absvalue: Uses the absolute value of each octave when combining them.

    Usage Example

    np_terrain = {
        offset = 0,
        scale = 1,
        spread = {x = 500, y = 500, z = 500},
        seed = 571347,
        octaves = 5,
        persistence = 0.63,
        lacunarity = 2.0,
        flags = "defaults, absvalue",
    }
    np_terrain = {
        offset = 0,
        scale = 1,
        spread = {x = 500, y = 500, z = 500},
        seed = 571347,
        octaves = 5,
        persistence = 0.63,
        lacunarity = 2.0,
        flags = "defaults, absvalue",
    }