Add missing stringify_variables() function in docs

This commit is contained in:
JeremyStar™ 2024-05-07 19:15:24 +02:00
parent cd711fe0bd
commit 9ab25940bc
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -68,3 +68,17 @@ var misc: CoreBaseModule = core.misc
func _ready() -> void: func _ready() -> void:
position = misc.center_object(get_parent().size, size) position = misc.center_object(get_parent().size, size)
``` ```
### *String* <u>stringify_variables</u>(*String* <u>template</u>, *Dictionary* <u>variables</u>, *bool* <u>no_quotes</u> = *false*, *bool* <u>force_no_type</u> = *false*)
Makes variables as look correct inside strings. \
Short examples: \
`true` -> `'true'` \
`Vector2(69.064, PI)` -> `'x=69.064 y=3.14159265358979'` \
`"This is a test string"` -> `'"This is a test string"'` \
Full example: \
```
Code:
logger.diag(stringify_variables("Triggered %trigger% (pos=%position%, successful=%success%)", { "trigger": "shoot", "position": Vector2(5156.149, 581.69), "success": true }))
Output:
[16:44:35] [DIAG Test.gd] Triggered '"shoot"' (pos='x=5156.149 y=581.69', successful='true')
```