update doc/en/scripting.md
This commit is contained in:
parent
561f6f0ea7
commit
899767c430
@ -44,10 +44,10 @@ For pack *containermod* will write text to the file `world:data/containermod/exa
|
|||||||
|
|
||||||
## *player* library
|
## *player* library
|
||||||
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
player.get_pos(playerid: int) -> number, number, number
|
player.get_pos(playerid: int) -> number, number, number
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns x, y, z coordinates of the player
|
Returns x, y, z coordinates of the player
|
||||||
|
|
||||||
```python
|
```python
|
||||||
@ -88,8 +88,25 @@ player.set_noclip(bool)
|
|||||||
|
|
||||||
Getter and setter for player noclip mode (collisions disabled)
|
Getter and setter for player noclip mode (collisions disabled)
|
||||||
|
|
||||||
|
```python
|
||||||
|
player.get_selected_block(playerid: int) -> x,y,z
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns position of the selected block or nil
|
||||||
|
|
||||||
## *world* library
|
## *world* library
|
||||||
|
|
||||||
|
## Библиотека *world*
|
||||||
|
|
||||||
|
```python
|
||||||
|
world.get_list() -> tables array {
|
||||||
|
name: str,
|
||||||
|
icon: str
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Retuns worlds information: name and preview/icon (loading automatically).
|
||||||
|
|
||||||
```python
|
```python
|
||||||
world.get_day_time() -> number
|
world.get_day_time() -> number
|
||||||
```
|
```
|
||||||
@ -114,29 +131,67 @@ world.get_seed() -> int
|
|||||||
|
|
||||||
Returns world seed.
|
Returns world seed.
|
||||||
|
|
||||||
|
```python
|
||||||
|
world.exists() -> bool
|
||||||
|
```
|
||||||
|
|
||||||
|
Checks the existence of a world by name.
|
||||||
|
|
||||||
## *pack* library
|
## *pack* library
|
||||||
|
|
||||||
```python
|
```python
|
||||||
pack.get_folder(packid: str) -> str
|
pack.get_folder(packid: str) -> str
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns installed content-pack folder
|
Returns installed content-pack folder.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
pack.is_installed(packid: str) -> bool
|
pack.is_installed(packid: str) -> bool
|
||||||
```
|
```
|
||||||
|
|
||||||
Check if the world has specified pack installed
|
Check if the world has specified pack installed.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
pack.get_installed() -> array of strings
|
pack.get_installed() -> strings array
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns all installed content-pack ids
|
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
|
## *gui* library
|
||||||
|
|
||||||
Library contains ui elements access functions. Library should not be directly used, because script *layouts/layout_name.xml.lua* already has a generated variable **document** (instance of **Document**)
|
The library contains functions for accessing the properties of UI elements. Instead of gui, you should use an object wrapper that provides access to properties through the __index, __newindex meta methods:
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@ -145,7 +200,35 @@ print(document.some_button.text) -- where 'some_button' is an element id
|
|||||||
document.some_button.text = "new text"
|
document.some_button.text = "new text"
|
||||||
```
|
```
|
||||||
|
|
||||||
## **inventory** library
|
```python
|
||||||
|
gui.str(text: str, context: str) -> str
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns translated text.
|
||||||
|
|
||||||
|
```python
|
||||||
|
gui.get_viewport() -> {int, int}
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns size of the main container (window).
|
||||||
|
|
||||||
|
```python
|
||||||
|
gui.get_env(document: str) -> table
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns environment (global variables table) of the specified document.
|
||||||
|
|
||||||
|
```python
|
||||||
|
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
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns information about all loaded locales (res/texts/\*).
|
||||||
|
|
||||||
|
## *inventory* library
|
||||||
|
|
||||||
Library for inventories interaction.
|
Library for inventories interaction.
|
||||||
|
|
||||||
@ -213,13 +296,25 @@ If slotB will be chosen automaticly if argument is not specified.
|
|||||||
block.name(blockid: int) -> str
|
block.name(blockid: int) -> str
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns block string ID (name) by index
|
Returns block string ID (name) by index.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
block.index(name: str) -> int
|
block.index(name: str) -> int
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns block integer ID (index) by name
|
Returns block integer ID (index) by name.
|
||||||
|
|
||||||
|
```python
|
||||||
|
block.material(blockid: int) -> str
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns the id of the block material.
|
||||||
|
|
||||||
|
```python
|
||||||
|
block.caption(blockid: int) -> str
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns the block name displayed in the interface.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
block.get(x: int, y: int, z: int) -> int
|
block.get(x: int, y: int, z: int) -> int
|
||||||
@ -296,6 +391,35 @@ block.set_rotation(x: int, y: int, z: int, rotation: int)
|
|||||||
|
|
||||||
Set block rotation by index.
|
Set block rotation by index.
|
||||||
|
|
||||||
|
### Extended blocks
|
||||||
|
|
||||||
|
Extended blocks are blocks with size greather than 1x1x1
|
||||||
|
|
||||||
|
```python
|
||||||
|
block.is_extended(id: int) -> bool
|
||||||
|
```
|
||||||
|
|
||||||
|
Checks whether the block is extended.
|
||||||
|
|
||||||
|
```python
|
||||||
|
block.get_size(id: int) -> int, int, int
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns the block size.
|
||||||
|
|
||||||
|
```python
|
||||||
|
block.is_segment(x: int, y: int, z: int) -> bool
|
||||||
|
```
|
||||||
|
|
||||||
|
Checks whether the block is a non-origin segment of an extended block.
|
||||||
|
|
||||||
|
```python
|
||||||
|
block.seek_origin(x: int, y: int, z: int) -> int, int, int
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns the position of the main segment of an extended block or the original position,
|
||||||
|
if the block is not extended.
|
||||||
|
|
||||||
### User bits
|
### User bits
|
||||||
|
|
||||||
Part of a voxel data used for scripting. Size: 8 bit.
|
Part of a voxel data used for scripting. Size: 8 bit.
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
require "контентпак:имя_модуля" -- загружает lua модуль из папки modules (расширение не указывается)
|
require "контентпак:имя_модуля" -- загружает lua модуль из папки modules (расширение не указывается)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Библиотека pack
|
## Библиотека *pack*
|
||||||
|
|
||||||
```python
|
```python
|
||||||
pack.is_installed(packid: str) -> bool
|
pack.is_installed(packid: str) -> bool
|
||||||
@ -38,10 +38,12 @@ file.write(pack.data_file(PACK_ID, "example.txt"), text)
|
|||||||
```
|
```
|
||||||
Для пака *containermod* запишет текст в файл `world:data/containermod/example.txt`
|
Для пака *containermod* запишет текст в файл `world:data/containermod/example.txt`
|
||||||
|
|
||||||
## Библиотека player
|
## Библиотека *player*
|
||||||
|
|
||||||
```python
|
```python
|
||||||
player.get_pos(playerid: int) -> number, number, number
|
player.get_pos(playerid: int) -> number, number, number
|
||||||
```
|
```
|
||||||
|
|
||||||
Возвращает x, y, z координаты игрока
|
Возвращает x, y, z координаты игрока
|
||||||
|
|
||||||
```python
|
```python
|
||||||
@ -88,7 +90,7 @@ player.get_selected_block(playerid: int) -> x,y,z
|
|||||||
|
|
||||||
Возвращает координаты выделенного блока, либо nil
|
Возвращает координаты выделенного блока, либо nil
|
||||||
|
|
||||||
## Библиотека world
|
## Библиотека *world*
|
||||||
|
|
||||||
```python
|
```python
|
||||||
world.get_list() -> массив таблиц {
|
world.get_list() -> массив таблиц {
|
||||||
@ -129,13 +131,13 @@ world.exists() -> bool
|
|||||||
|
|
||||||
Проверяет существование мира по имени.
|
Проверяет существование мира по имени.
|
||||||
|
|
||||||
## Библиотека pack
|
## Библиотека *pack*
|
||||||
|
|
||||||
```python
|
```python
|
||||||
pack.get_folder(packid: str) -> str
|
pack.get_folder(packid: str) -> str
|
||||||
```
|
```
|
||||||
|
|
||||||
Возвращает путь к папке установленного контент-пака
|
Возвращает путь к папке установленного контент-пака.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
pack.is_installed(packid: str) -> bool
|
pack.is_installed(packid: str) -> bool
|
||||||
@ -147,13 +149,13 @@ pack.is_installed(packid: str) -> bool
|
|||||||
pack.get_installed() -> массив строк
|
pack.get_installed() -> массив строк
|
||||||
```
|
```
|
||||||
|
|
||||||
Возращает id всех установленных в мире контент-паков
|
Возращает id всех установленных в мире контент-паков.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
pack.get_available() -> массив строк
|
pack.get_available() -> массив строк
|
||||||
```
|
```
|
||||||
|
|
||||||
Возвращает id всех доступных, но не установленных в мире контент-паков
|
Возвращает id всех доступных, но не установленных в мире контент-паков.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
pack.get_base_packs() -> массив строк
|
pack.get_base_packs() -> массив строк
|
||||||
@ -181,13 +183,13 @@ pack.get_info(packid: str) -> {
|
|||||||
- `~` - weak
|
- `~` - weak
|
||||||
например `!teal`
|
например `!teal`
|
||||||
|
|
||||||
## Библиотека gui
|
## Библиотека *gui*
|
||||||
|
|
||||||
Библиотека содержит функции для доступа к свойствам UI элементов. Вместо gui следует использовать объектную обертку, предоставляющую доступ к свойствам через мета-методы __index, __newindex:
|
Библиотека содержит функции для доступа к свойствам UI элементов. Вместо gui следует использовать объектную обертку, предоставляющую доступ к свойствам через мета-методы __index, __newindex:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local inventory_doc = Document.new("id-макета")
|
print(document.some_button.text) -- где 'some_button' - id элемета
|
||||||
print(inventory_doc.some_button.text)
|
document.some_button.text = "новый текст"
|
||||||
indentory_doc.some_button.text = "new text"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
В скрипте макета `layouts/файл_макета.xml` - `layouts/файл_макета.xml.lua` уже доступна переменная **document** содержащая объект класса Document
|
В скрипте макета `layouts/файл_макета.xml` - `layouts/файл_макета.xml.lua` уже доступна переменная **document** содержащая объект класса Document
|
||||||
@ -219,7 +221,8 @@ get_locales_info() -> таблица таблиц где
|
|||||||
```
|
```
|
||||||
|
|
||||||
Возвращает информацию о всех загруженных локалях (res/texts/\*).
|
Возвращает информацию о всех загруженных локалях (res/texts/\*).
|
||||||
## Библиотека inventory
|
|
||||||
|
## Библиотека *inventory*
|
||||||
|
|
||||||
Библиотека функций для работы с инвентарем.
|
Библиотека функций для работы с инвентарем.
|
||||||
|
|
||||||
@ -282,19 +285,19 @@ inventory.move(invA: int, slotA: int, invB: int, slotB: int)
|
|||||||
invA и invB могут указывать на один инвентарь.
|
invA и invB могут указывать на один инвентарь.
|
||||||
slotB будет выбран автоматически, если не указывать явно.
|
slotB будет выбран автоматически, если не указывать явно.
|
||||||
|
|
||||||
## Библиотека block
|
## Библиотека *block*
|
||||||
|
|
||||||
```python
|
```python
|
||||||
block.name(blockid: int) -> str
|
block.name(blockid: int) -> str
|
||||||
```
|
```
|
||||||
|
|
||||||
Возвращает строковый id блока по его числовому id
|
Возвращает строковый id блока по его числовому id.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
block.index(name: str) -> int
|
block.index(name: str) -> int
|
||||||
```
|
```
|
||||||
|
|
||||||
Возвращает числовой id блока, принимая в качестве агрумента строковый
|
Возвращает числовой id блока, принимая в качестве агрумента строковый.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
block.material(blockid: int) -> str
|
block.material(blockid: int) -> str
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user