Document minetest.parse_relative_number (#12576)

This commit is contained in:
Wuzzy 2022-09-18 18:38:55 +02:00 committed by GitHub
parent 310b12b5ed
commit 9acf2d3db7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6282,6 +6282,20 @@ Misc.
* Replaces definition of a builtin hud element * Replaces definition of a builtin hud element
* `name`: `"breath"` or `"health"` * `name`: `"breath"` or `"health"`
* `hud_definition`: definition to replace builtin definition * `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)` * `minetest.send_join_message(player_name)`
* This function can be overridden by mods to change the join message. * This function can be overridden by mods to change the join message.
* `minetest.send_leave_message(player_name, timed_out)` * `minetest.send_leave_message(player_name, timed_out)`