The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+3 votes

In gdscript, I know that I can get a character from a specific location using something like this:

var string = "Hello"
print(string[3])        # prints "l"

In python, we can use:




to get the first 4 characters, or "Hell".

Is there a way to do this on gdscript as well?

in Engine by (21 points)

2 Answers

0 votes

There is talk of this being added in Godot 3.1.

See for discussion as well as workarounds.

by (1,600 points)
+3 votes

Like this:


Here the full String Class Doc :-D

by (190 points)

I've been looking for this for almost 2-3 hours. :))
so how do we delete the first 4

string = string.left(4)

sorry, incorrect. please ignore.

I asked myself while reading this. I had some alcohol yesterday. What did you do last night, I said to myself. Then looking at history :)))

? i don't understand what you're saying

nevermind. I use google translation. English is not my native language

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.