Merge branch 'main' into blocks-renderer-and-generator-update-review

This commit is contained in:
MihailRis 2025-11-22 22:51:01 +03:00
commit 1772f0b58c
131 changed files with 2202 additions and 489 deletions

View file

@ -1,8 +1,9 @@
# Documentation
Documentation for 0.30 (in development).
Documentation for 0.30.
[Documentation for 0.29.](https://github.com/MihailRis/voxelcore/blob/release-0.29/doc/ru/main-page.md)
> [!WARNING]
> Version is in development. Proceed to [Documentation for 0.29.](https://github.com/MihailRis/voxelcore/blob/release-0.29/doc/ru/main-page.md)
## Sections

View file

@ -158,3 +158,36 @@ app.get_setting_info(name: str) -> {
```
Returns a table with information about a setting. Throws an exception if the setting does not exist.
```lua
app.focus()
```
Brings the window to front and sets input focus.
```lua
app.create_memory_device(
-- entry-point name
name: str
)
```
Creates an in-memory filesystem.
```lua
app.get_content_sources() -> table<string>
```
Returns a list of content sources (paths), in descending priority order.
``lua
app.set_content_sources(sources: table<string>)
```
Sets a list of content sources (paths). Specified in descending priority order.
``lua
app.reset_content_sources()
```
Resets content sources.

View file

@ -139,6 +139,12 @@ file.create_zip(directory: str, output_file: str) --> str
Creates a ZIP archive from the contents of the specified directory.
```lua
file.create_memory_device() --> str
```
Creates a memory file system and returns entry point name. Lives until content unload.
```lua
file.name(path: str) --> str
```

View file

@ -13,7 +13,16 @@ input.mousecode(mousename: str) --> int
Returns mouse button code or -1 if unknown
```lua
input.add_callback(bindname: str, callback: function)
input.add_callback(
-- Binding name
bindname: str,
-- Handler
callback: function
-- UI element that owns the handler (responsible for the handler's lifetime)
[optional] owner: Element,
-- Ignore input capture by UI elements
[optional] istoplevel: bool
)
```
Add binding activation callback. Example:

View file

@ -57,7 +57,10 @@ network.tcp_connect(
-- Function called upon successful connection
-- Sending will not work before connection
-- Socket is passed as the only argument
callback: function(Socket)
callback: function(Socket),
-- Function called when a connection error occurs
-- Arguments passed: socket and error text
[optional] error_callback: function(Socket, str)
) --> Socket
```
@ -79,6 +82,16 @@ socket:recv(
-- Returns nil on error (socket is closed or does not exist).
-- If there is no data yet, returns an empty byte array.
-- Asynchronous version for use in coroutines.
-- Waits for the entire specified number of bytes to be received.
-- If socket closes, function works like socket:recv
socket:recv_async(
-- Size of the byte array to read
length: int,
-- Use table instead of Bytearray
[optional] usetable: bool=false
) -> nil|table|Bytearray
-- Closes the connection
socket:close()
@ -129,3 +142,10 @@ network.get_total_upload() --> int
-- in bytes.
network.get_total_download() --> int
```
## Other
```lua
-- Looks for a free port to use.
network.find_free_port() --> int or nil
```

View file

@ -40,13 +40,13 @@ Sets x, y, z player linear velocity
player.get_rot(playerid: int, interpolated: bool) -> number, number, number
```
Returns x, y, z of camera rotation (radians). Interpolation is relevant in cases where the rotation refresh rate is lower than the frame rate.
Returns x, y, z of camera rotation (degrees). Interpolation is relevant in cases where the rotation refresh rate is lower than the frame rate.
```lua
player.set_rot(playerid: int, x: number, y: number, z: number)
```
Set camera rotation (radians)
Set camera rotation (degrees)
```lua
player.get_inventory(playerid: int) -> int, int

View file

@ -4,6 +4,10 @@
Callbacks specified in block script.
> [!WARNING]
> events such as on_block_tick, on_block_present, and on_block_removed
> can cause performance issues if used carelessly or excessively.
```lua
function on_placed(x, y, z, playerid)
```
@ -53,6 +57,21 @@ function on_block_tick(x, y, z, tps: number)
Called tps (20 / tick-interval) times per second for a block.
Use 1/tps instead of `time.delta()`.
```lua
function on_block_present(x, y, z)
```
Called for a specific block when it appears in the world (generated/loaded/placed).
The call occurs within a time period that may depend on the event queue load.
Under light load, it occurs during the first tick interval of the block.
on_block_tick is not called until the event is called.
```lua
function on_block_removed(x, y, z)
```
Called when chunk containing the block unloads.
```lua
function on_player_tick(playerid: int, tps: int)
```

View file

@ -194,13 +194,23 @@ Here, *color* can be specified in the following ways:
| data:blit(src: Canvas, dst_x: int, dst_y: int) | draws the src canvas at the specified coordinates |
| data:clear() | clears the canvas |
| data:clear(*color*) | fills the canvas with the specified RGBA color |
| data:rect(x: int, y: int, w: int, h: int, *color*) | fills the rectangle with the specified RGBA color |
| data:update() | applies changes to the canvas and uploads it to the GPU |
| data:set_data(data: table<int>) | replaces pixel data (width * height * 4 numbers) |
| data:set_data(data: Bytearray | table<int>) | replaces pixel data (width * height * 4 numbers) |
| data:get_data() | creates a Bytearray object with the image's pixel data |
| data:create_texture(name: str) | creates and shares texture to renderer |
| data:unbind_texture() | unbinds the texture from the canvas |
| data:mul(*color* or Canvas) | multiplies a color by the specified color or canvas |
| data:add(*color* or Canvas) | adds a color or another canvas to a color |
| data:sub(*color* or Canvas) | subtracts a color or another canvas to a color |
| data:encode(format: str) | encodes image to specified format and returns bytearray |
To decode a byte array into a Canvas, use the static method:
```lua
Canvas.decode(data: Bytearray, format: str) -> Canvas
```
Currently, only png is supported.
## Inline frame (iframe)

View file

@ -136,6 +136,7 @@ The key code for comparison can be obtained via `input.keycode("key_name")`
- `text-wrap` - allows automatic text wrapping (works only with multiline: "true")
- `editable` - determines whether the text can be edited.
- `line-numbers` - enables line numbers display.
- `keep-line-selection` - keep showing selected line after defocus.
- `error-color` - color when entering incorrect data (the text does not pass the validator check). Type: RGBA color.
- `text-color` - text color. Type: RGBA color.
- `validator` - lua function that checks text for correctness. Takes a string as input, returns true if the text is correct.