|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
jsyune1213 |
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:
string[0:3]
or
string[:3]
to get the first 4 characters, or “Hell”.
Is there a way to do this on gdscript as well?
|
|
|
 |
Reply From: |
Diet Estus |
There is talk of this being added in Godot 3.1.
See Array slicing for GDScript · Issue #4715 · godotengine/godot · GitHub for discussion as well as workarounds.
|
|
|
 |
Reply From: |
Gerardo Gonzalez |
Like this:
print("Hello".left(4))
Here the full String Class Doc
http://docs.godotengine.org/en/3.0/classes/class_string.html?highlight=String#class-string-left
I’ve been looking for this for almost 2-3 hours. :))
so how do we delete the first 4
ramazan | 2021-09-11 12:50
string = string.left(4)
sterngames | 2022-08-21 16:16
sorry, incorrect. please ignore.
sterngames | 2022-08-22 10:21
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 :)))
ramazan | 2022-08-23 09:27
? i don’t understand what you’re saying
sterngames | 2022-08-23 09:33
nevermind. I use google translation. English is not my native language
ramazan | 2022-08-23 10:23