X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=doc%2Flua_api.txt;h=59884621b66ef92b2346fe47a083de9e2999d699;hb=0bcc2f33ebe382a1dafbe6edaf00f476f2584b74;hp=7ffd17a42b05d615db810cdbe926bc978ae9c980;hpb=abd8a30c0542c75622d8e2b46e3529c9e798d227;p=dragonfireclient.git diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 7ffd17a42..59884621b 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -53,7 +53,7 @@ Games are looked up from: where `gameid` is unique to each game. -The game directory contains the file `game.conf`, which contains these fields: +The game directory contains the file `game.conf`, which contains: name = @@ -61,6 +61,16 @@ e.g. name = Minetest +Optionally, game.conf can also contain: + + disallowed_mapgens = + +e.g. + + disallowed_mapgens = v5,v6,flat + +These mapgens are removed from the list of mapgens for the game. + The game directory can contain the file minetest.conf, which will be used to set default settings when running the particular game. It can also contain a settingtypes.txt in the same format as the one in builtin. @@ -2238,25 +2248,43 @@ The following functions provide escape sequences: Spatial Vectors --------------- -* `vector.new(a[, b, c])`: returns a vector: +For the following functions, `v`, `v1`, `v2` are vectors, `p1`, `p2` are positions: + +* `vector.new(a[, b, c])`: + * Returns a vector. * A copy of `a` if `a` is a vector. - * `{x = a, y = b, z = c}`, if all `a, b, c` are defined -* `vector.direction(p1, p2)`: returns a vector -* `vector.distance(p1, p2)`: returns a number -* `vector.length(v)`: returns a number -* `vector.normalize(v)`: returns a vector -* `vector.floor(v)`: returns a vector, each dimension rounded down -* `vector.round(v)`: returns a vector, each dimension rounded to nearest int -* `vector.apply(v, func)`: returns a vector -* `vector.equals(v1, v2)`: returns a boolean -* `vector.sort(v1, v2)`: returns minp, maxp vectors of the cuboid defined by v1 and v2 + * `{x = a, y = b, z = c}`, if all of `a`, `b`, `c` are defined numbers. +* `vector.direction(p1, p2)`: + * Returns a vector of length 1 with direction `p1` to `p2`. + * If `p1` and `p2` are identical, returns `{x = 0, y = 0, z = 0}`. +* `vector.distance(p1, p2)`: + * Returns zero or a positive number, the distance between `p1` and `p2`. +* `vector.length(v)`: + * Returns zero or a positive number, the length of vector `v`. +* `vector.normalize(v)`: + * Returns a vector of length 1 with direction of vector `v`. + * If `v` has zero length, returns `{x = 0, y = 0, z = 0}`. +* `vector.floor(v)`: + * Returns a vector, each dimension rounded down. +* `vector.round(v)`: + * Returns a vector, each dimension rounded to nearest integer. +* `vector.apply(v, func)`: + * Returns a vector where the function `func` has been applied to each component. +* `vector.equals(v1, v2)`: + * Returns a boolean, `true` if the vectors are identical. +* `vector.sort(v1, v2)`: + * Returns in order minp, maxp vectors of the cuboid defined by `v1`, `v2`. For the following functions `x` can be either a vector or a number: -* `vector.add(v, x)`: returns a vector -* `vector.subtract(v, x)`: returns a vector -* `vector.multiply(v, x)`: returns a scaled vector or Schur product -* `vector.divide(v, x)`: returns a scaled vector or Schur quotient +* `vector.add(v, x)`: + * Returns a vector. +* `vector.subtract(v, x)`: + * Returns a vector. +* `vector.multiply(v, x)`: + * Returns a scaled vector or Schur product. +* `vector.divide(v, x)`: + * Returns a scaled vector or Schur quotient. Helper functions ---------------- @@ -2848,13 +2876,12 @@ and `minetest.auth_reload` call the authentication handler. * parameter was absent) * `minetest.delete_area(pos1, pos2)` * delete all mapblocks in the area from pos1 to pos2, inclusive -* `minetest.line_of_sight(pos1, pos2, stepsize)`: returns `boolean, pos` - * Check if there is a direct line of sight between `pos1` and `pos2` +* `minetest.line_of_sight(pos1, pos2)`: returns `boolean, pos` + * Checks if there is anything other than air between pos1 and pos2. + * Returns false if something is blocking the sight. * Returns the position of the blocking node when `false` * `pos1`: First position * `pos2`: Second position - * `stepsize`: smaller gives more accurate results but requires more computing - time. Default is `1`. * `minetest.raycast(pos1, pos2, objects, liquids)`: returns `Raycast` * Creates a `Raycast` object. * `pos1`: start of the ray @@ -4121,7 +4148,9 @@ It can be created via `Settings(filename)`. #### Methods * `get(key)`: returns a value -* `get_bool(key)`: returns a boolean +* `get_bool(key, [default])`: returns a boolean + * `default` is the value returned if `key` is not found. + * Returns `nil` if `key` is not found and `default` not specified. * `get_np_group(key)`: returns a NoiseParams table * `set(key, value)` * Setting names can't contain whitespace or any of `="{}#`.