Add array_to_stringarray function
This commit is contained in:
parent
35cdadf74d
commit
203018db6f
2 changed files with 15 additions and 0 deletions
|
@ -44,3 +44,7 @@ func _ready() -> void:
|
|||
logger.info(misc.format_stringarray(array))
|
||||
logger.info(misc.format_stringarray(array, "[b]", "[/b]"))
|
||||
```
|
||||
### *Array[String]* <u>array_to_stringarray</u>(*Array* array)
|
||||
Converts an array into a string array.
|
||||
|
||||
If an item is found that is not of type `String`, an empty array is returned.
|
||||
|
|
11
src/Misc.gd
11
src/Misc.gd
|
@ -60,3 +60,14 @@ func format_stringarray(array: Array[String], item_before: String = "", item_aft
|
|||
output = output.replace("If you somehow see this text report this at https://git.staropensource.de/StarOpenSource/CORE/issues, thank you!", separator_final)
|
||||
|
||||
return output
|
||||
|
||||
func array_to_stringarray(array: Array) -> Array[String]:
|
||||
var output: Array[String] = []
|
||||
|
||||
for item in array:
|
||||
if typeof(item) != TYPE_STRING:
|
||||
logger.error("Cannot convert Array to Array[String]: Item '" + str(item) + "' is not of type String")
|
||||
return []
|
||||
output.append(item)
|
||||
|
||||
return output
|
||||
|
|
Loading…
Reference in a new issue