From 15ec1073b6c70b49af9599d362489eeeadfb7ee4 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Tue, 7 May 2024 21:34:00 +0200 Subject: [PATCH] Implement get_escape() --- docs/docs/reference/modules/misc.md | 2 ++ src/misc.gd | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/docs/docs/reference/modules/misc.md b/docs/docs/reference/modules/misc.md index b43b516..fa981f6 100644 --- a/docs/docs/reference/modules/misc.md +++ b/docs/docs/reference/modules/misc.md @@ -55,6 +55,8 @@ Converts an array into a string array. If an item is found that is not of type `String`, an empty array is returned. ### *Array* stringarray_to_array(*Array[String]* array) Converts a string array into an array. +### *String* get_escape() +Returns \ so you can (for example) print ANSI codes, which isn't normally possible because of GDScript restrictions. ### *Vector2* get_center(*Vector2* parent_size, *Vector2* child_size) Calculates the center of the child in the area of the parent. diff --git a/src/misc.gd b/src/misc.gd index 8cca428..04947ef 100644 --- a/src/misc.gd +++ b/src/misc.gd @@ -123,6 +123,10 @@ func stringarray_to_array(array: Array[String]) -> Array: return output # +++ etc +++ +## Returns \ so you can (for example) print ANSI codes, which isn't normally possible because of GDScript restrictions. +func get_escape() -> String: + return PackedByteArray([0x1b]).get_string_from_ascii() + ## Calculates the center of the child in the area of the parent.[br] ## [br] ## Example: