From 26dcac013417f26f22cd01c9815e65e5452463b1 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 27 Jul 2024 13:36:29 +0300 Subject: [PATCH] add doc/**/libplayer.md --- doc/en/scripting.md | 133 ++++++------------------- doc/en/scripting/builtins/libplayer.md | 70 +++++++++++++ doc/ru/scripting.md | 126 +++++------------------ doc/ru/scripting/builtins/libplayer.md | 70 +++++++++++++ 4 files changed, 198 insertions(+), 201 deletions(-) create mode 100644 doc/en/scripting/builtins/libplayer.md create mode 100644 doc/ru/scripting/builtins/libplayer.md diff --git a/doc/en/scripting.md b/doc/en/scripting.md index 2ae09e3b..5de576e5 100644 --- a/doc/en/scripting.md +++ b/doc/en/scripting.md @@ -13,6 +13,7 @@ Subsections: - [entities](scripting/builtins/libentities.md) - [cameras](scripting/builtins/libcameras.md) - [mat4](scripting/builtins/libmat4.md) + - [player](scripting/builtins/libplayer.md) - [quat](scripting/builtins/libquat.md) - [vec2, vec3, vec4](scripting/builtins/libvecn.md) - [Module core:bit_converter](scripting/modules/core_bit_converter.md) @@ -62,76 +63,55 @@ file.write(pack.data_file(PACK_ID, "example.txt"), text) For pack *containermod* will write text to the file `world:data/containermod/example.txt` -## *player* library +```python +pack.get_folder(packid: str) -> str +``` + +Returns installed content-pack folder. ```python -player.get_pos(playerid: int) -> number, number, number +pack.is_installed(packid: str) -> bool ``` -Returns x, y, z coordinates of the player +Check if the world has specified pack installed. ```python -player.set_pos(playerid: int, x: number, y: number, z: number) +pack.get_installed() -> strings array ``` -Set player position +Returns all installed content-pack ids. ```python -player.get_rot(playerid: int) -> number, number, number +pack.get_available() -> strings array ``` -Returns x, y, z of camera rotation (radians) +Returns the ids of all content packs available but not installed in the world. ```python -player.set_rot(playerid: int, x: number, y: number, z: number) +pack.get_base_packs() -> strings array ``` -Set camera rotation (radians) +Returns the id of all base packages (non-removeable) ```python -player.get_inventory(playerid: int) -> int, int +pack.get_info(packid: str) -> { + id: str, + title: str, + creator: str, + description: str, + version: str, + icon: str, + dependencies: optional strings array +} ``` -Returns player inventory ID and selected slot index (0-9) - -```python -player.is_flight() -> bool -player.set_flight(bool) -``` - -Getter and setter for player flight mode - -```python -player.is_noclip() -> bool -player.set_noclip(bool) -``` - -Getter and setter for player noclip mode (collisions disabled) - -``` python -player.set_spawnpoint(playerid: int, x: number, y: number, z: number) -player.get_spawnpoint(playerid: int) -> number, number, number -``` - -Point setter and getter added by player - -```python -player.get_selected_block(playerid: int) -> x,y,z -``` - -Returns position of the selected block or nil - -```python -player.get_selected_entity(playerid: int) -> int -``` - -Returns unique indentifier of the entity selected by player - -```python -player.get_entity(playerid: int) -> int -``` - -Returns unique identifier of the player entity +Returns information about the pack (not necessarily installed). +- icon - name of the preview texture (loading automatically) +- dependencies - strings following format `{lvl}{id}`, where lvl: + - `!` - required + - `?` - optional + - `~` - weak + for example `!teal` ## *world* library @@ -200,57 +180,6 @@ world.exists() -> bool Checks the existence of a world by name. -## *pack* library - -```python -pack.get_folder(packid: str) -> str -``` - -Returns installed content-pack folder. - -```python -pack.is_installed(packid: str) -> bool -``` - -Check if the world has specified pack installed. - -```python -pack.get_installed() -> strings array -``` - -Returns all installed content-pack ids. - -```python -pack.get_available() -> strings array -``` - -Returns the ids of all content packs available but not installed in the world. - -```python -pack.get_base_packs() -> strings array -``` - -Returns the id of all base packages (non-removeable) - -```python -pack.get_info(packid: str) -> { - id: str, - title: str, - creator: str, - description: str, - version: str, - icon: str, - dependencies: optional strings array -} -``` - -Returns information about the pack (not necessarily installed). -- icon - name of the preview texture (loading automatically) -- dependencies - strings following format `{lvl}{id}`, where lvl: - - `!` - required - - `?` - optional - - `~` - weak - for example `!teal` ## *gui* library @@ -282,7 +211,7 @@ gui.get_env(document: str) -> table Returns environment (global variables table) of the specified document. ```python -get_locales_info() -> table of tables where +gui.get_locales_info() -> table of tables where key - locale id following isolangcode_ISOCOUNTRYCODE format value - table { name: str # name of the locale in its language diff --git a/doc/en/scripting/builtins/libplayer.md b/doc/en/scripting/builtins/libplayer.md new file mode 100644 index 00000000..dda4f450 --- /dev/null +++ b/doc/en/scripting/builtins/libplayer.md @@ -0,0 +1,70 @@ +# *player* library + +```python +player.get_pos(playerid: int) -> number, number, number +``` + +Returns x, y, z coordinates of the player + +```python +player.set_pos(playerid: int, x: number, y: number, z: number) +``` + +Set player position + +```python +player.get_rot(playerid: int) -> number, number, number +``` + +Returns x, y, z of camera rotation (radians) + +```python +player.set_rot(playerid: int, x: number, y: number, z: number) +``` + +Set camera rotation (radians) + +```python +player.get_inventory(playerid: int) -> int, int +``` + +Returns player inventory ID and selected slot index (0-9) + +```python +player.is_flight() -> bool +player.set_flight(bool) +``` + +Getter and setter for player flight mode + +```python +player.is_noclip() -> bool +player.set_noclip(bool) +``` + +Getter and setter for player noclip mode (collisions disabled) + +``` python +player.set_spawnpoint(playerid: int, x: number, y: number, z: number) +player.get_spawnpoint(playerid: int) -> number, number, number +``` + +Point setter and getter added by player + +```python +player.get_selected_block(playerid: int) -> x,y,z +``` + +Returns position of the selected block or nil + +```python +player.get_selected_entity(playerid: int) -> int +``` + +Returns unique indentifier of the entity selected by player + +```python +player.get_entity(playerid: int) -> int +``` + +Returns unique identifier of the player entity diff --git a/doc/ru/scripting.md b/doc/ru/scripting.md index 88ef3b09..c2c124e4 100644 --- a/doc/ru/scripting.md +++ b/doc/ru/scripting.md @@ -13,6 +13,7 @@ - [entities](scripting/builtins/libentities.md) - [cameras](scripting/builtins/libcameras.md) - [mat4](scripting/builtins/libmat4.md) + - [player](scripting/builtins/libplayer.md) - [quat](scripting/builtins/libquat.md) - [vec2, vec3, vec4](scripting/builtins/libvecn.md) - [Модуль core:bit_converter](scripting/modules/core_bit_converter.md) @@ -58,76 +59,55 @@ file.write(pack.data_file(PACK_ID, "example.txt"), text) ``` Для пака *containermod* запишет текст в файл `world:data/containermod/example.txt` -## Библиотека *player* - ```python -player.get_pos(playerid: int) -> number, number, number +pack.get_folder(packid: str) -> str ``` -Возвращает x, y, z координаты игрока +Возвращает путь к папке установленного контент-пака. ```python -player.set_pos(playerid: int, x: number, y: number, z: number) +pack.is_installed(packid: str) -> bool ``` -Устанавливает x, y, z координаты игрока +Проверяет наличие контент-пака в мире ```python -player.get_rot(playerid: int) -> number, number, number +pack.get_installed() -> массив строк ``` -Возвращает x, y, z вращения камеры (в радианах) +Возращает id всех установленных в мире контент-паков. ```python -player.set_rot(playerid: int, x: number, y: number, z: number) +pack.get_available() -> массив строк ``` -Устанавливает x, y вращения камеры (в радианах) +Возвращает id всех доступных, но не установленных в мире контент-паков. ```python -player.get_inventory(playerid: int) -> int, int +pack.get_base_packs() -> массив строк ``` -Возвращает id инвентаря игрока и индекс выбранного слота (от 0 до 9) +Возвращает id всех базовых паков (неудаляемых) ```python -player.is_flight() -> bool -player.set_flight(bool) +pack.get_info(packid: str) -> { + id: str, + title: str, + creator: str, + description: str, + version: str, + icon: str, + dependencies: опциональный массив строк +} ``` -Геттер и сеттер режима полета - -```python -player.is_noclip() -> bool -player.set_noclip(bool) -``` - -Геттер и сеттер noclip режима (выключенная коллизия игрока) - -```python -player.set_spawnpoint(playerid: int, x: number, y: number, z: number) -player.get_spawnpoint(playerid: int) -> number, number, number -``` - -Сеттер и геттер точки спавна игрока - -```python -player.get_selected_block(playerid: int) -> x,y,z -``` - -Возвращает координаты выделенного блока, либо nil - -```python -player.get_selected_entity(playerid: int) -> int -``` - -Возвращает уникальный идентификатор сущности, на которую нацелен игрок - -```python -player.get_entity(playerid: int) -> int -``` - -Возвращает уникальный идентификатор сущности игрока +Возвращает информацию о паке (не обязательно установленном). +- icon - название текстуры предпросмотра (загружается автоматически) +- dependencies - строки в формате `{lvl}{id}`, где lvl: + - `!` - required + - `?` - optional + - `~` - weak + например `!teal` ## Библиотека *world* @@ -194,58 +174,6 @@ world.is_night() -> bool Проверяет является ли текущее время ночью. От 0.8(8 вечера) до 0.2(8 утра) -## Библиотека *pack* - -```python -pack.get_folder(packid: str) -> str -``` - -Возвращает путь к папке установленного контент-пака. - -```python -pack.is_installed(packid: str) -> bool -``` - -Проверяет наличие контент-пака в мире - -```python -pack.get_installed() -> массив строк -``` - -Возращает id всех установленных в мире контент-паков. - -```python -pack.get_available() -> массив строк -``` - -Возвращает id всех доступных, но не установленных в мире контент-паков. - -```python -pack.get_base_packs() -> массив строк -``` - -Возвращает id всех базовых паков (неудаляемых) - -```python -pack.get_info(packid: str) -> { - id: str, - title: str, - creator: str, - description: str, - version: str, - icon: str, - dependencies: опциональный массив строк -} -``` - -Возвращает информацию о паке (не обязательно установленном). -- icon - название текстуры предпросмотра (загружается автоматически) -- dependencies - строки в формате `{lvl}{id}`, где lvl: - - `!` - required - - `?` - optional - - `~` - weak - например `!teal` - ## Библиотека *gui* Библиотека содержит функции для доступа к свойствам UI элементов. Вместо gui следует использовать объектную обертку, предоставляющую доступ к свойствам через мета-методы __index, __newindex: diff --git a/doc/ru/scripting/builtins/libplayer.md b/doc/ru/scripting/builtins/libplayer.md new file mode 100644 index 00000000..8b15d8df --- /dev/null +++ b/doc/ru/scripting/builtins/libplayer.md @@ -0,0 +1,70 @@ +# Библиотека *player* + +```python +player.get_pos(playerid: int) -> number, number, number +``` + +Возвращает x, y, z координаты игрока + +```python +player.set_pos(playerid: int, x: number, y: number, z: number) +``` + +Устанавливает x, y, z координаты игрока + +```python +player.get_rot(playerid: int) -> number, number, number +``` + +Возвращает x, y, z вращения камеры (в радианах) + +```python +player.set_rot(playerid: int, x: number, y: number, z: number) +``` + +Устанавливает x, y вращения камеры (в радианах) + +```python +player.get_inventory(playerid: int) -> int, int +``` + +Возвращает id инвентаря игрока и индекс выбранного слота (от 0 до 9) + +```python +player.is_flight() -> bool +player.set_flight(bool) +``` + +Геттер и сеттер режима полета + +```python +player.is_noclip() -> bool +player.set_noclip(bool) +``` + +Геттер и сеттер noclip режима (выключенная коллизия игрока) + +```python +player.set_spawnpoint(playerid: int, x: number, y: number, z: number) +player.get_spawnpoint(playerid: int) -> number, number, number +``` + +Сеттер и геттер точки спавна игрока + +```python +player.get_selected_block(playerid: int) -> x,y,z +``` + +Возвращает координаты выделенного блока, либо nil + +```python +player.get_selected_entity(playerid: int) -> int +``` + +Возвращает уникальный идентификатор сущности, на которую нацелен игрок + +```python +player.get_entity(playerid: int) -> int +``` + +Возвращает уникальный идентификатор сущности игрока