X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=doc%2Flua_api.txt;h=8aea490cfcadf36e927c9ae4e3b8500db3d1351b;hb=21df26984da91143c15587f5a03c98d68c3adc4e;hp=aa58bd48e65897c1cba1998210f024dc69d4a838;hpb=1f27bf6380f35656db75437bfbaecf26bf95405e;p=dragonfireclient.git diff --git a/doc/lua_api.txt b/doc/lua_api.txt index aa58bd48e..8aea490cf 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -3248,7 +3248,7 @@ Colors `#RRGGBBAA` defines a color in hexadecimal format and alpha channel. Named colors are also supported and are equivalent to -[CSS Color Module Level 4](http://dev.w3.org/csswg/css-color/#named-colors). +[CSS Color Module Level 4](https://www.w3.org/TR/css-color-4/#named-color). To specify the value of the alpha channel, append `#A` or `#AA` to the end of the color name (e.g. `colorname#08`). @@ -3283,6 +3283,8 @@ The following functions provide escape sequences: `minetest.get_color_escape_sequence(color) .. message .. minetest.get_color_escape_sequence("#ffffff")` +* `minetest.rainbow(message)`: + * Rainbow colorizes the message. * `minetest.get_background_escape_sequence(color)` * `color` is a ColorString * The escape sequence sets the background of the whole text element to @@ -3409,6 +3411,9 @@ vectors are written like this: `(x, y, z)`: * `vector.apply(v, func)`: * Returns a vector where the function `func` has been applied to each component. +* `vector.combine(v, w, func)`: + * Returns a vector where the function `func` has combined both components of `v` and `w` + for each component * `vector.equals(v1, v2)`: * Returns a boolean, `true` if the vectors are identical. * `vector.sort(v1, v2)`: @@ -3421,7 +3426,7 @@ vectors are written like this: `(x, y, z)`: * Returns the cross product of `v1` and `v2`. * `vector.offset(v, x, y, z)`: * Returns the sum of the vectors `v` and `(x, y, z)`. -* `vector.check()`: +* `vector.check(v)`: * Returns a boolean value indicating whether `v` is a real vector, eg. created by a `vector.*` function. * Returns `false` for anything else, including tables like `{x=3,y=1,z=4}`. @@ -5767,6 +5772,68 @@ Timing * `job:cancel()` * Cancels the job function from being called +Async environment +----------------- + +The engine allows you to submit jobs to be ran in an isolated environment +concurrently with normal server operation. +A job consists of a function to be ran in the async environment, any amount of +arguments (will be serialized) and a callback that will be called with the return +value of the job function once it is finished. + +The async environment does *not* have access to the map, entities, players or any +globals defined in the 'usual' environment. Consequently, functions like +`minetest.get_node()` or `minetest.get_player_by_name()` simply do not exist in it. + +Arguments and return values passed through this can contain certain userdata +objects that will be seamlessly copied (not shared) to the async environment. +This allows you easy interoperability for delegating work to jobs. + +* `minetest.handle_async(func, callback, ...)`: + * Queue the function `func` to be ran in an async environment. + Note that there are multiple persistent workers and any of them may + end up running a given job. The engine will scale the amount of + worker threads automatically. + * When `func` returns the callback is called (in the normal environment) + with all of the return values as arguments. + * Optional: Variable number of arguments that are passed to `func` +* `minetest.register_async_dofile(path)`: + * Register a path to a Lua file to be imported when an async environment + is initialized. You can use this to preload code which you can then call + later using `minetest.handle_async()`. + +### List of APIs available in an async environment + +Classes: +* `ItemStack` +* `PerlinNoise` +* `PerlinNoiseMap` +* `PseudoRandom` +* `PcgRandom` +* `SecureRandom` +* `VoxelArea` +* `VoxelManip` + * only if transferred into environment; can't read/write to map +* `Settings` + +Class instances that can be transferred between environments: +* `ItemStack` +* `PerlinNoise` +* `PerlinNoiseMap` +* `VoxelManip` + +Functions: +* Standalone helpers such as logging, filesystem, encoding, + hashing or compression APIs +* `minetest.request_insecure_environment` (same restrictions apply) + +Variables: +* `minetest.settings` +* `minetest.registered_items`, `registered_nodes`, `registered_tools`, + `registered_craftitems` and `registered_aliases` + * with all functions and userdata values replaced by `true`, calling any + callbacks here is obviously not possible + Server ------ @@ -6717,7 +6784,7 @@ object you are working with still exists. * Fourth column: subject looking to the right * Fifth column: subject viewed from above * Sixth column: subject viewed from below -* `get_entity_name()` (**Deprecated**: Will be removed in a future version) +* `get_entity_name()` (**Deprecated**: Will be removed in a future version, use the field `self.name` instead) * `get_luaentity()` #### Player only (no-op for other objects)