update doc/*/scripting/filesystem.md

This commit is contained in:
MihailRis 2026-07-22 22:38:43 +03:00
parent cd53a33d7b
commit 13984539f5
2 changed files with 106 additions and 0 deletions

View file

@ -52,6 +52,59 @@ yaml.parse(code: str) -> table
Parses a YAML string into a table.
## XML Library
The library contains functions for serializing and deserializing XML:
Further, XML as a data type denotes a Lua table with the following structure:
- Element tag is accessible by the key `#`
- XML ​​attributes are accessible as key = value pairs
- Inner elements are accessible by index
The table is used both as a dictionary and an array.
Example:
```xml
<panel size='400' color='0' interval='1' context='menu'>
<button onclick='menu.page="worlds"'>@Worlds</button>
</panel>
```
Equivalent Lua table:
```lua
{
['#'] = "panel",
size = "400",
color = "0",
interval = "1",
context = "menu",
{
['#'] = "button",
onclick = 'menu.page="worlds"',
{
"@Worlds"
}
}
}
```
Consequently, the button element is accessible as `panel_element[1]`.
```lua
-- Serializes a tree in XML format
-- multiline - use multiline formatting
xml.tostring(data: XML, multiline: bool = true) -> str
-- Parses XML
xml.parse(code: str) -> XML
-- Parses the VCD (VoxelCore Declaration) format used by the VCM format.
-- root_tag - root element tag (the format does not require an explicit root)
xml.parse(code: str, root_tag: str = "root") -> XML
```
## *bjson* library
The library contains functions for working with the binary data exchange format [vcbjson](../../specs/binary_json_spec.md).

View file

@ -52,6 +52,59 @@ yaml.parse(code: str) -> table
Парсит YAML строку в таблицу.
## Библиотека xml
Библиотека содержит функции для сериализации и десериализации XML:
Далее XML как тип данных обозначает Lua-таблицу со следующей структурой:
- Тег элемента доступен по ключу `#`
- XML-аттрибуты доступны как пары ключ = значение
- Вложенные элементы доступны по индексу
Таблица используется как словарь, так и массив.
Пример:
```xml
<panel size='400' color='0' interval='1' context='menu'>
<button onclick='menu.page="worlds"'>@Worlds</button>
</panel>
```
Эквивалентная Lua-таблица:
```lua
{
['#'] = "panel",
size = "400",
color = "0",
interval = "1",
context = "menu",
{
['#'] = "button",
onclick = 'menu.page="worlds"',
{
"@Worlds"
}
}
}
```
Соответственно, элемент button доступен как `элемент_panel[1]`.
```lua
-- Сериализует дерево в формате XML
-- multiline - использовать ли многострочное форматирование
xml.tostring(data: XML, multiline: bool = true) -> str
-- Парсит XML
xml.parse(code: str) -> XML
-- Парсит формат VCD (VoxelCore Declaration), используемый форматом VCM.
-- root_tag - тег корневого элемента (формат не требует наличия явного)
xml.parse(code: str, root_tag: str = "root") -> XML
```
## Библиотека bjson
Библиотека содержит функции для работы с двоичным форматом обмена данными [vcbjson](../../specs/binary_json_spec.md).