add 'assets' library docs
This commit is contained in:
parent
bef8e4b9d6
commit
2cdcebf9d9
@ -10,6 +10,7 @@ Subsections:
|
|||||||
- [Entities and components](scripting/ecs.md)
|
- [Entities and components](scripting/ecs.md)
|
||||||
- [Libraries](#)
|
- [Libraries](#)
|
||||||
- [app](scripting/builtins/libapp.md)
|
- [app](scripting/builtins/libapp.md)
|
||||||
|
- [assets](scripting/builtins/libassets.md)
|
||||||
- [base64](scripting/builtins/libbase64.md)
|
- [base64](scripting/builtins/libbase64.md)
|
||||||
- [bjson, json, toml, yaml](scripting/filesystem.md)
|
- [bjson, json, toml, yaml](scripting/filesystem.md)
|
||||||
- [block](scripting/builtins/libblock.md)
|
- [block](scripting/builtins/libblock.md)
|
||||||
|
|||||||
28
doc/en/scripting/builtins/libassets.md
Normal file
28
doc/en/scripting/builtins/libassets.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# *assets* library
|
||||||
|
|
||||||
|
A library for working with audio/visual assets.
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
```lua
|
||||||
|
-- Loads a texture
|
||||||
|
assets.load_texture(
|
||||||
|
-- Array of bytes of an image file
|
||||||
|
data: table | Bytearray,
|
||||||
|
-- Texture name after loading
|
||||||
|
name: str,
|
||||||
|
-- Image file format (only png is supported)
|
||||||
|
[optional]
|
||||||
|
format: str = "png"
|
||||||
|
)
|
||||||
|
|
||||||
|
-- Parses and loads a 3D model
|
||||||
|
assets.parse_model(
|
||||||
|
-- Model file format (xml / vcm)
|
||||||
|
format: str,
|
||||||
|
-- Contents of the model file
|
||||||
|
content: str,
|
||||||
|
-- Model name after loading
|
||||||
|
name: str
|
||||||
|
)
|
||||||
|
```
|
||||||
@ -10,6 +10,7 @@
|
|||||||
- [Сущности и компоненты](scripting/ecs.md)
|
- [Сущности и компоненты](scripting/ecs.md)
|
||||||
- [Библиотеки](#)
|
- [Библиотеки](#)
|
||||||
- [app](scripting/builtins/libapp.md)
|
- [app](scripting/builtins/libapp.md)
|
||||||
|
- [assets](scripting/builtins/libassets.md)
|
||||||
- [base64](scripting/builtins/libbase64.md)
|
- [base64](scripting/builtins/libbase64.md)
|
||||||
- [bjson, json, toml, yaml](scripting/filesystem.md)
|
- [bjson, json, toml, yaml](scripting/filesystem.md)
|
||||||
- [block](scripting/builtins/libblock.md)
|
- [block](scripting/builtins/libblock.md)
|
||||||
|
|||||||
28
doc/ru/scripting/builtins/libassets.md
Normal file
28
doc/ru/scripting/builtins/libassets.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# Библиотека *assets*
|
||||||
|
|
||||||
|
Библиотека для работы с аудио/визуальными загружаемыми ресурсами.
|
||||||
|
|
||||||
|
## Функции
|
||||||
|
|
||||||
|
```lua
|
||||||
|
-- Загружает текстуру
|
||||||
|
assets.load_texture(
|
||||||
|
-- Массив байт файла изображения
|
||||||
|
data: table | Bytearray,
|
||||||
|
-- Имя текстуры после загрузки
|
||||||
|
name: str,
|
||||||
|
-- Формат файла изображения (поддерживается только png)
|
||||||
|
[опционально]
|
||||||
|
format: str = "png"
|
||||||
|
)
|
||||||
|
|
||||||
|
-- Парсит и загружает 3D модель
|
||||||
|
assets.parse_model(
|
||||||
|
-- Формат файла модели (xml / vcm)
|
||||||
|
format: str,
|
||||||
|
-- Содержимое файла модели
|
||||||
|
content: str,
|
||||||
|
-- Имя модели после загрузки
|
||||||
|
name: str
|
||||||
|
)
|
||||||
|
```
|
||||||
@ -123,7 +123,6 @@ function run_current_file()
|
|||||||
local unit = info and info.unit
|
local unit = info and info.unit
|
||||||
|
|
||||||
if script_type == "model" then
|
if script_type == "model" then
|
||||||
print(current_file.filename)
|
|
||||||
clear_output()
|
clear_output()
|
||||||
local _, err = pcall(reload_model, current_file.filename, unit)
|
local _, err = pcall(reload_model, current_file.filename, unit)
|
||||||
if err then
|
if err then
|
||||||
|
|||||||
@ -174,7 +174,6 @@ std::unique_ptr<model::Model> vcm::parse(
|
|||||||
"'model' tag expected as root, got '" + root.getTag() + "'"
|
"'model' tag expected as root, got '" + root.getTag() + "'"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
std::cout << xml::stringify(*doc) << std::endl;
|
|
||||||
return load_model(root);
|
return load_model(root);
|
||||||
} catch (const parsing_error& err) {
|
} catch (const parsing_error& err) {
|
||||||
throw std::runtime_error(err.errorLog());
|
throw std::runtime_error(err.errorLog());
|
||||||
|
|||||||
@ -23,6 +23,9 @@ static void load_texture(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int l_load_texture(lua::State* L) {
|
static int l_load_texture(lua::State* L) {
|
||||||
|
if (lua::isstring(L, 3) && lua::require_lstring(L, 3) != "png") {
|
||||||
|
throw std::runtime_error("unsupportd image format");
|
||||||
|
}
|
||||||
if (lua::istable(L, 1)) {
|
if (lua::istable(L, 1)) {
|
||||||
lua::pushvalue(L, 1);
|
lua::pushvalue(L, 1);
|
||||||
size_t size = lua::objlen(L, 1);
|
size_t size = lua::objlen(L, 1);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user