summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorDS <vorunbekannt75@web.de>2021-04-05 15:55:56 +0200
committerGitHub <noreply@github.com>2021-04-05 15:55:56 +0200
commit23325277659132e95b346307b591c944625bda16 (patch)
tree29523e7d4334630a302ab573810643e87e61f38a /doc
parent19c283546c5418382ed3ab648ca165ef1cc7994b (diff)
downloadminetest-23325277659132e95b346307b591c944625bda16.tar.gz
minetest-23325277659132e95b346307b591c944625bda16.tar.bz2
minetest-23325277659132e95b346307b591c944625bda16.zip
Add vector.to_string and vector.from_string (#10323)
Writing vectors as strings is very common and should belong to `vector.*`. `minetest.pos_to_string` is also too long to write, implies that one should only use it for positions and leaves no spaces after the commas.
Diffstat (limited to 'doc')
-rw-r--r--doc/lua_api.txt10
1 files changed, 10 insertions, 0 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index 3630221e3..6c1e46c7e 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -3149,6 +3149,16 @@ For the following functions, `v`, `v1`, `v2` are vectors,
* Returns a vector.
* A copy of `a` if `a` is a vector.
* `{x = a, y = b, z = c}`, if all of `a`, `b`, `c` are defined numbers.
+* `vector.from_string(s[, init])`:
+ * Returns `v, np`, where `v` is a vector read from the given string `s` and
+ `np` is the next position in the string after the vector.
+ * Returns `nil` on failure.
+ * `s`: Has to begin with a substring of the form `"(x, y, z)"`. Additional
+ spaces, leaving away commas and adding an additional comma to the end
+ is allowed.
+ * `init`: If given starts looking for the vector at this string index.
+* `vector.to_string(v)`:
+ * Returns a string of the form `"(x, y, z)"`.
* `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}`.