aboutsummaryrefslogtreecommitdiff
path: root/doc/lua_api.txt
diff options
context:
space:
mode:
authorWuzzy <Wuzzy@disroot.org>2022-09-18 18:38:55 +0200
committerGitHub <noreply@github.com>2022-09-18 18:38:55 +0200
commit9acf2d3db7fe006dc47e3323003c5ef97e8f2f3e (patch)
tree749f7590a1ab6ce9cbb377f93e5b6075625147cd /doc/lua_api.txt
parent310b12b5edaaa415e664a7766b9226fc95ce89e4 (diff)
downloadminetest-9acf2d3db7fe006dc47e3323003c5ef97e8f2f3e.tar.xz
Document minetest.parse_relative_number (#12576)
Diffstat (limited to 'doc/lua_api.txt')
-rw-r--r--doc/lua_api.txt14
1 files changed, 14 insertions, 0 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index 5bac6d165..9a23bf0c7 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -6282,6 +6282,20 @@ Misc.
* Replaces definition of a builtin hud element
* `name`: `"breath"` or `"health"`
* `hud_definition`: definition to replace builtin definition
+* `minetest.parse_relative_number(arg, relative_to)`: returns number or nil
+ * Helper function for chat commands.
+ * For parsing an optionally relative number of a chat command
+ parameter, using the chat command tilde notation.
+ * `arg`: String snippet containing the number; possible values:
+ * `"<number>"`: return as number
+ * `"~<number>"`: return `relative_to + <number>`
+ * `"~"`: return `relative_to`
+ * Anything else will return `nil`
+ * `relative_to`: Number to which the `arg` number might be relative to
+ * Examples:
+ * `minetest.parse_relative_number("5", 10)` returns 5
+ * `minetest.parse_relative_number("~5", 10)` returns 15
+ * `minetest.parse_relative_number("~", 10)` returns 10
* `minetest.send_join_message(player_name)`
* This function can be overridden by mods to change the join message.
* `minetest.send_leave_message(player_name, timed_out)`