code:
# This file contains all settings displayed in the settings menu.
#
# General format:
#    name (Readable name) type type_args
#
# Note that the parts are separated by exactly one space
#
# `type` can be:
#    - int
#    - string
#    - bool
#    - float
#    - enum
#    - path
#    - key (will be ignored in GUI, since a special key change dialog exists)
#    - flags
#    - noise_params
#
# `type_args` can be:
#   * int:
#            - default
#            - default min max
#   * string:
#            - default (if default is not specified then "" is set)
#   * bool:
#            - default
#   * float:
#            - default
#            - default min max
#   * enum:
#            - default value1,value2,...
#   * path:
#            - default (if default is not specified then "" is set)
#   * key:
#            - default
#   * flags:
#            Flags are always separated by comma without spaces.
#            - default possible_flags
#   * noise_params:
#            TODO: these are currently treated like strings
#
# Comments directly above a setting are bound to this setting.
# All other comments are ignored.
#
# Comments and (Readable name) are handled by gettext.
# Comments should be complete sentences that describe the setting and possibly
#  give the user additional useful insight.
# Sections are marked by a single line in the format: [Section Name]
# Sub-section are marked by adding * in front of the section name: [*Sub-section]
# Sub-sub-sections have two * etc.
# There shouldn't be too much settings per category; settings that shouldn't be
#  modified by the "average user" should be in (sub-)categories called "Advanced".

[Client]

[*Controls]
#    If enabled, you can place blocks at the position (feet + eye level) where you stand.
#    This is helpful when working with nodeboxes in small areas.
enable_build_where_you_stand (Build inside player) bool false

#    Player is able to fly without being affected by gravity.
#    This requires the "fly" privilege on the server.
free_move (Flying) bool false

#    Fast movement (via use key).
#    This requires the "fast" privilege on the server.
fast_move (Fast movement) bool false

#    If enabled together with fly mode, player is able to fly through solid nodes.
#    This requires the "noclip" privilege on the server.
noclip (Noclip) bool false

#    Smooths camera when looking around. Also called look or mouse smoothing.
#    Useful for recording videos.
cinematic (Cinematic mode) bool false

#    Smooths rotation of camera. 0 to disable.
camera_smoothing (Camera smoothing) float 0.0 0.0 0.99

#    Smooths rotation of camera in cinematic mode. 0 to disable.
cinematic_camera_smoothing (Camera smoothing in cinematic mode) float 0.7 0.0 0.99

#    Invert vertical mouse movement.
invert_mouse (Invert mouse) bool false

#    Mouse sensitivity multiplier.
mouse_sensitivity (Mouse sensitivity) float 0.2

#    If enabled, "use" key instead of "sneak" key is used for climbing down and descending.
aux1_descends (Key use for climbing/descending) bool false

#    Double-tapping the jump key toggles fly mode.
doubletap_jump (Double tap jump for fly) bool false

#    If disabled "use" key is used to fly fast if both fly and fast mode are enabled.
always_fly_fast (Always fly and fast) bool true

#    The time in seconds it takes between repeated right clicks when holding the right mouse button.
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 (Continuous forward) bool false

#    Enable Joysticks
enable_joysticks (Enable Joysticks) bool false

#    The identifier of the joystick to use
joystick_id (Joystick ID) int 0

#    The type of joystick
joystick_type (Joystick Type) enum auto auto,generic,xbox

#    The time in seconds it takes between repeated events
#    when holding down a joystick button combination.
repeat_joystick_button_time (Joystick button repetition interval) float 0.17

#    The sensitivity of the joystick axes for moving the
#    ingame view frustum around.
joystick_frustum_sensitivity (Joystick frustum sensitivity) float 170

#    Key for moving the player forward.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_forward (Forward key) key KEY_KEY_W

#    Key for moving the player backward.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_backward (Backward key) key KEY_KEY_S

#    Key for moving the player left.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_left (Left key) key KEY_KEY_A

#    Key for moving the player right.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_right (Right key) key KEY_KEY_D

#    Key for jumping.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_jump (Jump key) key KEY_SPACE

#    Key for sneaking.
#    Also used for climbing down and descending in water if aux1_descends is disabled.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_sneak (Sneak key) key KEY_LSHIFT

#    Key for opening the inventory.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_inventory (Inventory key) key KEY_KEY_I

#    Key for moving fast in fast mode.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_special1 (Use key) key KEY_KEY_E

#    Key for opening the chat window.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_chat (Chat key) key KEY_KEY_T

#    Key for opening the chat window to type commands.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_cmd (Command key) key /

#    Key for opening the chat window to type local commands.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_cmd_local (Command key) key .

#    Key for toggling unlimited view range.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_rangeselect (Range select key) key KEY_KEY_R

#    Key for toggling flying.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_freemove (Fly key) key KEY_KEY_K

#    Key for toggling fast mode.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_fastmove (Fast key) key KEY_KEY_J

#    Key for toggling noclip mode.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_noclip (Noclip key) key KEY_KEY_H

#    Key for selecting the next item in the hotbar.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_hotbar_next (Hotbar next key) key KEY_KEY_N

#    Key for selecting the previous item in the hotbar.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_hotbar_previous (Hotbar previous key) key KEY_KEY_B

#    Key for muting the game.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_mute (Mute key) key KEY_KEY_M

#    Key for increasing the volume.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_increase_volume (Inc. volume key) key

#    Key for decreasing the volume.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_decrease_volume (Dec. volume key) key

#    Key for toggling autorun.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_autorun (Autorun key) key

#    Key for toggling cinematic mode.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_cinematic (Cinematic mode key) key

#    Key for toggling display of minimap.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_minimap (Minimap key) key KEY_F9

#    Key for taking screenshots.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_screenshot (Screenshot) key KEY_F12

#    Key for dropping the currently selected item.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_drop (Drop item key) key KEY_KEY_Q

#    Key to use view zoom when possible.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_zoom (View zoom key) key KEY_KEY_Z

#    Key for toggling the display of the HUD.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_toggle_hud (HUD toggle key) key KEY_F1

#    Key for toggling the display of the chat.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_toggle_chat (Chat toggle key) key KEY_F2

#    Key for toggling the display of the large chat console.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_console (Large chat console key) key KEY_F10

#    Key for toggling the display of the fog.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_toggle_force_fog_off (Fog toggle key) key KEY_F3

#    Key for toggling the camera update. Only used for development
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_toggle_update_camera (Camera update toggle key) key

#    Key for toggling the display of debug info.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_toggle_debug (Debug info toggle key) key KEY_F5

#    Key for toggling the display of the profiler. Used for development.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_toggle_profiler (Profiler toggle key) key KEY_F6

#    Key for switching between first- and third-person camera.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_camera_mode (Toggle camera mode key) key KEY_F7

#    Key for increasing the viewing range.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_increase_viewing_range_min (View range increase key) key +

#    Key for decreasing the viewing range.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_decrease_viewing_range_min (View range decrease key) key -

#    Key for printing debug stacks. Used for development.
#    See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
keymap_print_debug_stacks (Print stacks) key KEY_KEY_P

[*Network]

#    Address to connect to.
#    Leave this blank to start a local server.
#    Note that the address field in the main menu overrides this setting.
address (Server address) string

#    Port to connect to (UDP).
#    Note that the port field in the main menu overrides this setting.
remote_port (Remote port) int 30000 1 65535

#    Whether to support older servers before protocol version 25.
#    Enable if you want to connect to 0.4.12 servers and before.
#    Servers starting with 0.4.13 will work, 0.4.12-dev servers may work.
#    Disabling this option will protect your password better.
send_pre_v25_init (Support older servers) bool false

#    Save the map received by the client on disk.
enable_local_map_saving (Saving map received from server) bool false

#    Show entity selection boxes
show_entity_selectionbox (Show entity selection boxes) bool true

#    Enable usage of remote media server (if provided by server).
#    Remote servers offer a significantly faster way to download media (e.g. textures)
#    when connecting to the server.
enable_remote_media_server (Connect to external media server) bool true

#    Enable Lua modding support on client.
#    This support is experimental and API can change.
enable_client_modding (Client modding) bool false

#    URL to the server list displayed in the Multiplayer Tab.
serverlist_url (Serverlist URL) string servers.minetest.net

#    File in client/serverlist/ that contains your favorite servers displayed in the Multiplayer Tab.
serverlist_file (Serverlist file) string favoriteservers.txt

#    Maximum size of the out chat queue. 0 to disable queueing and -1 to make the queue size unlimited
max_out_chat_queue_size (Maximum size of the out chat queue) int 20

[*Graphics]

[**In-Game]

[***Basic]

#    Enable VBO
enable_vbo (VBO) bool true

#    Whether to fog out the end of the visible area.
enable_fog (Fog) bool true

#    Leaves style:
#    -   Fancy:  all faces visible
#    -   Simple: only outer faces, if defined special_tiles are used
#    -   Opaque: disable transparency
leaves_style (Leaves style) enum fancy fancy,simple,opaque

#    Connects glass if supported by node.
connected_glass (Connect glass) bool false

#    Enable smooth lighting with simple ambient occlusion.
#    Disable for speed or for different looks.
smooth_lighting (Smooth lighting) bool true

#    Clouds are a client side effect.
enable_clouds (Clouds) bool true

#    Use 3D cloud look instead of flat.
enable_3d_clouds (3D clouds) bool true

#    Method used to highlight selected object.
node_highlighting (Node highlighting) enum box box,halo,none

#    Adds particles when digging a node.
enable_particles (Digging particles) bool true

[***Filtering]

#    Use mip mapping to scale textures. May slightly increase performance.
mip_map (Mipmapping) bool false

#    Use anisotropic filtering when viewing at textures from an angle.
anisotropic_filter (Anisotropic filtering) bool false

#    Use bilinear filtering when scaling textures.
bilinear_filter (Bilinear filtering) bool false

#    Use trilinear filtering when scaling textures.
trilinear_filter (Trilinear filtering) bool false

#    Filtered textures can blend RGB values with fully-transparent neighbors,
#    which PNG optimizers usually discard, sometimes resulting in a dark or
#    light edge to transparent textures.  Apply this filter to clean that up
#    at texture load time.
texture_clean_transparent (Clean transparent textures) bool false

#    When using bilinear/trilinear/anisotropic filters, low-resolution textures
#    can be blurred, so automatically upscale them with nearest-neighbor
#    interpolation to preserve crisp pixels.  This sets the minimum texture size
#    for the upscaled textures; higher values look sharper, but require more
#    memory.  Powers of 2 are recommended.  Setting this higher than 1 may not
#    have a visible effect unless bilinear/trilinear/anisotropic filtering is
#    enabled.
texture_min_size (Minimum texture size for filters) int 64

#    Experimental option, might cause visible spaces between blocks
#    when set to higher number than 0.
fsaa (FSAA) enum 0 0,1,2,4,8,16

#    Undersampling is similar to using lower screen resolution, but it applies
#    to the game world only, keeping the GUI intact.
#    It should give significant performance boost at the cost of less detailed image.
undersampling (Undersampling) enum 0 0,2,3,4

[***Shaders]

#    Shaders allow advanced visual effects and may increase performance on some video cards.
#    This only works with the OpenGL video backend.
enable_shaders (Shaders) bool true

#    Path to shader directory. If no path is defined, default location will be used.
shader_path (Shader path) path

[****Tone Mapping]

#    Enables filmic tone mapping
tone_mapping (Filmic tone mapping) bool false

[****Bumpmapping]

#    Enables bumpmapping for textures. Normalmaps need to be supplied by the texture pack
#    or need to be auto-generated.
#    Requires shaders to be enabled.
enable_bumpmapping (Bumpmapping) bool false

#    Enables on the fly normalmap generation (Emboss effect).
#    Requires bumpmapping to be enabled.
generate_normalmaps (Generate normalmaps) bool false

#    Strength of generated normalmaps.
normalmaps_strength (Normalmaps strength) float 0.6

#    Defines sampling step of texture.
#    A higher value results in smoother normal maps.
normalmaps_smooth (Normalmaps sampling) int 0 0 2

[****Parallax Occlusion]

#    Enables parallax occlusion mapping.
#    Requires shaders to be enabled.
enable_parallax_occlusion (Parallax occlusion) bool false

#    0 = parallax occlusion with slope information (faster).
#    1 = relief mapping (slower, more accurate).
parallax_occlusion_mode (Parallax occlusion mode) int 1 0 1

#    Strength of parallax.
3d_paralax_strength (Parallax occlusion strength) float 0.025

#    Number of parallax occlusion iterations.
parallax_occlusion_iterations (Parallax occlusion iterations) int 4

#    Overall scale of parallax occlusion effect.
parallax_occlusion_scale (Parallax occlusion Scale) float 0.08

#    Overall bias of parallax occlusion effect, usually scale/2.
parallax_occlusion_bias (Parallax occlusion bias) float 0.04

[****Waving Nodes]

#    Set to true enables waving water.
#    Requires shaders to be enabled.
enable_waving_water (Waving water) bool false

water_wave_height (Waving water height) float 1.0

water_wave_length (Waving water length) float 20.0

water_wave_speed (Waving water speed) float 5.0

#    Set to true enables waving leaves.
#    Requires shaders to be enabled.
enable_waving_leaves (Waving leaves) bool false

#    Set to true enables waving plants.
#    Requires shaders to be enabled.
enable_waving_plants (Waving plants) bool false

[***Advanced]

#    If FPS would go higher than this, limit it by sleeping
#    to not waste CPU power for no benefit.
fps_max (Maximum FPS) int 60

#    Maximum FPS when game is paused.
pause_fps_max (FPS in pause menu) int 20

#    View distance in nodes.
viewing_range (Viewing range) int 100 20 4000

#   Camera near plane distance in nodes, between 0 and 0.5
#   Most users will not need to change this.
#   Increasing can reduce artifacting on weaker GPUs.
#   0.1 = Default, 0.25 = Good value for weaker tablets.
near_plane (Near plane) float 0.1 0 0.5

#    Width component of the initial window size.
screenW (Screen width) int 800

#    Height component of the initial window size.
screenH (Screen height) int 600

#    Save window size automatically when modified.
autosave_screensize (Autosave Screen Size) bool true

#    Fullscreen mode.
fullscreen (Full screen) bool false

#    Bits per pixel (aka color depth) in fullscreen mode.
fullscreen_bpp (Full screen BPP) int 24

#    Vertical screen synchronization.
vsync (V-Sync) bool false

#    Field of view in degrees.
fov (Field of view) int 72 30 160

#    Field of view while zooming in degrees.
#    Requires to be allowed by server-sided mods.
zoom_fov (Field of view for zoom) int 15 7 160

#    Adjust the gamma encoding for the light tables. Higher numbers are brighter.
#    This setting is for the client only and is ignored by the server.
display_gamma (Gamma) float 2.2 1.0 3.0

#    Path to texture directory. All textures are first searched from here.
texture_path (Texture path) path

#    The rendering back-end for Irrlicht.
video_driver (Video driver) enum opengl null,software,burningsvideo,direct3d8,direct3d9,opengl

#    Height on which clouds are appearing.
cloud_height (Cloud height) int 120

#    Radius of cloud area stated in number of 64 node cloud squares.
#    Values larger than 26 will start to produce sharp cutoffs at cloud area corners.
cloud_radius (Cloud radius) int 12

#    Enable view bobbing and amount of view bobbing.
#    For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double.
view_bobbing_amount (View bobbing factor) float 1.0

#    Multiplier for fall bobbing.
#    For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double.
fall_bobbing_amount (Fall bobbing factor) float 0.0

#    3D support.
#    Currently supported:
#    -    none: no 3d output.
#    -    anaglyph: cyan/magenta color 3d.
#    -    interlaced: odd/even line based polarisation screen support.
#    -    topbottom: split screen top/bottom.
#    -    sidebyside: split screen side by side.
#    -    pageflip: quadbuffer based 3d.
3d_mode (3D mode) enum none none,anaglyph,interlaced,topbottom,sidebyside,pageflip

#    In-game chat console height, between 0.1 (10%) and 1.0 (100%).
console_height (Console height) float 1.0 0.1 1.0

#    In-game chat console background color (R,G,B).
console_color (Console color) string (0,0,0)

#    In-game chat console background alpha (opaqueness, between 0 and 255).
console_alpha (Console alpha) int 200 0 255

#    Selection box border color (R,G,B).
selectionbox_color (Selection box color) string (0,0,0)

#    Width of the selectionbox's lines around nodes.
selectionbox_width (Selection box width) int 2 1 5

#    Crosshair color (R,G,B).
crosshair_color (Crosshair color) string (255,255,255)

#    Crosshair alpha (opaqueness, between 0 and 255).
crosshair_alpha (Crosshair alpha) int 255 0 255

#    Whether node texture animations should be desynchronized per mapblock.
desynchronize_mapblock_texture_animation (Desynchronize block animation) bool true

#    Maximum proportion of current window to be used for hotbar.
#    Useful if there's something to be displayed right or left of hotbar.
hud_hotbar_max_width (Maximum hotbar width) float 1.0

#    Modifies the size of the hudbar elements.
hud_scaling (HUD scale factor) float 1.0

#    Enables caching of facedir rotated meshes.
enable_mesh_cache (Mesh cache) bool false

#    Delay between mesh updates on the client in ms. Increasing this will slow
#    down the rate of mesh updates, thus reducing jitter on slower clients.
mesh_generation_interval (Mapblock mesh generation delay) int 0 0 50

#    Size of the MapBlock cache of the mesh generator. Increasing this will
#    increase the cache hit %, reducing the data being copied from the main
#    thread, thus reducing jitter.
meshgen_block_cache_size (Mapblock mesh generator's MapBlock cache size MB) int 20 0 1000

#    Enables minimap.
enable_minimap (Minimap) bool true

#    Shape of the minimap. Enabled = round, disabled = square.
minimap_shape_round (Round minimap) bool true

#    True = 256
#    False = 128
#    Useable to make minimap smoother on slower machines.
minimap_double_scan_height (Minimap scan height) bool true

#    Make fog and sky colors depend on daytime (dawn/sunset) and view direction.
directional_colored_fog (Colored fog) bool true

#    The strength (darkness) of node ambient-occlusion shading.
#    Lower is darker, Higher is lighter. The valid range of values for this
#    setting is 0.25 to 4.0 inclusive. If the value is out of range it will be
#    set to the nearest valid value.
ambient_occlusion_gamma (Ambient occlusion gamma) float 2.2 0.25 4.0

#    Enables animation of inventory items.
inventory_items_animations (Inventory items animations) bool false

#    Android systems only: Tries to create inventory textures from meshes
#    when no supported render was found.
inventory_image_hack (Inventory image hack) bool false

#    Fraction of the visible distance at which fog starts to be rendered
fog_start (Fog Start) float 0.4 0.0 0.99

#    Makes all liquids opaque
opaque_water (Opaque liquids) bool false

[**Menus]

#    Use a cloud animation for the main menu background.
menu_clouds (Clouds in menu) bool true

#    Scale gui by a user specified value.
#    Use a nearest-neighbor-anti-alias filter to scale the GUI.
#    This will smooth over some of the rough edges, and blend
#    pixels when scaling down, at the cost of blurring some
#    edge pixels when images are scaled by non-integer sizes.
gui_scaling (GUI scaling) float 1.0

#    When gui_scaling_filter is true, all GUI images need to be
#    filtered in software, but some images are generated directly
#    to hardware (e.g. render-to-texture for nodes in inventory).
gui_scaling_filter (GUI scaling filter) bool false

#    When gui_scaling_filter_txr2img is true, copy those images
#    from hardware to software for scaling.  When false, fall back
#    to the old scaling method, for video drivers that don't
#    properly support downloading textures back from hardware.
gui_scaling_filter_txr2img (GUI scaling filter txr2img) bool true

#    Delay showing tooltips, stated in milliseconds.
tooltip_show_delay (Tooltip delay) int 400

#    Whether freetype fonts are used, requires freetype support to be compiled in.
freetype (Freetype fonts) bool true

#    Path to TrueTypeFont or bitmap.
font_path (Font path) path fonts/liberationsans.ttf

font_size (Font size) int 16

#    Font shadow offset, if 0 then shadow will not be drawn.
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_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_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

#    Path to save screenshots at.
screenshot_path (Screenshot folder) path

#    Format of screenshots.
screenshot_format (Screenshot format) enum png png,jpg,bmp,pcx,ppm,tga

#    Screenshot quality. Only used for JPEG format.
#    1 means worst quality; 100 means best quality.
#    Use 0 for default quality.
screenshot_quality (Screenshot quality) int 0 0 100

[**Advanced]

#    Adjust dpi configuration to your screen (non X11/Android only) e.g. for 4k screens.
screen_dpi (DPI) int 72

#    Windows systems only: Start Minetest with the command line window in the background.
#    Contains the same information as the file debug.txt (default name).
enable_console (Enable console window) bool false

[*Sound]

enable_sound (Sound) bool true

sound_volume (Volume) float 0.7 0.0 1.0

[*Advanced]

#    Timeout for client to remove unused map data from memory.
client_unload_unused_data_timeout (Mapblock unload timeout) int 600

#    Maximum number of mapblocks for client to be kept in memory.
#    Set to -1 for unlimited amount.
client_mapblock_limit (Mapblock limit) int 5000

#    Whether to show the client debug info (has the same effect as hitting F5).
show_debug (Show debug info) bool false

[Server / Singleplayer]

#    Name of the server, to be displayed when players join and in the serverlist.
server_name (Server name) string Minetest server

#    Description of server, to be displayed when players join and in the serverlist.
server_description (Server description) string mine here

#    Domain name of server, to be displayed in the serverlist.
server_address (Server address) string game.minetest.net

#    Homepage of server, to be displayed in the serverlist.
server_url (Server URL) string http://minetest.net

#    Automaticaly report to the serverlist.
server_announce (Announce server) bool false

#    Announce to this serverlist.
#    If you want to announce your ipv6 address, use  serverlist_url = v6.servers.minetest.net.
serverlist_url (Serverlist URL) string servers.minetest.net

# 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]

#    Network port to listen (UDP).
#    This value will be overridden when starting from the main menu.
port (Server port) int 30000

#    The network interface that the server listens on.
bind_address (Bind address) string

#    Enable to disallow old clients from connecting.
#    Older clients are compatible in the sense that they will not crash when connecting
#    to new servers, but they may not support all new features that you are expecting.
strict_protocol_version_checking (Strict protocol checking) bool false

#    Specifies URL from which client fetches media instead of using UDP.
#    $filename should be accessible from $remote_media$filename via cURL
#    (obviously, remote_media should end with a slash).
#    Files that are not present will be fetched the usual way.
remote_media (Remote media) string

#    Enable/disable running an IPv6 server.  An IPv6 server may be restricted
#    to IPv6 clients, depending on system configuration.
#    Ignored if bind_address is set.
ipv6_server (IPv6 server) bool false

[**Advanced]

#    Maximum number of blocks that are simultaneously sent per client.
max_simultaneous_block_sends_per_client (Maximum simultaneous block sends per client) int 10

#   Maximum number of blocks that are simultaneously sent in total.
max_simultaneous_block_sends_server_total (Maximum simultaneous block sends total) int 40

#    To reduce lag, block transfers are slowed down when a player is building something.
#    This determines how long they are slowed down after placing or removing a node.
full_block_send_enable_min_time_from_building (Delay in sending blocks after building) float 2.0

#    Maximum number of packets sent per send step, if you have a slow connection
#    try reducing it, but don't reduce it to a number below double of targeted
#    client number.
max_packets_per_iteration (Max. packets per iteration) int 1024

[*Game]

#    Default game when creating a new world.
#    This will be overridden when creating a world from the main menu.
default_game (Default game) string minetest

#    Message of the day displayed to players connecting.
motd (Message of the day) string

#    Maximum number of players that can connect simultaneously.
max_users (Maximum users) int 15

#    World directory (everything in the world is stored here).
#    Not needed if starting from the main menu.
map-dir (Map directory) path

#    Time in seconds for item entity (dropped items) to live.
#    Setting it to -1 disables the feature.
item_entity_ttl (Item entity TTL) int 900

#    If enabled, show the server status message on player connection.
show_statusline_on_connect (Status message on connection) bool true

#    Enable players getting damage and dying.
enable_damage (Damage) bool false

#    Enable creative mode for new created maps.
creative_mode (Creative) bool false

#    A chosen map seed for a new map, leave empty for random.
#    Will be overridden when creating a new world in the main menu.
fixed_map_seed (Fixed map seed) string

#    New users need to input this password.
default_password (Default password) string

#    The privileges that new users automatically get.
#    See /privs in game for a full list on your server and mod configuration.
default_privs (Default privileges) string interact, shout

#    Privileges that players with basic_privs can grant
basic_privs (Basic Privileges) string interact, shout

#    Whether players are shown to clients without any range limit.
#    Deprecated, use the setting player_transfer_distance instead.
unlimited_player_transfer_distance (Unlimited player transfer distance) bool true

#    Defines the maximal player transfer distance in blocks (0 = unlimited).
player_transfer_distance (Player transfer distance) int 0

#    Whether to allow players to damage and kill each other.
enable_pvp (Player versus Player) bool true

#    If this is set, players will always (re)spawn at the given position.
static_spawnpoint (Static spawnpoint) string

#    If enabled, new players cannot join with an empty password.
disallow_empty_password (Disallow empty passwords) bool false

#    If enabled, disable cheat prevention in multiplayer.
disable_anticheat (Disable anticheat) bool false

#    If enabled, actions are recorded for rollback.
#    This option is only read when server starts.
enable_rollback_recording (Rollback recording) bool false

#    A message to be displayed to all clients when the server shuts down.
kick_msg_shutdown (Shutdown message) string Server shutting down.

#    A message to be displayed to all clients when the server crashes.
kick_msg_crash (Crash message) string This server has experienced an internal error. You will now be disconnected.

#    Whether to ask clients to reconnect after a (Lua) crash.
#    Set this to true if your server is set up to restart automatically.
ask_reconnect_on_crash (Ask to reconnect after crash) bool false

#    From how far clients know about objects, stated in mapblocks (16 nodes).
active_object_send_range_blocks (Active object send range) int 3

#    How large area of blocks are subject to the active block stuff, stated in mapblocks (16 nodes).
#    In active blocks objects are loaded and ABMs run.
active_block_range (Active block range) int 3

#    From how far blocks are sent to clients, stated in mapblocks (16 nodes).
max_block_send_distance (Max block send distance) int 10

#    Maximum number of forceloaded mapblocks.
max_forceloaded_blocks (Maximum forceloaded blocks) int 16

#    Interval of sending time of day to clients.
time_send_interval (Time send interval) int 5

#    Controls length of day/night cycle.
#    Examples: 72 = 20min, 360 = 4min, 1 = 24hour, 0 = day/night/whatever stays unchanged.
time_speed (Time speed) int 72

#    Interval of saving important changes in the world, stated in seconds.
server_map_save_interval (Map save interval) float 5.3

#    Set the maximum character length of a chat message sent by clients.
# chat_message_max_size int 500

#    Limit a single player to send X messages per 10 seconds.
# chat_message_limit_per_10sec float 10.0

#    Kick player if send more than X messages per 10 seconds.
# chat_message_limit_trigger_kick int 50

[**Physics]

movement_acceleration_default (Default acceleration) float 3
movement_acceleration_air (Acceleration in air) float 2
movement_acceleration_fast (Fast mode acceleration) float 10
movement_speed_walk (Walking speed) float 4
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_liquid_fluidity (Liquid fluidity) float 1
movement_liquid_fluidity_smooth (Liquid fluidity smoothing) float 0.5
movement_liquid_sink (Liquid sink) float 10
movement_gravity (Gravity) float 9.81

[**Advanced]

#    Handling for deprecated lua api calls:
#    -    legacy: (try to) mimic old behaviour (default for release).
#    -    log: mimic and log backtrace of deprecated call (default for debug).
#    -    error: abort on usage of deprecated call (suggested for mod developers).
deprecated_lua_api_handling (Deprecated Lua API handling) enum legacy legacy,log,error

#    Number of extra blocks that can be loaded by /clearobjects at once.
#    This is a trade-off between sqlite transaction overhead and
#    memory consumption (4096=100MB, as a rule of thumb).
max_clearobjects_extra_loaded_blocks (Max. clearobjects extra blocks) int 4096

#    How much the server will wait before unloading unused mapblocks.
#    Higher value is smoother, but will use more RAM.
server_unload_unused_data_timeout (Unload unused server data) int 29

#    Maximum number of statically stored objects in a block.
max_objects_per_block (Maximum objects per block) int 64

#    See http://www.sqlite.org/pragma.html#pragma_synchronous
sqlite_synchronous (Synchronous SQLite) enum 2 0,1,2

#    Length of a server tick and the interval at which objects are generally updated over network.
dedicated_server_step (Dedicated server step) float 0.1

#    Time in between active block management cycles
active_block_mgmt_interval (Active Block Management interval) float 2.0

#    Length of time between ABM execution cycles
abm_interval (Active Block Modifier interval) float 1.0

#    Length of time between NodeTimer execution cycles
nodetimer_interval (NodeTimer interval) float 0.2

#    If enabled, invalid world data won't cause the server to shut down.
#    Only enable this if you know what you are doing.
ignore_world_load_errors (Ignore world errors) bool false

#    Max liquids processed per step.
liquid_loop_max (Liquid loop max) int 100000

#    The time (in seconds) that the liquids queue may grow beyond processing
#    capacity until an attempt is made to decrease its size by dumping old queue
#    items.  A value of 0 disables the functionality.
liquid_queue_purge_time (Liquid queue purge time) int 0

#    Liquid update interval in seconds.
liquid_update (Liquid update tick) float 1.0

#    At this distance the server will aggressively optimize which blocks are sent to clients.
#    Small values potentially improve performance a lot, at the expense of visible rendering glitches.
#    (some blocks will not be rendered under water and in caves, as well as sometimes on land)
#    Setting this to a value greater than max_block_send_distance disables this optimization.
#    Stated in mapblocks (16 nodes)
block_send_optimize_distance (block send optimize distance) int 4 2

#    If enabled the server will perform map block occlusion culling based on
#    on the eye position of the player. This can reduce the number of blocks
#    sent to the client 50-80%. The client will not longer receive most invisible
#    so that the utility of noclip mode is reduced.
server_side_occlusion_culling (Server side occlusion culling) bool true

[*Mapgen]

#    Name of map generator to be used when creating a new world.
#    Creating a world in the main menu will override this.
mg_name (Mapgen name) enum v7 v5,v6,v7,flat,valleys,fractal,singlenode

#    Water surface level of the world.
water_level (Water level) int 1

#    From how far blocks are generated for clients, stated in mapblocks (16 nodes).
max_block_generate_distance (Max block generate distance) int 6

#    Limit of map generation, in nodes, in all 6 directions from (0, 0, 0).
#    Only mapchunks completely within the mapgen limit are generated.
#    Value is stored per-world.
mapgen_limit (Map generation limit) int 31000 0 31000

#    Global map generation attributes.
#    In Mapgen v6 the 'decorations' flag controls all decorations except trees
#    and junglegrass, in all other mapgens this flag controls all decorations.
#    Flags that are not specified in the flag string are not modified from the default.
#    Flags starting with 'no' are used to explicitly disable them.
mg_flags (Mapgen flags) flags caves,dungeons,light,decorations caves,dungeons,light,decorations,nocaves,nodungeons,nolight,nodecorations

[**Advanced]

#    Size of chunks to be generated at once by mapgen, stated in mapblocks (16 nodes).
chunksize (Chunk size) int 5

#    Dump the mapgen debug infos.
enable_mapgen_debug_info (Mapgen debug) bool false

#    Maximum number of blocks that can be queued for loading.
emergequeue_limit_total (Absolute limit of emerge queues) int 256

#    Maximum number of blocks to be queued that are to be loaded from file.
#    Set to blank for an appropriate amount to be chosen automatically.
emergequeue_limit_diskonly (Limit of emerge queues on disk) int 32

#    Maximum number of blocks to be queued that are to be generated.
#    Set to blank for an appropriate amount to be chosen automatically.
emergequeue_limit_generate (Limit of emerge queues to generate) int 32

#    Number of emerge threads to use. Make this field blank, or increase this number
#    to use multiple threads. On multiprocessor systems, this will improve mapgen speed greatly
#    at the cost of slightly buggy caves.
num_emerge_threads (Number of emerge threads) int 1

[***Biome API temperature and humidity noise parameters]

#    Temperature variation for biomes.
mg_biome_np_heat (Heat noise) noise_params 50, 50, (1000, 1000, 1000), 5349, 3, 0.5, 2.0

#    Small-scale temperature variation for blending biomes on borders.
mg_biome_np_heat_blend (Heat blend noise) noise_params 0, 1.5, (8, 8, 8), 13, 2, 1.0, 2.0

#    Humidity variation for biomes.
mg_biome_np_humidity (Humidity noise) noise_params 50, 50, (1000, 1000, 1000), 842, 3, 0.5, 2.0

#    Small-scale humidity variation for blending biomes on borders.
mg_biome_np_humidity_blend (Humidity blend noise) noise_params 0, 1.5, (8, 8, 8), 90003, 2, 1.0, 2.0

[***Mapgen v5]

#    Map generation attributes specific to Mapgen v5.
#    Flags that are not specified in the flag string are not modified from the default.
#    Flags starting with 'no' are used to explicitly disable them.
mgv5_spflags (Mapgen v5 specific flags) flags caverns caverns,nocaverns

#    Controls width of tunnels, a smaller value creates wider tunnels.
mgv5_cave_width (Cave width) float 0.125

#    Y-level of cavern upper limit.
mgv5_cavern_limit (Cavern limit) int -256

#    Y-distance over which caverns expand to full size.
mgv5_cavern_taper (Cavern taper) int 256

#    Defines full size of caverns, smaller values create larger caverns.
mgv5_cavern_threshold (Cavern threshold) float 0.7

#    Variation of biome filler depth.
mgv5_np_filler_depth (Filler depth noise) noise_params 0, 1, (150, 150, 150), 261, 4, 0.7, 2.0

#    Variation of terrain vertical scale.
#    When noise is < -0.55 terrain is near-flat.
mgv5_np_factor (Factor noise) noise_params 0, 1, (250, 250, 250), 920381, 3, 0.45, 2.0

#    Y-level of average terrain surface.
mgv5_np_height (Height noise) noise_params 0, 10, (250, 250, 250), 84174, 4, 0.5, 2.0

#    First of 2 3D noises that together define tunnels.
mgv5_np_cave1 (Cave1 noise) noise_params 0, 12, (50, 50, 50), 52534, 4, 0.5, 2.0

#    Second of 2 3D noises that together define tunnels.
mgv5_np_cave2 (Cave2 noise) noise_params 0, 12, (50, 50, 50), 10325, 4, 0.5, 2.0

#    3D noise defining giant caverns.
mgv5_np_cavern (Cavern noise) noise_params 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0

#    TODO
#    Noise parameters in group format, unsupported by advanced settings
#    menu but settable in minetest.conf.
#    See documentation of noise parameter formats in minetest.conf.example.
#    3D noise defining terrain.
#mgv5_np_ground = {
#    offset      = 0
#    scale       = 40
#    spread      = (80, 80, 80)
#    seed        = 983240
#    octaves     = 4
#    persistence = 0.55
#    lacunarity  = 2.0
#    flags       = "eased"
#}

[***Mapgen v6]

#    Map generation attributes specific to Mapgen v6.
#    The 'snowbiomes' flag enables the new 5 biome system.
#    When the new biome system is enabled jungles are automatically enabled and
#    the 'jungles' flag is ignored.
#    Flags that are not specified in the flag string are not modified from the default.
#    Flags starting with 'no' are used to explicitly disable them.
mgv6_spflags (Mapgen v6 specific flags) flags jungles,biomeblend,mudflow,snowbiomes,trees jungles,biomeblend,mudflow,snowbiomes,flat,trees,nojungles,nobiomeblend,nomudflow,nosnowbiomes,noflat,notrees

#    Deserts occur when np_biome exceeds this value.
#    When the new biome system is enabled, this is ignored.
mgv6_freq_desert (Desert noise threshold) float 0.45

#    Sandy beaches occur when np_beach exceeds this value.
mgv6_freq_beach (Beach noise threshold) float 0.15

#    Y-level of lower terrain and lakebeds.
mgv6_np_terrain_base (Terrain base noise) noise_params -4, 20, (250, 250, 250), 82341, 5, 0.6, 2.0

#    Y-level of higher (cliff-top) terrain.
mgv6_np_terrain_higher (Terrain higher noise) noise_params 20, 16, (500, 500, 500), 85039, 5, 0.6, 2.0

#    Varies steepness of cliffs.
mgv6_np_steepness (Steepness noise) noise_params 0.85, 0.5, (125, 125, 125), -932, 5, 0.7, 2.0

#    Defines areas of 'terrain_higher' (cliff-top terrain).
mgv6_np_height_select (Height select noise) noise_params 0.5, 1, (250, 250, 250), 4213, 5, 0.69, 2.0

#    Varies depth of biome surface nodes.
mgv6_np_mud (Mud noise) noise_params 4, 2, (200, 200, 200), 91013, 3, 0.55, 2.0

#    Defines areas with sandy beaches.
mgv6_np_beach (Beach noise) noise_params 0, 1, (250, 250, 250), 59420, 3, 0.50, 2.0

#    Temperature variation for biomes.
mgv6_np_biome (Biome noise) noise_params 0, 1, (500, 500, 500), 9130, 3, 0.50, 2.0

#    Variation of number of caves.
mgv6_np_cave (Cave noise) noise_params 6, 6, (250, 250, 250), 34329, 3, 0.50, 2.0

#    Humidity variation for biomes.
mgv6_np_humidity (Humidity noise) noise_params 0.5, 0.5, (500, 500, 500), 72384, 3, 0.50, 2.0

#    Defines tree areas and tree density.
mgv6_np_trees (Trees noise) noise_params 0, 1, (125, 125, 125), 2, 4, 0.66, 2.0

#    Defines areas where trees have apples.
mgv6_np_apple_trees (Apple trees noise) noise_params 0, 1, (100, 100, 100), 342902, 3, 0.45, 2.0

[***Mapgen v7]

#    Map generation attributes specific to Mapgen v7.
#    The 'ridges' flag enables the rivers.
#    Floatlands are currently experimental and subject to change.
#    Flags that are not specified in the flag string are not modified from the default.
#    Flags starting with 'no' are used to explicitly disable them.
mgv7_spflags (Mapgen v7 specific flags) flags mountains,ridges,nofloatlands,caverns mountains,ridges,floatlands,caverns,nomountains,noridges,nofloatlands,nocaverns

#    Controls width of tunnels, a smaller value creates wider tunnels.
mgv7_cave_width (Cave width) float 0.09

#    Controls the density of floatland mountain terrain.
#    Is an offset added to the 'np_mountain' noise value.
mgv7_float_mount_density (Floatland mountain density) float 0.6

#    Typical maximum height, above and below midpoint, of floatland mountain terrain.
mgv7_float_mount_height (Floatland mountain height) float 128.0

#    Y-level of floatland midpoint and lake surface.
mgv7_floatland_level (Floatland level) int 1280

#    Y-level to which floatland shadows extend.
mgv7_shadow_limit (Shadow limit) int 1024

#    Y-level of cavern upper limit.
mgv7_cavern_limit (Cavern limit) int -256

#    Y-distance over which caverns expand to full size.
mgv7_cavern_taper (Cavern taper) int 256

#    Defines full size of caverns, smaller values create larger caverns.
mgv7_cavern_threshold (Cavern threshold) float 0.7

#    Y-level of higher (cliff-top) terrain.
mgv7_np_terrain_base (Terrain base noise) noise_params 4, 70, (600, 600, 600), 82341, 5, 0.6, 2.0

#    Y-level of lower terrain and lakebeds.
mgv7_np_terrain_alt (Terrain alt noise) noise_params 4, 25, (600, 600, 600), 5934, 5, 0.6, 2.0

#    Varies roughness of terrain.
#    Defines the 'persistence' value for terrain_base and terrain_alt noises.
mgv7_np_terrain_persist (Terrain persistence noise) noise_params 0.6, 0.1, (2000, 2000, 2000), 539, 3, 0.6, 2.0

#    Defines areas of higher (cliff-top) terrain and affects steepness of cliffs.
mgv7_np_height_select (Height select noise) noise_params -8, 16, (500, 500, 500), 4213, 6, 0.7, 2.0

#    Variation of biome filler depth.
mgv7_np_filler_depth (Filler depth noise) noise_params 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0

#    Variation of maximum mountain height (in nodes).
mgv7_np_mount_height (Mountain height noise) noise_params 256, 112, (1000, 1000, 1000), 72449, 3, 0.6, 2.0

#    Defines large-scale river channel structure.
mgv7_np_ridge_uwater (Ridge underwater noise) noise_params 0, 1, (1000, 1000, 1000), 85039, 5, 0.6, 2.0

#    Defines areas of floatland smooth terrain.
#    Smooth floatlands occur when noise > 0.
mgv7_np_floatland_base (Floatland base noise) noise_params -0.6, 1.5, (600, 600, 600), 114, 5, 0.6, 2.0

#    Variation of hill height and lake depth on floatland smooth terrain.
mgv7_np_float_base_height (Floatland base height noise) noise_params 48, 24, (300, 300, 300), 907, 4, 0.7, 2.0

#    3D noise defining mountain structure and height.
#    Also defines structure of floatland mountain terrain.
mgv7_np_mountain (Mountain noise) noise_params -0.6, 1, (250, 350, 250), 5333, 5, 0.63, 2.0

#    3D noise defining structure of river canyon walls.
mgv7_np_ridge (Ridge noise) noise_params 0, 1, (100, 100, 100), 6467, 4, 0.75, 2.0

#    3D noise defining giant caverns.
mgv7_np_cavern (Cavern noise) noise_params 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0

#    First of 2 3D noises that together define tunnels.
mgv7_np_cave1 (Cave1 noise) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0

#    Second of 2 3D noises that together define tunnels.
mgv7_np_cave2 (Cave2 noise) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0

[***Mapgen flat]

#    Map generation attributes specific to Mapgen flat.
#    Occasional lakes and hills can be added to the flat world.
#    Flags that are not specified in the flag string are not modified from the default.
#    Flags starting with 'no' are used to explicitly disable them.
mgflat_spflags (Mapgen flat specific flags) flags nolakes,nohills lakes,hills,nolakes,nohills

#    Y of flat ground.
mgflat_ground_level (Ground level) int 8

#    Y of upper limit of large pseudorandom caves.
mgflat_large_cave_depth (Large cave depth) int -33

#    Controls width of tunnels, a smaller value creates wider tunnels.
mgflat_cave_width (Cave width) float 0.09

#    Terrain noise threshold for lakes.
#    Controls proportion of world area covered by lakes.
#    Adjust towards 0.0 for a larger proportion.
mgflat_lake_threshold (Lake threshold) float -0.45

#    Controls steepness/depth of lake depressions.
mgflat_lake_steepness (Lake steepness) float 48.0

#    Terrain noise threshold for hills.
#    Controls proportion of world area covered by hills.
#    Adjust towards 0.0 for a larger proportion.
mgflat_hill_threshold (Hill threshold) float 0.45

#    Controls steepness/height of hills.
mgflat_hill_steepness (Hill steepness) float 64.0

#    Defines location and terrain of optional hills and lakes.
mgflat_np_terrain (Terrain noise) noise_params 0, 1, (600, 600, 600), 7244, 5, 0.6, 2.0

#    Variation of biome filler depth.
mgflat_np_filler_depth (Filler depth noise) noise_params 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0

#    First of 2 3D noises that together define tunnels.
mgflat_np_cave1 (Cave1 noise) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0

#    Second of 2 3D noises that together define tunnels.
mgflat_np_cave2 (Cave2 noise) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0

[***Mapgen fractal]

#    Controls width of tunnels, a smaller value creates wider tunnels.
mgfractal_cave_width (Cave width) float 0.09

#    Choice of 18 fractals from 9 formulas.
#    1 = 4D "Roundy" mandelbrot set.
#    2 = 4D "Roundy" julia set.
#    3 = 4D "Squarry" mandelbrot set.
#    4 = 4D "Squarry" julia set.
#    5 = 4D "Mandy Cousin" mandelbrot set.
#    6 = 4D "Mandy Cousin" julia set.
#    7 = 4D "Variation" mandelbrot set.
#    8 = 4D "Variation" julia set.
#    9 = 3D "Mandelbrot/Mandelbar" mandelbrot set.
#    10 = 3D "Mandelbrot/Mandelbar" julia set.
#    11 = 3D "Christmas Tree" mandelbrot set.
#    12 = 3D "Christmas Tree" julia set.
#    13 = 3D "Mandelbulb" mandelbrot set.
#    14 = 3D "Mandelbulb" julia set.
#    15 = 3D "Cosine Mandelbulb" mandelbrot set.
#    16 = 3D "Cosine Mandelbulb" julia set.
#    17 = 4D "Mandelbulb" mandelbrot set.
#    18 = 4D "Mandelbulb" julia set.
mgfractal_fractal (Fractal type) int 1 1 18

#    Iterations of the recursive function.
#    Controls the amount of fine detail.
mgfractal_iterations (Iterations) int 11

#    Approximate (X,Y,Z) scale of fractal in nodes.
mgfractal_scale (Scale) v3f (4096.0, 1024.0, 4096.0)

#    (X,Y,Z) offset of fractal from world centre in units of 'scale'.
#    Used to move a suitable spawn area of low land close to (0, 0).
#    The default is suitable for mandelbrot sets, it needs to be edited for julia sets.
#    Range roughly -2 to 2. Multiply by 'scale' for offset in nodes.
mgfractal_offset (Offset) v3f (1.79, 0.0, 0.0)

#    W co-ordinate of the generated 3D slice of a 4D fractal.
#    Determines which 3D slice of the 4D shape is generated.
#    Has no effect on 3D fractals.
#    Range roughly -2 to 2.
mgfractal_slice_w (Slice w) float 0.0

#    Julia set only: X component of hypercomplex constant determining julia shape.
#    Range roughly -2 to 2.
mgfractal_julia_x (Julia x) float 0.33

#    Julia set only: Y component of hypercomplex constant determining julia shape.
#    Range roughly -2 to 2.
mgfractal_julia_y (Julia y) float 0.33

#    Julia set only: Z component of hypercomplex constant determining julia shape.
#    Range roughly -2 to 2.
mgfractal_julia_z (Julia z) float 0.33

#    Julia set only: W component of hypercomplex constant determining julia shape.
#    Has no effect on 3D fractals.
#    Range roughly -2 to 2.
mgfractal_julia_w (Julia w) float 0.33

#    Y-level of seabed.
mgfractal_np_seabed (Seabed noise) noise_params -14, 9, (600, 600, 600), 41900, 5, 0.6, 2.0

#    Variation of biome filler depth.
mgfractal_np_filler_depth (Filler depth noise) noise_params 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0

#    First of 2 3D noises that together define tunnels.
mgfractal_np_cave1 (Cave1 noise) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0

#    Second of 2 3D noises that together define tunnels.
mgfractal_np_cave2 (Cave2 noise) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0

# Mapgen Valleys parameters
[***Mapgen Valleys]

# General parameters
[****General]

#    Map generation attributes specific to Mapgen Valleys.
#    'altitude_chill' makes higher elevations colder, which may cause biome issues.
#    'humid_rivers' modifies the humidity around rivers and in areas where water would tend to pool,
#    it may interfere with delicately adjusted biomes.
#    Flags that are not specified in the flag string are not modified from the default.
#    Flags starting with 'no' are used to explicitly disable them.
mg_valleys_spflags (Valleys C Flags) flags altitude_chill,humid_rivers altitude_chill,noaltitude_chill,humid_rivers,nohumid_rivers

# The altitude at which temperature drops by 20C
mgvalleys_altitude_chill (Altitude Chill) int 90

# Depth below which you'll find large caves.
mgvalleys_large_cave_depth (Large cave depth) int -33

# Creates unpredictable lava features in caves.
# These can make mining difficult. Zero disables them. (0-10)
mgvalleys_lava_features (Lava Features) int 0

# Depth below which you'll find massive caves.
mgvalleys_massive_cave_depth (Massive cave depth) int -256

# How deep to make rivers
mgvalleys_river_depth (River Depth) int 4

# How wide to make rivers
mgvalleys_river_size (River Size) int 5

# Creates unpredictable water features in caves.
# These can make mining difficult. Zero disables them. (0-10)
mgvalleys_water_features (Water Features) int 0

#    Controls width of tunnels, a smaller value creates wider tunnels.
mgvalleys_cave_width (Cave width) float 0.09

# Noise parameters
[****Noises]

# Caves and tunnels form at the intersection of the two noises
mgvalleys_np_cave1 (Cave noise #1) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0

# Caves and tunnels form at the intersection of the two noises
mgvalleys_np_cave2 (Cave noise #2) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0

# The depth of dirt or other filler
mgvalleys_np_filler_depth (Filler Depth) noise_params 0, 1.2, (256, 256, 256), 1605, 3, 0.5, 2.0

# Massive caves form here.
mgvalleys_np_massive_caves (Massive cave noise) noise_params 0, 1, (768, 256, 768), 59033, 6, 0.63, 2.0

# River noise -- rivers occur close to zero
mgvalleys_np_rivers (River Noise) noise_params 0, 1, (256, 256, 256), -6050, 5, 0.6, 2.0

# Base terrain height
mgvalleys_np_terrain_height (Terrain Height) noise_params -10, 50, (1024, 1024, 1024), 5202, 6, 0.4, 2.0

# Raises terrain to make valleys around the rivers
mgvalleys_np_valley_depth (Valley Depth) noise_params 5, 4, (512, 512, 512), -1914, 1, 1.0, 2.0

# Slope and fill work together to modify the heights
mgvalleys_np_inter_valley_fill (Valley Fill) noise_params 0, 1, (256, 512, 256), 1993, 6, 0.8, 2.0

# Amplifies the valleys
mgvalleys_np_valley_profile (Valley Profile) noise_params 0.6, 0.5, (512, 512, 512), 777, 1, 1.0, 2.0

# Slope and fill work together to modify the heights
mgvalleys_np_inter_valley_slope (Valley Slope) noise_params 0.5, 0.5, (128, 128, 128), 746, 1, 1.0, 2.0

[*Security]

#    Prevent mods from doing insecure things like running shell commands.
secure.enable_security (Enable mod security) bool true

#    Comma-separated list of trusted mods that are allowed to access insecure
#    functions even when mod security is on (via request_insecure_environment()).
secure.trusted_mods (Trusted mods) string

#	Comma-separated list of mods that are allowed to access HTTP APIs, which
#	allow them to upload and download data to/from the internet.
secure.http_mods (HTTP Mods) string

[*Advanced]

[**Profiling]
#    Load the game profiler to collect game profiling data.
#    Provides a /profiler command to access the compiled profile.
#    Useful for mod developers and server operators.
profiler.load (Load the game profiler) bool false

#    The default format in which profiles are being saved,
#    when calling `/profiler save [format]` without format.
profiler.default_report_format (Default report format) enum txt txt,csv,lua,json,json_pretty

#    The file path relative to your worldpath in which profiles will be saved to.
profiler.report_path (Report path) string ""

[***Instrumentation]

#    Instrument the methods of entities on registration.
instrument.entity (Entity methods) bool true

#    Instrument the action function of Active Block Modifiers on registration.
instrument.abm (Active Block Modifiers) bool true

#    Instrument the action function of Loading Block Modifiers on registration.
instrument.lbm (Loading Block Modifiers) bool true

#    Instrument chatcommands on registration.
instrument.chatcommand (Chatcommands) bool true

#    Instrument global callback functions on registration.
#    (anything you pass to a minetest.register_*() function)
instrument.global_callback (Global callbacks) bool true

[****Advanced]
#    Instrument builtin.
#    This is usually only needed by core/builtin contributors
instrument.builtin (Builtin) bool false

#    Have the profiler instrument itself:
#     * Instrument an empty function.
#       This estimates the overhead, that instrumentation is adding (+1 function call).
#     * Instrument the sampler being used to update the statistics.
instrument.profiler (Profiler) bool false

[Client and Server]

#    Name of the player.
#    When running a server, clients connecting with this name are admins.
#    When starting from the main menu, this is overridden.
name (Player name) string

#    Set the language. Leave empty to use the system language.
#    A restart is required after changing this.
language (Language) enum   ,be,ca,cs,da,de,en,eo,es,et,fr,he,hu,id,it,ja,jbo,ko,ky,lt,nb,nl,pl,pt,pt_BR,ro,ru,sr_Cyrl,tr,uk,zh_CN,zh_TW

#    Level of logging to be written to debug.txt:
#    -    <nothing> (no logging)
#    -    none (messages with no level)
#    -    error
#    -    warning
#    -    action
#    -    info
#    -    verbose
debug_log_level (Debug log level) enum action ,none,error,warning,action,info,verbose

#    IPv6 support.
enable_ipv6 (IPv6) bool true

[*Advanced]

#    Default timeout for cURL, stated in milliseconds.
#    Only has an effect if compiled with cURL.
curl_timeout (cURL timeout) int 5000

#    Limits number of parallel HTTP requests. Affects:
#    -    Media fetch if server uses remote_media setting.
#    -    Serverlist download and server announcement.
#    -    Downloads performed by main menu (e.g. mod manager).
#    Only has an effect if compiled with cURL.
curl_parallel_limit (cURL parallel limit) int 8

#    Maximum time in ms a file download (e.g. a mod download) may take.
curl_file_download_timeout (cURL file download timeout) int 300000

#    Makes DirectX work with LuaJIT. Disable if it causes troubles.
high_precision_fpu (High-precision FPU) bool true

#    Replaces the default main menu with a custom one.
main_menu_script (Main menu script) string

main_menu_game_mgr (Main menu game manager) int 0

main_menu_mod_mgr (Main menu mod manager) int 1

modstore_download_url (Modstore download URL) string https://forum.minetest.net/media/

modstore_listmods_url (Modstore mods list URL) string https://forum.minetest.net/mmdb/mods/

modstore_details_url (Modstore details URL) string https://forum.minetest.net/mmdb/mod/*/

#    Print the engine's profiling data in regular intervals (in seconds). 0 = disable. Useful for developers.
profiler_print_interval (Engine profiling data print interval) int 0


code:
void main(void)
{
	gl_FragColor = gl_Color;
}

repo_name: pgimeno/minetest

license: unknown


code:
uniform mat4 mWorldViewProj;

void main(void)
{
	gl_TexCoord[0] = gl_MultiTexCoord0;
	gl_Position = mWorldViewProj * gl_Vertex;

	gl_FrontColor = gl_BackColor = gl_Color;
}


code:
uniform sampler2D baseTexture;
uniform sampler2D normalTexture;
uniform vec3 yawVec;

void main (void)
{
	vec2 uv = gl_TexCoord[0].st;

	//texture sampling rate
	const float step = 1.0 / 256.0;
	float tl = texture2D(normalTexture, vec2(uv.x - step, uv.y + step)).r;
	float t  = texture2D(normalTexture, vec2(uv.x - step, uv.y - step)).r;
	float tr = texture2D(normalTexture, vec2(uv.x + step, uv.y + step)).r;
	float r  = texture2D(normalTexture, vec2(uv.x + step, uv.y)).r;
	float br = texture2D(normalTexture, vec2(uv.x + step, uv.y - step)).r;
	float b  = texture2D(normalTexture, vec2(uv.x, uv.y - step)).r;
	float bl = texture2D(normalTexture, vec2(uv.x - step, uv.y - step)).r;
	float l  = texture2D(normalTexture, vec2(uv.x - step, uv.y)).r;
	float dX = (tr + 2.0 * r + br) - (tl + 2.0 * l + bl);
	float dY = (bl + 2.0 * b + br) - (tl + 2.0 * t + tr);
	vec4 bump = vec4 (normalize(vec3 (dX, dY, 0.1)),1.0);
	float height = 2.0 * texture2D(normalTexture, vec2(uv.x, uv.y)).r - 1.0;
	vec4 base = texture2D(baseTexture, uv).rgba;
	vec3 L = normalize(vec3(0.0, 0.75, 1.0));
	float specular = pow(clamp(dot(reflect(L, bump.xyz), yawVec), 0.0, 1.0), 1.0);
	float diffuse = dot(yawVec, bump.xyz);

	vec3 color = (1.1 * diffuse + 0.05 * height + 0.5 * specular) * base.rgb;
	vec4 col = vec4(color.rgb, base.a);
	col *= gl_Color;
	gl_FragColor = vec4(col.rgb, base.a);
}


code:
uniform mat4 mWorldViewProj;
uniform mat4 mWorld;

void main(void)
{
	gl_TexCoord[0] = gl_MultiTexCoord0;
	gl_Position = mWorldViewProj * gl_Vertex;
	gl_FrontColor = gl_BackColor = gl_Color;
}


code:
uniform sampler2D baseTexture;
uniform sampler2D normalTexture;
uniform sampler2D textureFlags;

uniform vec4 skyBgColor;
uniform float fogDistance;
uniform vec3 eyePosition;

varying vec3 vPosition;
varying vec3 worldPosition;
varying float area_enable_parallax;

varying vec3 eyeVec;
varying vec3 tsEyeVec;
varying vec3 lightVec;
varying vec3 tsLightVec;

bool normalTexturePresent = false;

const float e = 2.718281828459;
const float BS = 10.0;
const float fogStart = FOG_START;
const float fogShadingParameter = 1 / ( 1 - fogStart);

#ifdef ENABLE_TONE_MAPPING

/* Hable's UC2 Tone mapping parameters
	A = 0.22;
	B = 0.30;
	C = 0.10;
	D = 0.20;
	E = 0.01;
	F = 0.30;
	W = 11.2;
	equation used:  ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F
*/

vec3 uncharted2Tonemap(vec3 x)
{
	return ((x * (0.22 * x + 0.03) + 0.002) / (x * (0.22 * x + 0.3) + 0.06)) - 0.03333;
}

vec4 applyToneMapping(vec4 color)
{
	color = vec4(pow(color.rgb, vec3(2.2)), color.a);
	const float gamma = 1.6;
	const float exposureBias = 5.5;
	color.rgb = uncharted2Tonemap(exposureBias * color.rgb);
	// Precalculated white_scale from
	//vec3 whiteScale = 1.0 / uncharted2Tonemap(vec3(W));
	vec3 whiteScale = vec3(1.036015346);
	color.rgb *= whiteScale;
	return vec4(pow(color.rgb, vec3(1.0 / gamma)), color.a);
}
#endif

void get_texture_flags()
{
	vec4 flags = texture2D(textureFlags, vec2(0.0, 0.0));
	if (flags.r > 0.5) {
		normalTexturePresent = true;
	}
}

float intensity(vec3 color)
{
	return (color.r + color.g + color.b) / 3.0;
}

float get_rgb_height(vec2 uv)
{
	return intensity(texture2D(baseTexture, uv).rgb);
}

vec4 get_normal_map(vec2 uv)
{
	vec4 bump = texture2D(normalTexture, uv).rgba;
	bump.xyz = normalize(bump.xyz * 2.0 - 1.0);
	return bump;
}

float find_intersection(vec2 dp, vec2 ds)
{
	float depth = 1.0;
	float best_depth = 0.0;
	float size = 0.0625;
	for (int i = 0; i < 15; i++) {
		depth -= size;
		float h = texture2D(normalTexture, dp + ds * depth).a;
		if (depth <= h) {
			best_depth = depth;
			break;
		}
	}
	depth = best_depth;
	for (int i = 0; i < 4; i++) {
		size *= 0.5;
		float h = texture2D(normalTexture,dp + ds * depth).a;
		if (depth <= h) {
			best_depth = depth;
			depth += size;
		} else {
			depth -= size;
		}
	}
	return best_depth;
}

float find_intersectionRGB(vec2 dp, vec2 ds)
{
	const float depth_step = 1.0 / 24.0;
	float depth = 1.0;
	for (int i = 0 ; i < 24 ; i++) {
		float h = get_rgb_height(dp + ds * depth);
		if (h >= depth)
			break;
		depth -= depth_step;
	}
	return depth;
}

void main(void)
{
	vec3 color;
	vec4 bump;
	vec2 uv = gl_TexCoord[0].st;
	bool use_normalmap = false;
	get_texture_flags();

#ifdef ENABLE_PARALLAX_OCCLUSION
	vec2 eyeRay = vec2 (tsEyeVec.x, -tsEyeVec.y);
	const float scale = PARALLAX_OCCLUSION_SCALE / PARALLAX_OCCLUSION_ITERATIONS;
	const float bias = PARALLAX_OCCLUSION_BIAS / PARALLAX_OCCLUSION_ITERATIONS;

#if PARALLAX_OCCLUSION_MODE == 0
	// Parallax occlusion with slope information
	if (normalTexturePresent && area_enable_parallax > 0.0) {
		for (int i = 0; i < PARALLAX_OCCLUSION_ITERATIONS; i++) {
			vec4 normal = texture2D(normalTexture, uv.xy);
			float h = normal.a * scale - bias;
			uv += h * normal.z * eyeRay;
		}
#endif

#if PARALLAX_OCCLUSION_MODE == 1
	// Relief mapping
	if (normalTexturePresent && area_enable_parallax > 0.0) {
		vec2 ds = eyeRay * PARALLAX_OCCLUSION_SCALE;
		float dist = find_intersection(uv, ds);
		uv += dist * ds;
#endif
	} else if (GENERATE_NORMALMAPS == 1 && area_enable_parallax > 0.0) {
		vec2 ds = eyeRay * PARALLAX_OCCLUSION_SCALE;
		float dist = find_intersectionRGB(uv, ds);
		uv += dist * ds;
	}
#endif

#if USE_NORMALMAPS == 1
	if (normalTexturePresent) {
		bump = get_normal_map(uv);
		use_normalmap = true;
	}
#endif

#if GENERATE_NORMALMAPS == 1
	if (normalTexturePresent == false) {
		float tl = get_rgb_height(vec2(uv.x - SAMPLE_STEP, uv.y + SAMPLE_STEP));
		float t  = get_rgb_height(vec2(uv.x - SAMPLE_STEP, uv.y - SAMPLE_STEP));
		float tr = get_rgb_height(vec2(uv.x + SAMPLE_STEP, uv.y + SAMPLE_STEP));
		float r  = get_rgb_height(vec2(uv.x + SAMPLE_STEP, uv.y));
		float br = get_rgb_height(vec2(uv.x + SAMPLE_STEP, uv.y - SAMPLE_STEP));
		float b  = get_rgb_height(vec2(uv.x, uv.y - SAMPLE_STEP));
		float bl = get_rgb_height(vec2(uv.x -SAMPLE_STEP, uv.y - SAMPLE_STEP));
		float l  = get_rgb_height(vec2(uv.x - SAMPLE_STEP, uv.y));
		float dX = (tr + 2.0 * r + br) - (tl + 2.0 * l + bl);
		float dY = (bl + 2.0 * b + br) - (tl + 2.0 * t + tr);
		bump = vec4(normalize(vec3 (dX, dY, NORMALMAPS_STRENGTH)), 1.0);
		use_normalmap = true;
	}
#endif
	vec4 base = texture2D(baseTexture, uv).rgba;

#ifdef ENABLE_BUMPMAPPING
	if (use_normalmap) {
		vec3 L = normalize(lightVec);
		vec3 E = normalize(eyeVec);
		float specular = pow(clamp(dot(reflect(L, bump.xyz), E), 0.0, 1.0), 1.0);
		float diffuse = dot(-E,bump.xyz);
		color = (diffuse + 0.1 * specular) * base.rgb;
	} else {
		color = base.rgb;
	}
#else
	color = base.rgb;
#endif

	vec4 col = vec4(color.rgb * gl_Color.rgb, 1.0);

#ifdef ENABLE_TONE_MAPPING
	col = applyToneMapping(col);
#endif

	// Due to a bug in some (older ?) graphics stacks (possibly in the glsl compiler ?),
	// the fog will only be rendered correctly if the last operation before the
	// clamp() is an addition. Else, the clamp() seems to be ignored.
	// E.g. the following won't work:
	//      float clarity = clamp(fogShadingParameter
	//		* (fogDistance - length(eyeVec)) / fogDistance), 0.0, 1.0);
	// As additions usually come for free following a multiplication, the new formula
	// should be more efficient as well.
	// Note: clarity = (1 - fogginess)
	float clarity = clamp(fogShadingParameter
		- fogShadingParameter * length(eyeVec) / fogDistance, 0.0, 1.0);
	col = mix(skyBgColor, col, clarity);
	col = vec4(col.rgb, base.a);

	gl_FragColor = col;
}


code:
uniform mat4 mWorldViewProj;
uniform mat4 mWorld;

// Color of the light emitted by the sun.
uniform vec3 dayLight;
uniform vec3 eyePosition;
uniform float animationTimer;

varying vec3 vPosition;
varying vec3 worldPosition;

varying vec3 eyeVec;
varying vec3 lightVec;
varying vec3 tsEyeVec;
varying vec3 tsLightVec;
varying float area_enable_parallax;

// Color of the light emitted by the light sources.
const vec3 artificialLight = vec3(1.04, 1.04, 1.04);
const float e = 2.718281828459;
const float BS = 10.0;

float smoothCurve(float x)
{
	return x * x * (3.0 - 2.0 * x);
}

float triangleWave(float x)
{
	return abs(fract(x + 0.5) * 2.0 - 1.0);
}

float smoothTriangleWave(float x)
{
	return smoothCurve(triangleWave(x)) * 2.0 - 1.0;
}

void main(void)
{
	gl_TexCoord[0] = gl_MultiTexCoord0;
	//TODO: make offset depending on view angle and parallax uv displacement
	//thats for textures that doesnt align vertically, like dirt with grass
	//gl_TexCoord[0].y += 0.008;

	//Allow parallax/relief mapping only for certain kind of nodes
	//Variable is also used to control area of the effect
#if (DRAW_TYPE == NDT_NORMAL || DRAW_TYPE == NDT_LIQUID || DRAW_TYPE == NDT_FLOWINGLIQUID)
	area_enable_parallax = 1.0;
#else
	area_enable_parallax = 0.0;
#endif

float disp_x;
float disp_z;
#if (MATERIAL_TYPE == TILE_MATERIAL_WAVING_LEAVES && ENABLE_WAVING_LEAVES) || (MATERIAL_TYPE == TILE_MATERIAL_WAVING_PLANTS && ENABLE_WAVING_PLANTS)
	vec4 pos2 = mWorld * gl_Vertex;
	float tOffset = (pos2.x + pos2.y) * 0.001 + pos2.z * 0.002;
	disp_x = (smoothTriangleWave(animationTimer * 23.0 + tOffset) +
		smoothTriangleWave(animationTimer * 11.0 + tOffset)) * 0.4;
	disp_z = (smoothTriangleWave(animationTimer * 31.0 + tOffset) +
		smoothTriangleWave(animationTimer * 29.0 + tOffset) +
		smoothTriangleWave(animationTimer * 13.0 + tOffset)) * 0.5;
#endif

#if (MATERIAL_TYPE == TILE_MATERIAL_LIQUID_TRANSPARENT || MATERIAL_TYPE == TILE_MATERIAL_LIQUID_OPAQUE) && ENABLE_WAVING_WATER
	vec4 pos = gl_Vertex;
	pos.y -= 2.0;
	float posYbuf = (pos.z / WATER_WAVE_LENGTH + animationTimer * WATER_WAVE_SPEED * WATER_WAVE_LENGTH);
	pos.y -= sin(posYbuf) * WATER_WAVE_HEIGHT + sin(posYbuf / 7.0) * WATER_WAVE_HEIGHT;
	gl_Position = mWorldViewProj * pos;
#elif MATERIAL_TYPE == TILE_MATERIAL_WAVING_LEAVES && ENABLE_WAVING_LEAVES
	vec4 pos = gl_Vertex;
	pos.x += disp_x;
	pos.y += disp_z * 0.1;
	pos.z += disp_z;
	gl_Position = mWorldViewProj * pos;
#elif MATERIAL_TYPE == TILE_MATERIAL_WAVING_PLANTS && ENABLE_WAVING_PLANTS
	vec4 pos = gl_Vertex;
	if (gl_TexCoord[0].y < 0.05) {
		pos.x += disp_x;
		pos.z += disp_z;
	}
	gl_Position = mWorldViewProj * pos;
#else
	gl_Position = mWorldViewProj * gl_Vertex;
#endif

	vPosition = gl_Position.xyz;
	worldPosition = (mWorld * gl_Vertex).xyz;

	// Don't generate heightmaps when too far from the eye
	float dist = distance (vec3(0.0, 0.0, 0.0), vPosition);
	if (dist > 150.0) {
		area_enable_parallax = 0.0;
	}

	vec3 sunPosition = vec3 (0.0, eyePosition.y * BS + 900.0, 0.0);

	vec3 normal, tangent, binormal;
	normal = normalize(gl_NormalMatrix * gl_Normal);
	tangent = normalize(gl_NormalMatrix * gl_MultiTexCoord1.xyz);
	binormal = normalize(gl_NormalMatrix * gl_MultiTexCoord2.xyz);

	vec3 v;

	lightVec = sunPosition - worldPosition;
	v.x = dot(lightVec, tangent);
	v.y = dot(lightVec, binormal);
	v.z = dot(lightVec, normal);
	tsLightVec = normalize (v);

	eyeVec = -(gl_ModelViewMatrix * gl_Vertex).xyz;
	v.x = dot(eyeVec, tangent);
	v.y = dot(eyeVec, binormal);
	v.z = dot(eyeVec, normal);
	tsEyeVec = normalize (v);

	// Calculate color.
	// Red, green and blue components are pre-multiplied with
	// the brightness, so now we have to multiply these
	// colors with the color of the incoming light.
	// The pre-baked colors are halved to prevent overflow.
	vec4 color;
	// The alpha gives the ratio of sunlight in the incoming light.
	float nightRatio = 1 - gl_Color.a;
	color.rgb = gl_Color.rgb * (gl_Color.a * dayLight.rgb +
		nightRatio * artificialLight.rgb) * 2;
	color.a = 1;

	// Emphase blue a bit in darker places
	// See C++ implementation in mapblock_mesh.cpp finalColorBlend()
	float brightness = (color.r + color.g + color.b) / 3;
	color.b += max(0.0, 0.021 - abs(0.2 * brightness - 0.021) +
		0.07 * brightness);

	gl_FrontColor = gl_BackColor = clamp(color, 0.0, 1.0);
}


code:
uniform sampler2D baseTexture;

void main(void)
{
	vec2 uv = gl_TexCoord[0].st;
	vec4 color = texture2D(baseTexture, uv);
	color.rgb *= gl_Color.rgb;
	gl_FragColor = color;
}


code:
uniform sampler2D baseTexture;
uniform sampler2D normalTexture;
uniform sampler2D textureFlags;

uniform vec4 skyBgColor;
uniform float fogDistance;
uniform vec3 eyePosition;

varying vec3 vPosition;
varying vec3 worldPosition;

varying vec3 eyeVec;
varying vec3 lightVec;

bool normalTexturePresent = false;
bool texTileableHorizontal = false;
bool texTileableVertical = false;
bool texSeamless = false;

const float e = 2.718281828459;
const float BS = 10.0;
const float fogStart = FOG_START;
const float fogShadingParameter = 1 / ( 1 - fogStart);

void get_texture_flags()
{
	vec4 flags = texture2D(textureFlags, vec2(0.0, 0.0));
	if (flags.r > 0.5) {
		normalTexturePresent = true;
	}
	if (flags.g > 0.5) {
		texTileableHorizontal = true;
	}
	if (flags.b > 0.5) {
		texTileableVertical = true;
	}
	if (texTileableHorizontal && texTileableVertical) {
		texSeamless = true;
	}
}

float intensity(vec3 color)
{
	return (color.r + color.g + color.b) / 3.0;
}

float get_rgb_height(vec2 uv)
{
	if (texSeamless) {
		return intensity(texture2D(baseTexture, uv).rgb);
	} else {
		return intensity(texture2D(baseTexture, clamp(uv, 0.0, 0.999)).rgb);
	}
}

vec4 get_normal_map(vec2 uv)
{
	vec4 bump = texture2D(normalTexture, uv).rgba;
	bump.xyz = normalize(bump.xyz * 2.0 - 1.0);
	return bump;
}

void main(void)
{
	vec3 color;
	vec4 bump;
	vec2 uv = gl_TexCoord[0].st;
	bool use_normalmap = false;
	get_texture_flags();

#if USE_NORMALMAPS == 1
	if (normalTexturePresent) {
		bump = get_normal_map(uv);
		use_normalmap = true;
	}
#endif

#if GENERATE_NORMALMAPS == 1
	if (normalTexturePresent == false) {
		float tl = get_rgb_height(vec2(uv.x - SAMPLE_STEP, uv.y + SAMPLE_STEP));
		float t  = get_rgb_height(vec2(uv.x - SAMPLE_STEP, uv.y - SAMPLE_STEP));
		float tr = get_rgb_height(vec2(uv.x + SAMPLE_STEP, uv.y + SAMPLE_STEP));
		float r  = get_rgb_height(vec2(uv.x + SAMPLE_STEP, uv.y));
		float br = get_rgb_height(vec2(uv.x + SAMPLE_STEP, uv.y - SAMPLE_STEP));
		float b  = get_rgb_height(vec2(uv.x, uv.y - SAMPLE_STEP));
		float bl = get_rgb_height(vec2(uv.x -SAMPLE_STEP, uv.y - SAMPLE_STEP));
		float l  = get_rgb_height(vec2(uv.x - SAMPLE_STEP, uv.y));
		float dX = (tr + 2.0 * r + br) - (tl + 2.0 * l + bl);
		float dY = (bl + 2.0 * b + br) - (tl + 2.0 * t + tr);
		bump = vec4(normalize(vec3 (dX, dY, NORMALMAPS_STRENGTH)), 1.0);
		use_normalmap = true;
	}
#endif

	vec4 base = texture2D(baseTexture, uv).rgba;

#ifdef ENABLE_BUMPMAPPING
	if (use_normalmap) {
		vec3 L = normalize(lightVec);
		vec3 E = normalize(eyeVec);
		float specular = pow(clamp(dot(reflect(L, bump.xyz), E), 0.0, 1.0), 1.0);
		float diffuse = dot(-E,bump.xyz);
		color = (diffuse + 0.1 * specular) * base.rgb;
	} else {
		color = base.rgb;
	}
#else
	color = base.rgb;
#endif

	vec4 col = vec4(color.rgb, base.a);
	col *= gl_Color;
	// Due to a bug in some (older ?) graphics stacks (possibly in the glsl compiler ?),
	// the fog will only be rendered correctly if the last operation before the
	// clamp() is an addition. Else, the clamp() seems to be ignored.
	// E.g. the following won't work:
	//      float clarity = clamp(fogShadingParameter
	//		* (fogDistance - length(eyeVec)) / fogDistance), 0.0, 1.0);
	// As additions usually come for free following a multiplication, the new formula
	// should be more efficient as well.
	// Note: clarity = (1 - fogginess)
	float clarity = clamp(fogShadingParameter
		- fogShadingParameter * length(eyeVec) / fogDistance, 0.0, 1.0);
	col = mix(skyBgColor, col, clarity);

	gl_FragColor = vec4(col.rgb, base.a);
}


code:
uniform mat4 mWorldViewProj;
uniform mat4 mWorld;

uniform vec3 eyePosition;
uniform float animationTimer;

varying vec3 vPosition;
varying vec3 worldPosition;

varying vec3 eyeVec;
varying vec3 lightVec;
varying vec3 tsEyeVec;
varying vec3 tsLightVec;

const float e = 2.718281828459;
const float BS = 10.0;

void main(void)
{
	gl_TexCoord[0] = gl_MultiTexCoord0;
	gl_Position = mWorldViewProj * gl_Vertex;

	vPosition = gl_Position.xyz;
	worldPosition = (mWorld * gl_Vertex).xyz;

	vec3 sunPosition = vec3 (0.0, eyePosition.y * BS + 900.0, 0.0);

	lightVec = sunPosition - worldPosition;
	eyeVec = -(gl_ModelViewMatrix * gl_Vertex).xyz;

	gl_FrontColor = gl_BackColor = gl_Color;
}


code:
local modname = core.get_current_modname() or "??"
local modstorage = core.get_mod_storage()

-- This is an example function to ensure it's working properly, should be removed before merge
core.register_on_shutdown(function()
	print("[PREVIEW] shutdown client")
end)

core.register_on_connect(function()
	print("[PREVIEW] Player connection completed")
	local server_info = core.get_server_info()
	print("Server version: " .. server_info.protocol_version)
	print("Server ip: " .. server_info.ip)
	print("Server address: " .. server_info.address)
	print("Server port: " .. server_info.port)
end)

core.register_on_placenode(function(pointed_thing, node)
	print("The local player place a node!")
	print("pointed_thing :" .. dump(pointed_thing))
	print("node placed :" .. dump(node))
	return false
end)

core.register_on_item_use(function(itemstack, pointed_thing)
	print("The local player used an item!")
	print("pointed_thing :" .. dump(pointed_thing))
	print("item = " .. itemstack:get_name())
	return false
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)
	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)
	print("[PREVIEW] Sending message " .. message)
	return false
end)

-- This is an example function to ensure it's working properly, should be removed before merge
core.register_on_hp_modification(function(hp)
	print("[PREVIEW] HP modified " .. hp)
end)

-- This is an example function to ensure it's working properly, should be removed before merge
core.register_on_damage_taken(function(hp)
	print("[PREVIEW] Damage taken " .. hp)
end)

-- This is an example function to ensure it's working properly, should be removed before merge
core.register_globalstep(function(dtime)
	-- print("[PREVIEW] globalstep " .. dtime)
end)

-- This is an example function to ensure it's working properly, should be removed before merge
core.register_chatcommand("dump", {
	func = function(param)
		return true, dump(_G)
	end,
})

core.register_chatcommand("colorize_test", {
	func = function(param)
		return true, core.colorize("red", param)
	end,
})

core.register_chatcommand("test_node", {
	func = function(param)
		core.display_chat_message(dump(core.get_node({x=0, y=0, z=0})))
		core.display_chat_message(dump(core.get_node_or_nil({x=0, y=0, z=0})))
	end,
})

local function preview_minimap()
	local minimap = core.ui.minimap
	if not minimap then
		print("[PREVIEW] Minimap is disabled. Skipping.")
		return
	end
	minimap:set_mode(4)
	minimap:show()
	minimap:set_pos({x=5, y=50, z=5})
	minimap:set_shape(math.random(0, 1))

	print("[PREVIEW] Minimap: mode => " .. dump(minimap:get_mode()) ..
			" position => " .. dump(minimap:get_pos()) ..
			" angle => " .. dump(minimap:get_angle()))
end

core.after(2, function()
	print("[PREVIEW] loaded " .. modname .. " mod")
	modstorage:set_string("current_mod", modname)
	print(modstorage:get_string("current_mod"))
	preview_minimap()
end)

core.after(5, function()
	if core.ui.minimap then
		core.ui.minimap:show()
	end

	print("[PREVIEW] Day count: " .. core.get_day_count() ..
		" time of day " .. core.get_timeofday())

	print("[PREVIEW] Node level: " .. core.get_node_level({x=0, y=20, z=0}) ..
		" max level " .. core.get_node_max_level({x=0, y=20, z=0}))

	print("[PREVIEW] Find node near: " .. dump(core.find_node_near({x=0, y=20, z=0}, 10,
		{"group:tree", "default:dirt", "default:stone"})))
end)

core.register_on_dignode(function(pos, node)
	print("The local player dug a node!")
	print("pos:" .. dump(pos))
	print("node:" .. dump(node))
	return false
end)

core.register_on_punchnode(function(pos, node)
	print("The local player punched a node!")
	local itemstack = core.get_wielded_item()
	--[[
	-- getters
	print(dump(itemstack:is_empty()))
	print(dump(itemstack:get_name()))
	print(dump(itemstack:get_count()))
	print(dump(itemstack:get_wear()))
	print(dump(itemstack:get_meta()))
	print(dump(itemstack:get_metadata()
	print(dump(itemstack:is_known()))
	--print(dump(itemstack:get_definition()))
	print(dump(itemstack:get_tool_capabilities()))
	print(dump(itemstack:to_string()))
	print(dump(itemstack:to_table()))
	-- setters
	print(dump(itemstack:set_name("default:dirt")))
	print(dump(itemstack:set_count("95")))
	print(dump(itemstack:set_wear(934)))
	print(dump(itemstack:get_meta()))
	print(dump(itemstack:get_metadata()))
	--]]
	print(dump(itemstack:to_table()))
	print("pos:" .. dump(pos))
	print("node:" .. dump(node))
	return false
end)


code:
mark_as_advanced(CURL_LIBRARY CURL_INCLUDE_DIR)

find_library(CURL_LIBRARY NAMES curl)
find_path(CURL_INCLUDE_DIR NAMES curl/curl.h)

set(CURL_REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR)

if(WIN32)
	find_file(CURL_DLL NAMES libcurl-4.dll
		PATHS
		"C:/Windows/System32"
		DOC "Path to the cURL DLL (for installation)")
	mark_as_advanced(CURL_DLL)
	set(CURL_REQUIRED_VARS ${CURL_REQUIRED_VARS} CURL_DLL)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CURL DEFAULT_MSG ${CURL_REQUIRED_VARS})


code:
option(ENABLE_SYSTEM_GMP "Use GMP from system" TRUE)
mark_as_advanced(GMP_LIBRARY GMP_INCLUDE_DIR)
set(USE_SYSTEM_GMP FALSE)

if(ENABLE_SYSTEM_GMP)
	find_library(GMP_LIBRARY NAMES libgmp.so)
	find_path(GMP_INCLUDE_DIR NAMES gmp.h)

	if(GMP_LIBRARY AND GMP_INCLUDE_DIR)
		message (STATUS "Using GMP provided by system.")
		set(USE_SYSTEM_GMP TRUE)
	else()
		message (STATUS "Detecting GMP from system failed.")
	endif()
else()
	message (STATUS "Detecting GMP from system disabled! (ENABLE_SYSTEM_GMP=0)")
endif()

if(NOT USE_SYSTEM_GMP)
	message(STATUS "Using bundled mini-gmp library.")
	set(GMP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/gmp)
	set(GMP_LIBRARY gmp)
	add_subdirectory(lib/gmp)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GMP DEFAULT_MSG GMP_LIBRARY GMP_INCLUDE_DIR)


code:
set(CUSTOM_GETTEXT_PATH "${PROJECT_SOURCE_DIR}/../../gettext"
	CACHE FILEPATH "path to custom gettext")

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")

set(GETTEXT_REQUIRED_VARS GETTEXT_INCLUDE_DIR GETTEXT_MSGFMT)

if(APPLE)
	find_library(GETTEXT_LIBRARY
		NAMES libintl.a
		PATHS "${CUSTOM_GETTEXT_PATH}/lib"
		DOC "GetText library")

	find_library(ICONV_LIBRARY
		NAMES libiconv.dylib
		PATHS "/usr/lib"
		DOC "IConv library")
	set(GETTEXT_REQUIRED_VARS ${GETTEXT_REQUIRED_VARS} GETTEXT_LIBRARY ICONV_LIBRARY)
endif(APPLE)

# Modern Linux, as well as OSX, does not require special linking 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 library")
	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")
	set(GETTEXT_REQUIRED_VARS ${GETTEXT_REQUIRED_VARS} GETTEXT_DLL GETTEXT_ICONV_DLL)
endif(WIN32)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GetText DEFAULT_MSG ${GETTEXT_REQUIRED_VARS})

if(GETTEXT_FOUND)
	# BSD variants require special linkage as they don't use glibc
	if(${CMAKE_SYSTEM_NAME} MATCHES "BSD")
		set(GETTEXT_LIBRARY "intl")
	endif()

	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 ${LOCALEDIR}/<locale>/LC_MESSAGES)
	file(GLOB GETTEXT_AVAILABLE_LOCALES RELATIVE ${GETTEXT_PO_PATH} "${GETTEXT_PO_PATH}/*")
	list(REMOVE_ITEM GETTEXT_AVAILABLE_LOCALES minetest.pot)
	list(REMOVE_ITEM GETTEXT_AVAILABLE_LOCALES timestamp)
	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()
endif()


code:
mark_as_advanced(IRRLICHT_LIBRARY IRRLICHT_INCLUDE_DIR IRRLICHT_DLL)
set(IRRLICHT_SOURCE_DIR "" CACHE PATH "Path to irrlicht source directory (optional)")

# 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.so libIrrlicht.a Irrlicht
		PATHS
		/usr/local/lib
		/usr/lib
	)
endif()

# On Windows, find the DLL for installation
if(WIN32)
	if(MSVC)
		set(IRRLICHT_COMPILER "VisualStudio")
	else()
		set(IRRLICHT_COMPILER "gcc")
	endif()
	find_file(IRRLICHT_DLL NAMES Irrlicht.dll
		PATHS
		"${IRRLICHT_SOURCE_DIR}/bin/Win32-${IRRLICHT_COMPILER}"
		DOC "Path of the Irrlicht dll (for installation)"
	)
endif(WIN32)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Irrlicht DEFAULT_MSG IRRLICHT_LIBRARY IRRLICHT_INCLUDE_DIR)


code:
# Look for JSONCPP if asked to.
# We use a bundled version by default because some distros ship versions of
# JSONCPP that cause segfaults and other memory errors when we link with them.
# See https://github.com/minetest/minetest/issues/1793

mark_as_advanced(JSON_LIBRARY JSON_INCLUDE_DIR)
option(ENABLE_SYSTEM_JSONCPP "Enable using a system-wide JSONCPP.  May cause segfaults and other memory errors!" FALSE)

