289 lines
11 KiB
Lua
289 lines
11 KiB
Lua
---Version: 5.18
|
|
---@meta
|
|
|
|
--- Utilities ---
|
|
|
|
---Returns the currently loading mod's name, when loading a mod.
|
|
---@return string
|
|
function core.get_current_modname() end
|
|
|
|
---Returns the directory path for a mod, e.g. `"/home/user/.minetest/"`
|
|
---@param modname string
|
|
---@return string?
|
|
function core.get_modpath(modname) end
|
|
|
|
---Returns a list of the mods' names that are loaded or are yet to be loaded during startup.
|
|
---@param load_order boolean?
|
|
function core.get_modnames(load_order) end
|
|
|
|
---@class Core.GameInfo
|
|
---@field id string
|
|
---@field title string
|
|
---@field author string
|
|
---@field path string The root directory of the game.
|
|
|
|
---Returns a table containing information about the current game.
|
|
---
|
|
---Note that other meta information (e.g. version/release number)
|
|
---can be manually read from game.conf in the game's root directory.
|
|
---@return Core.GameInfo
|
|
function core.get_game_info() end
|
|
|
|
---Returns e.g. `"/home/user/.minetest/world"`.
|
|
---@return string
|
|
function core.get_worldpath() end
|
|
|
|
---Returns e.g. `"/home/user/.minetest/mod_data/mymod"`
|
|
---@return string
|
|
function core.get_mod_data_path() end
|
|
|
|
---Returns `true` if the server is running in singleplayer mode, `false` otherwise.
|
|
---@return boolean
|
|
function core.is_singleplayer() end
|
|
|
|
---@class Core.Features
|
|
---@field glasslike_framed boolean
|
|
---@field nodebox_as_selectionbox boolean
|
|
---@field get_all_craft_recipes_works boolean
|
|
---@field use_texture_alpha boolean
|
|
---@field no_legacy_abms boolean
|
|
---@field texture_names_parens boolean
|
|
---@field area_store_custom_ids boolean
|
|
---@field add_entity_with_staticdata boolean
|
|
---@field no_chat_message_prediction boolean
|
|
---@field object_use_texture_alpha boolean
|
|
---@field object_independent_selectionbox boolean
|
|
---@field httpfetch_binary_data boolean
|
|
---@field formspec_version_element boolean
|
|
---@field area_store_persistent_ids boolean
|
|
---@field pathfinder_works boolean
|
|
---@field object_step_has_moveresult boolean
|
|
---@field direct_velocity_on_players boolean
|
|
---@field use_texture_alpha_string_modes boolean
|
|
---@field degrotate_240_steps boolean
|
|
---@field abm_min_max_y boolean
|
|
---@field dynamic_add_media_table boolean
|
|
---@field particlespawner_tweenable boolean
|
|
---@field get_sky_as_table boolean
|
|
---@field get_light_data_buffer boolean
|
|
---@field mod_storage_on_disk boolean
|
|
---@field compress_zstd boolean
|
|
---@field sound_params_start_time boolean
|
|
---@field physics_overrides_v2 boolean
|
|
---@field hud_def_type_field boolean
|
|
---@field random_state_restore boolean
|
|
---@field after_order_expiry_registration boolean
|
|
---@field wallmounted_rotate boolean
|
|
---@field item_specific_pointabilities boolean
|
|
---@field blocking_pointability_type boolean
|
|
---@field dynamic_add_media_startup boolean
|
|
---@field dynamic_add_media_filepath boolean
|
|
---@field lsystem_decoration_type boolean
|
|
---@field item_meta_range boolean
|
|
---@field node_interaction_actor boolean
|
|
---@field moveresult_new_pos boolean
|
|
---@field override_item_remove_fields boolean
|
|
---@field hotbar_hud_element boolean
|
|
---@field bulk_lbms boolean
|
|
---@field abm_without_neighbors boolean
|
|
---@field biome_weights boolean
|
|
---@field particle_blend_clip boolean
|
|
---@field remove_item_match_meta boolean
|
|
---@field httpfetch_additional_methods boolean
|
|
---@field object_guids boolean
|
|
---@field on_timer_four_args boolean
|
|
---@field particlespawner_exclude_player boolean
|
|
---@field generate_decorations_biomes boolean
|
|
---@field chunksize_vector boolean
|
|
---@field item_image_animation boolean
|
|
---@field get_modnames_load_order boolean
|
|
---@field set_camera_resettable boolean
|
|
---@field hud_hideable_field boolean
|
|
---@field compress_raw_deflate boolean
|
|
---@field get_all_craft_recipes_fuel boolean
|
|
---@field get_all_craft_recipes_replacements boolean
|
|
|
|
---Table containing server-side API feature flags.
|
|
---@type Core.Features
|
|
core.features = nil
|
|
|
|
---Checks for server-side feature availability.
|
|
---@param arg string|table
|
|
---@return boolean
|
|
---@return table<string,boolean> missing_features
|
|
function core.has_feature(arg) end
|
|
|
|
---@class Core.PlayerInformation
|
|
---@field address string
|
|
---@field ip_version integer
|
|
---@field connection_uptime integer
|
|
---@field protocol_version integer
|
|
---@field formspec_version integer
|
|
---@field lang_code string
|
|
---@field min_rtt number?
|
|
---@field max_rtt number?
|
|
---@field avg_rtt number?
|
|
---@field min_jitter number?
|
|
---@field max_jitter number?
|
|
---@field avg_jitter number?
|
|
---@field version_string string
|
|
--- The following information is available in a debug build only!!!
|
|
-- -@field serialization_version integer?
|
|
-- -@field major integer?
|
|
-- -@field minor integer?
|
|
-- -@field patch integer?
|
|
-- -@field state string?
|
|
|
|
---Table containing information about a player.
|
|
---@param player_name string
|
|
---@return Core.PlayerInformation
|
|
function core.get_player_information(player_name) end
|
|
|
|
---Table mapping Luanti versions to corresponding protocol versions for modder convenience.
|
|
---
|
|
---For example, to check whether a client has at least the feature set of Luanti 5.8.0
|
|
---or newer, you could do:
|
|
---```lua
|
|
--- core.get_player_information(player_name).protocol_version >= core.protocol_versions["5.8.0"]
|
|
---```
|
|
---@type table<string, integer>
|
|
core.protocol_versions = nil
|
|
|
|
---@class Core.PlayerWindowInformation
|
|
---@field size {x:integer,y:integer}
|
|
---@field max_formspec_size {x:integer,y:integer}
|
|
---@field real_gui_scaling number
|
|
---@field real_hud_scaling number
|
|
---@field touch_controls boolean
|
|
|
|
---@param player_name string
|
|
---@return Core.PlayerWindowInformation
|
|
function core.get_player_window_information(player_name) end
|
|
|
|
---Returns `true` if the given path exists else `false`.
|
|
---@param path string
|
|
---@return boolean
|
|
function core.path_exists(path) end
|
|
|
|
---Creates a directory specified by path, creating parent directories if they don't exist.
|
|
---
|
|
---Returns success.
|
|
---@param path string
|
|
---@return boolean success
|
|
function core.mkdir(path) end
|
|
|
|
---Removes a directory specified by path.
|
|
---
|
|
---If `recursive` is set to `true`, the directory is recursively removed.
|
|
---Otherwise, the directory will only be removed if it is empty.
|
|
---@param path string
|
|
---@param recursive boolean
|
|
---@return boolean success
|
|
function core.rmdir(path, recursive) end
|
|
|
|
---Copies a directory specified by source to destination.
|
|
---
|
|
---Any files in `destination` will be overwritten if they already exist.
|
|
---@param source string
|
|
---@param destination string
|
|
---@return boolean success
|
|
function core.cpdir(source, destination) end
|
|
|
|
---Moves a directory specified by source to destination.
|
|
---
|
|
---If the `destination` is a non-empty directory, then the move will fail.
|
|
--- @param source string
|
|
--- @param destination string
|
|
--- @return boolean success
|
|
function core.mvdir(source, destination) end
|
|
|
|
---Returns list of entry names
|
|
---@param path string
|
|
---@param is_dir boolean? is one of:
|
|
--- * `nil`: return all entries
|
|
--- * `true`: return only subdirectory names
|
|
--- * `false`: return only file names
|
|
---@return string[]
|
|
function core.get_dir_list(path, is_dir) end
|
|
|
|
---Replaces contents of file at path with new contents in a safe (atomic) way.
|
|
---
|
|
---Use this instead of below code when writing e.g. database files:
|
|
---```lua
|
|
--- local f = io.open(path, "wb"); f:write(content); f:close()
|
|
---```
|
|
---@param path string
|
|
---@param content string
|
|
function core.safe_file_write(path, content) end
|
|
|
|
---@class Core.Version
|
|
---@field project string
|
|
---@field string string
|
|
---@field proto_min integer
|
|
---@field proto_max integer
|
|
---@field hash string
|
|
---@field is_dev string
|
|
|
|
---Returns a table containing components of the engine version.
|
|
---@return Core.Version
|
|
function core.get_version() end
|
|
|
|
---Returns the sha1 hash of data.
|
|
---@param data string string of data to hash
|
|
---@param raw boolean? return raw bytes instead of hex digits, default: `false`
|
|
---@return string
|
|
function core.sha1(data, raw) end
|
|
|
|
---Returns the sha256 hash of data
|
|
---@param data string string of data to hash
|
|
---@param raw boolean? return raw bytes instead of hex digits, default: `false`
|
|
---@return string
|
|
function core.sha256(data, raw) end
|
|
|
|
---Converts a `ColorSpec` to a `ColorString`.
|
|
---
|
|
---If the ColorSpec is invalid, returns `nil`.
|
|
---@param colorspec ColorSpec
|
|
---@return ColorString?
|
|
function core.colorspec_to_colorstring(colorspec) end
|
|
|
|
---Converts a `ColorSpec` to a raw string of four bytes in an RGBA layout,
|
|
---returned as a string.
|
|
---@param colorspec ColorSpec
|
|
---@return string?
|
|
function core.colorspec_to_bytes(colorspec) end
|
|
|
|
---Converts a `ColorSpec` into RGBA table form.
|
|
---
|
|
---If the ColorSpec is invalid, returns `nil`. You can use this to parse `ColorStrings`.
|
|
---@param colorspec ColorSpec
|
|
---@return ColorTable?
|
|
function core.colorspec_to_table(colorspec) end
|
|
|
|
---Returns a `"day-night ratio"` value (as accepted by `ObjectRef:override_day_night_ratio`)
|
|
---that is equivalent to the given `"time of day"` value (as returned by `core.get_timeofday`).
|
|
---@param time_of_day number?
|
|
function core.time_to_day_night_ratio(time_of_day) end
|
|
|
|
---Encode a PNG image and return it in string form.
|
|
---@param width integer Width of the image (integer in range [u32])
|
|
---@param height integer Height of the image (integer in range [u32])
|
|
---@param data table Image data, one of:
|
|
--- * array table of ColorSpec, length must be `width*height`
|
|
--- * string with raw RGBA pixels, length must be `width*height*4`
|
|
---@param compression integer? Optional zlib compression level, integer in range [0, 9].
|
|
--- The data is one-dimensional, starting in the upper left
|
|
--- corner of the image and laid out in scanlines going from
|
|
--- left to right, then top to bottom.
|
|
--- You can use colorspec_to_bytes to generate raw RGBA values.
|
|
--- Palettes are not supported at the moment. You may use this
|
|
--- to procedurally generate textures during server init.
|
|
---@return string
|
|
function core.encode_png(width, height, data, compression) end
|
|
|
|
---Encodes reserved URI characters by a percent sign followed by two hex digits.
|
|
---
|
|
---See [RFC 3986, section 2.3](https://datatracker.ietf.org/doc/html/rfc3986#section-2.3).
|
|
---@param str string
|
|
function core.urlencode(str) end
|