Merge branch 'main' into release-0.25

This commit is contained in:
MihailRis
2024-11-28 18:59:37 +03:00
12 changed files with 276 additions and 3 deletions
+9
View File
@@ -187,3 +187,12 @@ Available data types:
- Currently, the total sum of the field sizes cannot exceed 240 bytes.
- A field without an array length specification is equivalent to an array of 1 element.
- A character array can be used to store UTF-8 strings.
## User properties
User properties must be declared in `pack:config/user-props.toml` file:
```toml
"pack:property_name" = {}
```
Example: [user properties of pack **base**](../../res/content/base/config/user-props.toml).
+2
View File
@@ -15,6 +15,7 @@ Subsections:
- [cameras](scripting/builtins/libcameras.md)
- [entities](scripting/builtins/libentities.md)
- [file](scripting/builtins/libfile.md)
- [gfx.blockwraps](scripting/builtins/libgfx-blockwraps.md)
- [gfx.particles](particles.md#gfxparticles-library)
- [gfx.text3d](3d-text.md#gfxtext3d-library)
- [gui](scripting/builtins/libgui.md)
@@ -22,6 +23,7 @@ Subsections:
- [inventory](scripting/builtins/libinventory.md)
- [item](scripting/builtins/libitem.md)
- [mat4](scripting/builtins/libmat4.md)
- [network](scripting/builtins/libnetwork.md)
- [pack](scripting/builtins/libpack.md)
- [player](scripting/builtins/libplayer.md)
- [quat](scripting/builtins/libquat.md)
@@ -0,0 +1,22 @@
# Library *gfx.blockwraps*
Library for working with *block wrappers*.
Block wrappers are introduced to implement block destruction animation and can be used for other purposes.
```lua
-- Creates a wrapper at the specified position, with the specified texture.
-- Returns the wrapper id.
gfx.blockwraps.wrap(position: vec3, texture: str) --> int
-- Removes the wrapper, if it exists.
gfx.blockwraps.unwrap(id: int)
-- Changes the position of the wrapper, if it exists.
gfx.blockwraps.set_pos(id: int, position: vec3)
-- Changes the texture of the wrapper, if it exists.
gfx.blockwraps.set_texture(id: int, texture: str)
```
Wrappers are not automatically removed without calling `unwrap`.
+94
View File
@@ -0,0 +1,94 @@
# *network* library
A library for working with the network.
## HTTP requests
```lua
-- Performs a GET request to the specified URL.
-- After receiving the response, passes the text to the callback function.
network.get(url: str, callback: function(str))
-- Example:
network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/latest", function (s)
print(json.parse(s).name) -- will output the name of the latest engine release
end)
-- A variant for binary files, with a byte array instead of a string in the response.
network.get_binary(url: str, callback: function(table|ByteArray))
```
## TCP Connections
```lua
network.tcp_connect(
-- Address
address: str,
-- Port
port: int,
-- Function called upon successful connection
-- Sending will not work before connection
-- Socket is passed as the only argument
callback: function(Socket)
) --> Socket
```
Initiates TCP connection.
The Socket class has the following methods:
```lua
-- Sends a byte array
socket:send(table|ByteArray)
-- Reads the received data
socket:recv(
-- Maximum size of the byte array to read
length: int,
-- Use table instead of Bytearray
[optional] usetable: bool=false
) -> nil|table|Bytearray
-- Returns nil on error (socket is closed or does not exist).
-- If there is no data yet, returns an empty byte array.
-- Closes the connection
socket:close()
-- Checks that the socket exists and is not closed.
socket:is_alive() --> bool
-- Checks if the connection is present (using socket:send(...) is available).
socket:is_connected() --> bool
```
```lua
-- Opens a TCP server.
network.tcp_open(
-- Port
port: int,
-- Function called when connecting
-- The socket of the connected client is passed as the only argument
callback: function(Socket)
) --> ServerSocket
```
The SocketServer class has the following methods:
```lua
-- Closes the server, breaking connections with clients.
server:close()
-- Checks if the TCP server exists and is open.
server:is_open() --> bool
```
## Analytics
```lua
-- Returns the approximate amount of data sent (including connections to localhost)
-- in bytes.
network.get_total_upload() --> int
-- Returns the approximate amount of data received (including connections to localhost)
-- in bytes.
network.get_total_download() --> int
```
+1
View File
@@ -98,6 +98,7 @@ Inner text is a button text.
Inner text - initially entered text
- `placeholder` - placeholder text (used if the text field is empty)
- `hint` - text displayed if the text field is empty (not sent to consumer, sub-consumer and validator).
- `supplier` - text supplier (called every frame)
- `consumer` - lua function that receives the entered text. Called only when input is complete
- `sub-consumer` - lua function-receiver of the input text. Called during text input or deletion.