Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for StringName in len function #8774

Closed
JUSTCAMH opened this issue Jan 2, 2024 · 0 comments · Fixed by godotengine/godot#86704
Closed

Add support for StringName in len function #8774

JUSTCAMH opened this issue Jan 2, 2024 · 0 comments · Fixed by godotengine/godot#86704
Milestone

Comments

@JUSTCAMH
Copy link

JUSTCAMH commented Jan 2, 2024

Describe the project you are working on

A weird text based game

Describe the problem or limitation you are having in your project

len(&"test") throws an error, but is expected to return the length of the StringName, similar to how len("test") would show the length of the String. Strings and StringName can be used interchangeably in most other GDScript contexts however where len works for Strings, it does not work for StringNames.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Update the GDScript len function to also support returning the length of a StringName.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

This would make len behave same for both Strings and StringNames, so you could do len(&"test") and get a result

If this enhancement will not be used often, can it be worked around with a few lines of script?

It can be worked around using the StringName.length() function which does the same thing. However using len is the most common method and unexpectedly breaks for StringNames where all other string functions are shared between the two.

Is there a reason why this should be core and not an add-on in the asset library?

StringNames are core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants