Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | andre_angelo |
I wrote a simple function to create a random string of 3 letters of the alphabet. I’m trying to print that string to the console but I’m getting the error:
modules/gdscript/gdscript_tokenizer.cpp:1129 - Condition "tk_rb[ofs].type != TK_IDENTIFIER" is true. Returned: StringName()
Here’s the code:
extends Node2D
var decoded_string : String = create_letter_string(3)
print(decoded_string)
func create_letter_string(num):
randomize()
var alphabet := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var random_letters : String
for i in num:
random_letters += alphabet[randi() % 26]
return random_letters
I can print the string inside the function, but not outside. I can’t print anything actually. My scene has only one Node and a script attached to it.
I’ve been trying to research it more myself. It looks like I need to put the first var and print() inside the _ready() function, but I’m not 100% sure why.
andre_angelo | 2021-10-31 06:27