-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #246 from MihailRis/docs-update
update docs structure
- Loading branch information
Showing
36 changed files
with
1,140 additions
and
322 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# Console | ||
|
||
To work with the command interpreter, use the **console** library. | ||
|
||
## Commands creation | ||
|
||
To create a console command, use the following function: | ||
|
||
```python | ||
console.add_command(scheme: str, executor: function) | ||
``` | ||
|
||
Scheme has the following syntax: | ||
|
||
``` | ||
name positional arguments {keyword arguments} | ||
``` | ||
|
||
Name may contain: | ||
- latin letters | ||
- digits (except the first character) | ||
- `.`, `_`, `-` | ||
|
||
Positional arguments are separated by spaces and have the following syntax: | ||
|
||
``` | ||
name:type (option 1) | ||
name:type=default (option 2) | ||
name:type~origin (option 3) | ||
name:type=default~origin (option 4) | ||
``` | ||
|
||
Available types: | ||
- **int** - integer | ||
- **num** - floating-point number | ||
- **str** - string | ||
- **sel** - selector (object id represented by an integer) | ||
- **enum** - enumeration | ||
|
||
Options 3 and 4 show the `~` operator that allows you to use relative values. *Origin* - the value relative to which the user will be specified. For example, the player's position. | ||
|
||
The relative operator only works with numbers (num or int) | ||
|
||
Variables assigned via **console.set** can be specified as origin values. | ||
|
||
Example: | ||
|
||
```python | ||
x:num~pos.x | ||
``` | ||
|
||
Variables may be specified as default values using the `$` prefix: | ||
|
||
```python | ||
t:int=$time | ||
``` | ||
|
||
Enumerations are declared the following way: | ||
|
||
```python | ||
mode:[replace|destruct|none] | ||
``` | ||
|
||
Or with a variable: | ||
|
||
```python | ||
mode:enum $modes | ||
``` | ||
|
||
Selectors are specified with the `@` prefix. At the moment they are unused due to the lack of an object model. Should be made optional and use variables: | ||
|
||
```python | ||
obj:sel=$obj.id # obj.id - player id | ||
``` | ||
|
||
Keyword arguments are specified in a special block, delimited by curly braces `{ }`, following the same pattern as positional arguments. | ||
|
||
Example: | ||
|
||
```python | ||
eval name:str="World" {greeting:str='Hello'} | ||
``` | ||
|
||
## Command scheme examples | ||
|
||
Schemes of standard commands can be found in the file `res/script/stdcmd.lua`. | ||
|
||
Example - command **tp**: | ||
|
||
```python | ||
tp obj:sel=$obj.id x:num~pos.x y:num~pos.y z:num~pos.z | ||
``` | ||
|
||
Full lua code of the command creation: | ||
|
||
```lua | ||
console.add_command( | ||
"tp obj:sel=$obj.id x:num~pos.x y:num~pos.y z:num~pos.z", | ||
"Teleport object", | ||
function (args, kwargs) | ||
player.set_pos(unpack(args)) | ||
end | ||
) | ||
``` | ||
|
||
- Checked values of positional arguments are passed to **args**. | ||
- A table of keyword argument values is passed to **kwargs**. | ||
|
||
The command interpreter performs type checking and casting automatically. |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Documentation | ||
|
||
## Sections | ||
|
||
- [Engine usage recommendations](engine-use-recommendations.md) | ||
- [Content-packs](content-packs.md) | ||
- [Block properties](block-properties.md) | ||
- [Item properties](item-properties.md) | ||
- [XML UI building](xml-ui-layouts.md) | ||
- [Assets preloading](assets-preload.md) | ||
- [Audio](audio.md) | ||
- [Scripting](scripting.md) | ||
- [Console](console.md) | ||
- [Block models](block-models.md) |
Oops, something went wrong.