update doc/en/scripting/builtins/libapp.md
This commit is contained in:
parent
b927c19f4f
commit
e98132f4da
@ -1,8 +1,8 @@
|
|||||||
# *app* library
|
# *app* library
|
||||||
|
|
||||||
A library for high-level engine control, available only in script/test mode.
|
A library for high-level engine control, available only in script or test mode.
|
||||||
|
|
||||||
The script/test name without path and extension is available as `app.script`. The file path can be obtained as:
|
The script/test name without the path and extension is available as `app.script`. The file path can be obtained as:
|
||||||
```lua
|
```lua
|
||||||
local filename = "script:"..app.script..".lua"
|
local filename = "script:"..app.script..".lua"
|
||||||
```
|
```
|
||||||
@ -13,31 +13,31 @@ local filename = "script:"..app.script..".lua"
|
|||||||
app.tick()
|
app.tick()
|
||||||
```
|
```
|
||||||
|
|
||||||
Executes one tick of the engine main loop.
|
Performs one tick of the main engine loop.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
app.sleep(time: number)
|
app.sleep(time: number)
|
||||||
```
|
```
|
||||||
|
|
||||||
Waits for the specified time in seconds, executing the engine main loop.
|
Waits for the specified time in seconds, performing the main engine loop.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
app.sleep_until(
|
app.sleep_until(
|
||||||
-- function that checks the wait finishing condition
|
-- function that checks the condition for ending the wait
|
||||||
predicate: function() -> bool,
|
predicate: function() -> bool,
|
||||||
-- maximum number of engine cycle ticks, after which
|
-- the maximum number of engine loop ticks after which
|
||||||
-- an exception "max ticks exceed" will be thrown
|
-- a "max ticks exceed" exception will be thrown
|
||||||
[optional] max_ticks = 1e9
|
[optional] max_ticks = 1e9
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Waits for the condition checked by the function to be true, executing the engine main loop.
|
Waits for the condition checked by the function to be true, performing the main engine loop.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
app.quit()
|
app.quit()
|
||||||
```
|
```
|
||||||
|
|
||||||
Quits the engine, printing the call stack to track where the function was called.
|
Terminates the engine, printing the call stack to trace the function call location.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
app.reconfig_packs(
|
app.reconfig_packs(
|
||||||
@ -48,7 +48,7 @@ app.reconfig_packs(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Updates the packs configuration, checking its correctness (dependencies and packs existence).
|
Updates the pack configuration, checking its correctness (dependencies and availability of packs).
|
||||||
|
|
||||||
To remove all packs from the configuration, you can use `pack.get_installed()`:
|
To remove all packs from the configuration, you can use `pack.get_installed()`:
|
||||||
|
|
||||||
@ -62,9 +62,9 @@ In this case, `base` will also be removed from the configuration.
|
|||||||
app.new_world(
|
app.new_world(
|
||||||
-- world name
|
-- world name
|
||||||
name: str,
|
name: str,
|
||||||
-- seed of generation
|
-- generation seed
|
||||||
seed: str,
|
seed: str,
|
||||||
-- name of generator
|
-- generator name
|
||||||
generator: str
|
generator: str
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
@ -102,7 +102,7 @@ Deletes a world by name.
|
|||||||
app.get_version() -> int, int
|
app.get_version() -> int, int
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns the major and minor engine versions.
|
Returns the major and minor versions of the engine.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
app.get_setting(name: str) -> value
|
app.get_setting(name: str) -> value
|
||||||
@ -119,12 +119,12 @@ Sets the value of a setting. Throws an exception if the setting does not exist.
|
|||||||
```lua
|
```lua
|
||||||
app.get_setting_info(name: str) -> {
|
app.get_setting_info(name: str) -> {
|
||||||
-- default value
|
-- default value
|
||||||
def: value
|
def: value,
|
||||||
-- minimum value
|
-- minimum value
|
||||||
[numeric settings only] min: number,
|
[only for numeric settings] min: number,
|
||||||
-- maximum value
|
-- maximum value
|
||||||
[numeric settings only] max: number
|
[only for numeric settings] max: number
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns a table with information about the setting. Throws an exception if the setting does not exist.
|
Returns a table with information about a setting. Throws an exception if the setting does not exist.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user