if(ENABLE_SYSTEM_JSONCPP)
	find_library(JSON_LIBRARY NAMES jsoncpp)
	find_path(JSON_INCLUDE_DIR json/features.h PATH_SUFFIXES jsoncpp)

	include(FindPackageHandleStandardArgs)
	find_package_handle_standard_args(JSONCPP DEFAULT_MSG JSON_LIBRARY JSON_INCLUDE_DIR)

	if(JSONCPP_FOUND)
		message(STATUS "Using system JSONCPP library.")
	endif()
endif()

if(NOT JSONCPP_FOUND)
	message(STATUS "Using bundled JSONCPP library.")
	set(JSON_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/jsoncpp)
	set(JSON_LIBRARY jsoncpp)
	add_subdirectory(lib/jsoncpp)
endif()


code:
# Look for Lua library to use
# This selects LuaJIT by default

option(ENABLE_LUAJIT "Enable LuaJIT support" TRUE)
set(USE_LUAJIT FALSE)
option(REQUIRE_LUAJIT "Require LuaJIT support" FALSE)
if(REQUIRE_LUAJIT)
	set(ENABLE_LUAJIT TRUE)
endif()
if(ENABLE_LUAJIT)
	find_package(LuaJIT)
	if(LUAJIT_FOUND)
		set(USE_LUAJIT TRUE)
		message (STATUS "Using LuaJIT provided by system.")
	elseif(REQUIRE_LUAJIT)
		message(FATAL_ERROR "LuaJIT not found whereas REQUIRE_LUAJIT=\"TRUE\" is used.\n"
			"To continue, either install LuaJIT or do not use REQUIRE_LUAJIT=\"TRUE\".")
	endif()
else()
	message (STATUS "LuaJIT detection disabled! (ENABLE_LUAJIT=0)")
endif()

if(NOT USE_LUAJIT)
	message(STATUS "LuaJIT not found, using bundled Lua.")
	set(LUA_LIBRARY lua)
	set(LUA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/lua/src)
	add_subdirectory(lib/lua)
endif()


code:
# Locate LuaJIT library
# This module defines
#  LUAJIT_FOUND, if false, do not try to link to Lua
#  LUA_INCLUDE_DIR, where to find lua.h
#  LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
#
# This module is similar to FindLua51.cmake except that it finds LuaJit instead.

FIND_PATH(LUA_INCLUDE_DIR luajit.h
	HINTS
	$ENV{LUA_DIR}
	PATH_SUFFIXES include/luajit-2.0 include/luajit-5_1-2.0 include
	PATHS
	~/Library/Frameworks
	/Library/Frameworks
	/sw # Fink
	/opt/local # DarwinPorts
	/opt/csw # Blastwave
	/opt
)

FIND_LIBRARY(LUA_LIBRARY
	NAMES luajit-5.1
	HINTS
	$ENV{LUA_DIR}
	PATH_SUFFIXES lib64 lib
	PATHS
	~/Library/Frameworks
	/Library/Frameworks
	/sw
	/opt/local
	/opt/csw
	/opt
)

IF(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/luajit.h")
	FILE(STRINGS "${LUA_INCLUDE_DIR}/luajit.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"LuaJIT .+\"")

	STRING(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"LuaJIT ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
	UNSET(lua_version_str)
ENDIF()

INCLUDE(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LUAJIT_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJit
	REQUIRED_VARS LUA_LIBRARY LUA_INCLUDE_DIR
	VERSION_VAR LUA_VERSION_STRING)

MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARY LUA_MATH_LIBRARY)


code:
#.rst:
# FindNcursesw
# ------------
#
# Find the ncursesw (wide ncurses) include file and library.
#
# Based on FindCurses.cmake which comes with CMake.
#
# Checks for ncursesw first. If not found, it then executes the
# regular old FindCurses.cmake to look for for ncurses (or curses).
#
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This module defines the following variables:
#
# ``CURSES_FOUND``
#   True if curses is found.
# ``NCURSESW_FOUND``
#   True if ncursesw is found.
# ``CURSES_INCLUDE_DIRS``
#   The include directories needed to use Curses.
# ``CURSES_LIBRARIES``
#   The libraries needed to use Curses.
# ``CURSES_HAVE_CURSES_H``
#   True if curses.h is available.
# ``CURSES_HAVE_NCURSES_H``
#   True if ncurses.h is available.
# ``CURSES_HAVE_NCURSES_NCURSES_H``
#   True if ``ncurses/ncurses.h`` is available.
# ``CURSES_HAVE_NCURSES_CURSES_H``
#   True if ``ncurses/curses.h`` is available.
# ``CURSES_HAVE_NCURSESW_NCURSES_H``
#   True if ``ncursesw/ncurses.h`` is available.
# ``CURSES_HAVE_NCURSESW_CURSES_H``
#   True if ``ncursesw/curses.h`` is available.
#
# Set ``CURSES_NEED_NCURSES`` to ``TRUE`` before the
# ``find_package(Ncursesw)`` call if NCurses functionality is required.
#
#=============================================================================
# Copyright 2001-2014 Kitware, Inc.
# modifications: Copyright 2015 kahrl <kahrl@gmx.net>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
#   notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
#   notice, this list of conditions and the following disclaimer in the
#   documentation and/or other materials provided with the distribution.
#
# * Neither the names of Kitware, Inc., the Insight Software Consortium,
#   nor the names of their contributors may be used to endorse or promote
#   products derived from this software without specific prior written
#   permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# ------------------------------------------------------------------------------
#
# The above copyright and license notice applies to distributions of
# CMake in source and binary form.  Some source files contain additional
# notices of original copyright by their contributors; see each source
# for details.  Third-party software packages supplied with CMake under
# compatible licenses provide their own copyright notices documented in
# corresponding subdirectories.
#
# ------------------------------------------------------------------------------
#
# CMake was initially developed by Kitware with the following sponsorship:
#
#  * National Library of Medicine at the National Institutes of Health
#    as part of the Insight Segmentation and Registration Toolkit (ITK).
#
#  * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
#    Visualization Initiative.
#
#  * National Alliance for Medical Image Computing (NAMIC) is funded by the
#    National Institutes of Health through the NIH Roadmap for Medical Research,
#    Grant U54 EB005149.
#
#  * Kitware, Inc.
#=============================================================================

include(CheckLibraryExists)

find_library(CURSES_NCURSESW_LIBRARY NAMES ncursesw
  DOC "Path to libncursesw.so or .lib or .a")

set(CURSES_USE_NCURSES FALSE)
set(CURSES_USE_NCURSESW FALSE)

if(CURSES_NCURSESW_LIBRARY)
  set(CURSES_USE_NCURSES TRUE)
  set(CURSES_USE_NCURSESW TRUE)
endif()

if(CURSES_USE_NCURSESW)
  get_filename_component(_cursesLibDir "${CURSES_NCURSESW_LIBRARY}" PATH)
  get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)

  find_path(CURSES_INCLUDE_PATH
    NAMES ncursesw/ncurses.h ncursesw/curses.h ncurses.h curses.h
    HINTS "${_cursesParentDir}/include"
    )

  # Previous versions of FindCurses provided these values.
  if(NOT DEFINED CURSES_LIBRARY)
    set(CURSES_LIBRARY "${CURSES_NCURSESW_LIBRARY}")
  endif()

  CHECK_LIBRARY_EXISTS("${CURSES_NCURSESW_LIBRARY}"
    cbreak "" CURSES_NCURSESW_HAS_CBREAK)
  if(NOT CURSES_NCURSESW_HAS_CBREAK)
    find_library(CURSES_EXTRA_LIBRARY tinfo HINTS "${_cursesLibDir}"
      DOC "Path to libtinfo.so or .lib or .a")
    find_library(CURSES_EXTRA_LIBRARY tinfo )
  endif()

  # Report whether each possible header name exists in the include directory.
  if(NOT DEFINED CURSES_HAVE_NCURSESW_NCURSES_H)
    if(EXISTS "${CURSES_INCLUDE_PATH}/ncursesw/ncurses.h")
      set(CURSES_HAVE_NCURSESW_NCURSES_H "${CURSES_INCLUDE_PATH}/ncursesw/ncurses.h")
    else()
      set(CURSES_HAVE_NCURSESW_NCURSES_H "CURSES_HAVE_NCURSESW_NCURSES_H-NOTFOUND")
    endif()
  endif()
  if(NOT DEFINED CURSES_HAVE_NCURSESW_CURSES_H)
    if(EXISTS "${CURSES_INCLUDE_PATH}/ncursesw/curses.h")
      set(CURSES_HAVE_NCURSESW_CURSES_H "${CURSES_INCLUDE_PATH}/ncursesw/curses.h")
    else()
      set(CURSES_HAVE_NCURSESW_CURSES_H "CURSES_HAVE_NCURSESW_CURSES_H-NOTFOUND")
    endif()
  endif()
  if(NOT DEFINED CURSES_HAVE_NCURSES_H)
    if(EXISTS "${CURSES_INCLUDE_PATH}/ncurses.h")
      set(CURSES_HAVE_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses.h")
    else()
      set(CURSES_HAVE_NCURSES_H "CURSES_HAVE_NCURSES_H-NOTFOUND")
    endif()
  endif()
  if(NOT DEFINED CURSES_HAVE_CURSES_H)
    if(EXISTS "${CURSES_INCLUDE_PATH}/curses.h")
      set(CURSES_HAVE_CURSES_H "${CURSES_INCLUDE_PATH}/curses.h")
    else()
      set(CURSES_HAVE_CURSES_H "CURSES_HAVE_CURSES_H-NOTFOUND")
    endif()
  endif()

  find_library(CURSES_FORM_LIBRARY form HINTS "${_cursesLibDir}"
    DOC "Path to libform.so or .lib or .a")
  find_library(CURSES_FORM_LIBRARY form )

  # Need to provide the *_LIBRARIES
  set(CURSES_LIBRARIES ${CURSES_LIBRARY})

  if(CURSES_EXTRA_LIBRARY)
    set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_EXTRA_LIBRARY})
  endif()

  if(CURSES_FORM_LIBRARY)
    set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_FORM_LIBRARY})
  endif()

  # Provide the *_INCLUDE_DIRS result.
  set(CURSES_INCLUDE_DIRS ${CURSES_INCLUDE_PATH})
  set(CURSES_INCLUDE_DIR ${CURSES_INCLUDE_PATH}) # compatibility

  # handle the QUIETLY and REQUIRED arguments and set CURSES_FOUND to TRUE if
  # all listed variables are TRUE
  include(FindPackageHandleStandardArgs)
  FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ncursesw DEFAULT_MSG
    CURSES_LIBRARY CURSES_INCLUDE_PATH)
  set(CURSES_FOUND ${NCURSESW_FOUND})

else()
  find_package(Curses)
  set(NCURSESW_FOUND FALSE)
endif()

mark_as_advanced(
  CURSES_INCLUDE_PATH
  CURSES_CURSES_LIBRARY
  CURSES_NCURSES_LIBRARY
  CURSES_NCURSESW_LIBRARY
  CURSES_EXTRA_LIBRARY
  CURSES_FORM_LIBRARY
  )