You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On output of an array of vectors write for instance: print("%[%.2v]" % [array])
On output of an array of ints write for instance: print("%[%010d]" % [array])
like in this example but for all values of type int:
print("%010d" % 12345)
# output: "0000012345"
If you have different types in one array use this syntax to support each separately: print("%[%010d %10.3f %.2v]" % [array])
So the outer "%[]" acts as a clip for the other format specifiers and qualifies for arrays. Different format specifier are separated by a space. Each format specifier is written as before.
The rest works like today with the already existing syntax.
If this enhancement will not be used often, can it be worked around with a few lines of script?
I think it will be used often. As output of arrays during development is quite common and easier than looking into them in debug.
Is there a reason why this should be core and not an add-on in the asset library?
The text was updated successfully, but these errors were encountered:
just-like-that
changed the title
Format specifier for output of arrays by using known type specifiers when printing
Format specifier for output of arrays via "%[...]" by using known type specifiers when printing
Aug 24, 2022
As the hash character looks like an array already and it's currently NOT used as format specifier I recommend to use it as array specifier instead of the brackets (see above).
So the already existing format specifiers are used in conjunction with # (the hash character) to format all items of this type in the array given.
just-like-that
changed the title
Format specifier for output of arrays via "%[...]" by using known type specifiers when printing
Format specifier for output of arrays via "%#..." by using known type specifiers when printing
Sep 7, 2023
Describe the project you are working on
A vector drawing program with primitive drawing routines.
Describe the problem or limitation you are having in your project
For logging and debugging reasons I frequently put out arrays' contents.
Especially float type and vector type tend to have long decimal parts which are usually of less interest to me.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Add format specifier for arrays by using already existing type specifiers for int, float and vector.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
On output of an array of floats write for instance:
print("%[%10.3f]" % [array])
like in this example but for all values of type float:
On output of an array of vectors write for instance:
print("%[%.2v]" % [array])
On output of an array of ints write for instance:
print("%[%010d]" % [array])
like in this example but for all values of type int:
If you have different types in one array use this syntax to support each separately:
print("%[%010d %10.3f %.2v]" % [array])
So the outer "%[]" acts as a clip for the other format specifiers and qualifies for arrays.
Different format specifier are separated by a space. Each format specifier is written as before.
The rest works like today with the already existing syntax.
If this enhancement will not be used often, can it be worked around with a few lines of script?
I think it will be used often. As output of arrays during development is quite common and easier than looking into them in debug.
Is there a reason why this should be core and not an add-on in the asset library?
Format specifier are core already.
GDScript format strings
The text was updated successfully, but these errors were encountered: