diff --git a/doc/en/3d-text.md b/doc/en/3d-text.md new file mode 100644 index 00000000..3f3dc7f1 --- /dev/null +++ b/doc/en/3d-text.md @@ -0,0 +1,86 @@ +# 3D Text + +2D text displayed in 3D space. + +The appearance of 3D text, is configured via a table, like [particles](particles.md). All fields are optional. + +| Field | Description | Default | +| -------------- | ---------------------------- | ---------------- | +| display | Display format | static_billboard | +| color | Text color | {1, 1, 1, 1} | +| scale | Text scale | 1 | +| renderDistance | Text rendering distance | 32 | +| xray_opacity | Visibility through obstacles | 0 | +| perspective | Perspective coefficient | 1 | + +Available display formats: + +| Format | Description | +| ----------------- | ----------------------------------------------------------------- | +| static_billboard | Simple 3D text in the world with manual size and rotation control | +| y_free_billboard | Freely rotating text on the Y axis facing the camera | +| xy_free_billboard | Freely rotating text facing the camera | +| projected | Projected text (displayed in screen coordinates) | + +## *gfx.text3d* library + +```lua +gfx.text3d.show( + -- text position + position: vec3, + -- text to display + text: str, + -- text display settings table + preset: table, + -- additional text display settings table + [optional] extension: table +) -> int +``` + +Creates 3D text, returning its id. + +```lua +gfx.text3d.hide(id: int) +``` + +Removes 3D text. + +```lua +gfx.text3d.get_text(id: int) -> str +gfx.text3d.set_text(id: int, text: str) +``` + +Text getter and setter. + +```lua +gfx.text3d.get_pos(id: int) -> vec3 +gfx.text3d.set_pos(id: int, pos: vec3) +``` + +Text position getter and setter. + +```lua +gfx.text3d.get_axis_x(id: int) -> vec3 +gfx.text3d.set_axis_x(id: int, pos: vec3) +``` + +Getter and setter of vector X. + +```lua +gfx.text3d.get_axis_y(id: int) -> vec3 +gfx.text3d.set_axis_y(id: int, pos: vec3) +``` + +Getter and setter of vector Y. + +```lua +gfx.text3d.set_rotation(id: int, rotation: mat4) +``` + +Sets the text rotation (Sets the rotated vectors X,Y). + +```lua +gfx.text3d.update_settings(id: int, preset: table) +``` + +Updates text display settings. diff --git a/doc/en/scripting.md b/doc/en/scripting.md index 7f5f3dda..6b33f7d9 100644 --- a/doc/en/scripting.md +++ b/doc/en/scripting.md @@ -9,10 +9,14 @@ Subsections: - [UI properties and methods](scripting/ui.md) - [Entities and components](scripting/ecs.md) - [Libraries](#) + - [base64](scripting/builtins/libbase64.md) + - [bjson, json, toml](scripting/filesystem.md) - [block](scripting/builtins/libblock.md) - [cameras](scripting/builtins/libcameras.md) - [entities](scripting/builtins/libentities.md) - [file](scripting/builtins/libfile.md) + - [gfx.particles](particles.md#gfxparticles-library) + - [gfx.text3d](3d-text.md#gfxtext3d-library) - [gui](scripting/builtins/libgui.md) - [hud](scripting/builtins/libhud.md) - [inventory](scripting/builtins/libinventory.md) diff --git a/doc/en/scripting/builtins/libbase64.md b/doc/en/scripting/builtins/libbase64.md new file mode 100644 index 00000000..fdfd467e --- /dev/null +++ b/doc/en/scripting/builtins/libbase64.md @@ -0,0 +1,11 @@ +# *base64* library + +Library for base64 encoding/decoding. + +```lua +-- Encode bytes to base64 string +base64.encode(bytes: table|ByteArray) -> str + +-- Decode base64 string to ByteArray or lua table if second argument is set to true +base64.decode(base64string: str, [optional]usetable: bool=false) -> table|ByteArray +``` diff --git a/doc/en/scripting/builtins/libplayer.md b/doc/en/scripting/builtins/libplayer.md index 99482c68..f71b8c95 100644 --- a/doc/en/scripting/builtins/libplayer.md +++ b/doc/en/scripting/builtins/libplayer.md @@ -77,6 +77,13 @@ player.get_spawnpoint(playerid: int) -> number, number, number Spawn point setter and getter +```lua +player.set_name(playerid: int, name: str) +player.get_name(playerid: int) -> str +``` + +Player name setter and getter + ```lua player.get_selected_block(playerid: int) -> x,y,z ``` diff --git a/doc/en/scripting/builtins/libworld.md b/doc/en/scripting/builtins/libworld.md index 349e9106..5bf01abb 100644 --- a/doc/en/scripting/builtins/libworld.md +++ b/doc/en/scripting/builtins/libworld.md @@ -10,6 +10,8 @@ world.get_list() -> tables array { name: str, -- world icon/preview (loading automatically) icon: str + -- engine version the world was saved on + version: {int, int} } -- Returns current day time in range \[0.0-1.0\] diff --git a/doc/en/scripting/events.md b/doc/en/scripting/events.md index 8dcd1a06..4b13ec7b 100644 --- a/doc/en/scripting/events.md +++ b/doc/en/scripting/events.md @@ -16,6 +16,12 @@ function on_broken(x, y, z, playerid) Called on block broken by player +```lua +function on_replaced(x, y, z, playerid) +``` + +Called on block replaced with other by player + ```lua function on_interact(x, y, z, playerid) -> bool ``` diff --git a/doc/ru/3d-text.md b/doc/ru/3d-text.md new file mode 100644 index 00000000..ac6affd3 --- /dev/null +++ b/doc/ru/3d-text.md @@ -0,0 +1,86 @@ +# 3D Текст + +2D текст отображаемый в 3D пространстве. + +Вид 3D текста, как и [частицы](particles.md), настраивается через таблицу, все поля которой опциональны. + +| Поле | Описание | По-умолчанию | +| --------------- | ------------------------------------------------------- | ----------------- | +| display | Формат отображения | static_billboard | +| color | Цвет текста | {1, 1, 1, 1} | +| scale | Масштаб | 1 | +| renderDistance | Дистанция отрисовки текста | 32 | +| xray_opacity | Коэффициент видимости через препятствия (просвечивание) | 0 | +| perspective | Коэффициент перспективы | 1 | + +Доступные форматы отображения: + +| Формат | Описание | +| ----------------- | ----------------------------------------------------------------- | +| static_billboard | Простой 3D текст в мире с ручным управлением размером и вращением | +| y_free_billboard | Свободно вращающийся по оси Y текст, направляющийся на камеру | +| xy_free_billboard | Свободно вращающийся текст, направляющийся на камеру | +| projected | Проецируемый текст (отображается в экранной системе координат) | + +## Библиотека *gfx.text3d* + +```lua +gfx.text3d.show( + -- позиция текста + position: vec3, + -- отображаемый текст + text: str, + -- таблица настроек отображение текста + preset: table, + -- дополнительная таблица настроек отображения текста + [опционально] extension: table +) -> int +``` + +Создаёт 3D текст, возвращая его id. + +```lua +gfx.text3d.hide(id: int) +``` + +Удаляет 3D текст. + +```lua +gfx.text3d.get_text(id: int) -> str +gfx.text3d.set_text(id: int, text: str) +``` + +Геттер и сеттер текста. + +```lua +gfx.text3d.get_pos(id: int) -> vec3 +gfx.text3d.set_pos(id: int, pos: vec3) +``` + +Геттер и сеттер позиции текста. + +```lua +gfx.text3d.get_axis_x(id: int) -> vec3 +gfx.text3d.set_axis_x(id: int, pos: vec3) +``` + +Геттер и сеттер вектора X. + +```lua +gfx.text3d.get_axis_y(id: int) -> vec3 +gfx.text3d.set_axis_y(id: int, pos: vec3) +``` + +Геттер и сеттер вектора Y. + +```lua +gfx.text3d.set_rotation(id: int, rotation: mat4) +``` + +Устанавливает вращение текста (Устанавливает повернутые вектора X,Y). + +```lua +gfx.text3d.update_settings(id: int, preset: table) +``` + +Обновляет настройки отображения текста. diff --git a/doc/ru/scripting.md b/doc/ru/scripting.md index 6f092570..19f4570a 100644 --- a/doc/ru/scripting.md +++ b/doc/ru/scripting.md @@ -9,10 +9,14 @@ - [Свойства и методы UI элементов](scripting/ui.md) - [Сущности и компоненты](scripting/ecs.md) - [Библиотеки](#) + - [base64](scripting/builtins/libbase64.md) + - [bjson, json, toml](scripting/filesystem.md) - [block](scripting/builtins/libblock.md) - [cameras](scripting/builtins/libcameras.md) - [entities](scripting/builtins/libentities.md) - [file](scripting/builtins/libfile.md) + - [gfx.particles](particles.md#библиотека-gfxparticles) + - [gfx.text3d](3d-text.md#библиотека-gfxtext3d) - [gui](scripting/builtins/libgui.md) - [hud](scripting/builtins/libhud.md) - [inventory](scripting/builtins/libinventory.md) diff --git a/doc/ru/scripting/builtins/libbase64.md b/doc/ru/scripting/builtins/libbase64.md new file mode 100644 index 00000000..7078fa0b --- /dev/null +++ b/doc/ru/scripting/builtins/libbase64.md @@ -0,0 +1,11 @@ +# Библиотека *base64* + +Библиотека для base64 кодирования/декодирования. + +```lua +-- Кодирует массив байт в base64 строку +base64.encode(bytes: table|ByteArray) -> str + +-- Декодирует base64 строку в ByteArray или таблицу чисел, если второй аргумент установлен на true +base64.decode(base64string: str, [опционально]usetable: bool=false) -> table|ByteArray +``` diff --git a/doc/ru/scripting/builtins/libplayer.md b/doc/ru/scripting/builtins/libplayer.md index 179e6b18..916fd4ab 100644 --- a/doc/ru/scripting/builtins/libplayer.md +++ b/doc/ru/scripting/builtins/libplayer.md @@ -77,6 +77,13 @@ player.get_spawnpoint(playerid: int) -> number, number, number Сеттер и геттер точки спавна игрока +```lua +player.set_name(playerid: int, name: str) +player.get_name(playerid: int) -> str +``` + +Сеттер и геттер имени игрока + ```lua player.get_selected_block(playerid: int) -> x,y,z ``` diff --git a/doc/ru/scripting/builtins/libworld.md b/doc/ru/scripting/builtins/libworld.md index b82f3b53..9d7d635e 100644 --- a/doc/ru/scripting/builtins/libworld.md +++ b/doc/ru/scripting/builtins/libworld.md @@ -9,7 +9,9 @@ world.get_list() -> массив таблиц { -- название мира name: str, -- предпросмотр (автоматически загружаемая текстура) - icon: str + icon: str, + -- версия движка, на которой был сохранен мир + version: {int, int} } -- Возвращает текущее игровое время от 0.0 до 1.0, где 0.0 и 1.0 - полночь, 0.5 - полдень. diff --git a/doc/ru/scripting/events.md b/doc/ru/scripting/events.md index 6d908459..08192cfa 100644 --- a/doc/ru/scripting/events.md +++ b/doc/ru/scripting/events.md @@ -16,6 +16,12 @@ function on_broken(x, y, z, playerid) Вызывается после разрушения блока игроком +```lua +function on_replaced(x, y, z, playerid) +``` + +Вызывается после замены блока игроком + ```lua function on_interact(x, y, z, playerid) -> bool ``` diff --git a/res/layouts/console.xml.lua b/res/layouts/console.xml.lua index 7d4c2771..11d7bd14 100644 --- a/res/layouts/console.xml.lua +++ b/res/layouts/console.xml.lua @@ -84,13 +84,11 @@ events.on("core:open_traceback", function(traceback_b64) framestr = framestr.."("..tostring(frame.name)..")" end local color = "#FFFFFF" - if frame.source:starts_with("core:") then - color = "#C0D0C5" - end tb_list:add(gui.template("stack_frame", { location=framestr, color=color, - callback=callback + callback=callback, + enabled=file.exists(frame.source) })) end tb_list.size = srcsize diff --git a/res/layouts/pages/worlds.xml.lua b/res/layouts/pages/worlds.xml.lua index 37c348a9..1cbcd53d 100644 --- a/res/layouts/pages/worlds.xml.lua +++ b/res/layouts/pages/worlds.xml.lua @@ -1,6 +1,13 @@ function on_open() local worlds = world.get_list() for _, info in ipairs(worlds) do + local major, minor = core.get_version() + if info.version[1] > major or info.version[2] > minor then + info.versionColor = "#A02010" + else + info.versionColor = "#808080" + end + info.versionString = string.format("%s.%s", unpack(info.version)) document.worlds:add(gui.template("world", info)) end end diff --git a/res/layouts/templates/stack_frame.xml b/res/layouts/templates/stack_frame.xml index c73890bb..16f2571c 100644 --- a/res/layouts/templates/stack_frame.xml +++ b/res/layouts/templates/stack_frame.xml @@ -1,3 +1,3 @@ -