Hi there! I know that this is similar to other questions in the archive, but I looked at those solutions and wasn’t able to get it to work; so I’m hoping that maybe some more personalized responses may help me.
I have here this line, pulling the variable blurb_lines which is an array of strings from one file and randomly picking one of them for my main character to say (This is a sort of Tamagotchi type virtual pet, and I want him to speak periodically).
But, the third line here–the one beginning with random_line–keeps returning this error.
Error at (28, 35): Only “String” or “StringName” can be used as index for type “Node”, but received “int”.
Obviously the int is randi_range, but what I’m intending is to pull that numbered entry from the array. The general line here works fine when used in the base file where blurb_lines originates from (I’ve only used it to print text, but it DOES work) so can anyone tell me why it’s failing here?
Apologies if there’s any information missing, I’m a beginner so it’s entirely possible I’m missing something blatantly obvious. Thanks for any help!
and it should convert it, if it doesn’t then you store something that can’t be turned into string and you need to provide more code on how these blurblines work
This one prints perfectly fine–I get a randomized choice of the three on boot. I can only guess that the issue lies somewhere between exporting blurb_lines from script one and importing it into script 2. Even trying the ‘print’ function, exactly as is, has the same issue.
ok im back, i see @baba gave great suggestion to just use array.pick_random function, unless you need weighted chance or luck modifiers for these lines then it’s your best choice probably
Yes your issue seems to be about importing and exporting blurb lines. But you didn’t write any script or information about that part. So it’s probably very hard anyone to help you, until you give more information/code related to that part.