[Resolved] text to variable when specific condition is met breaks other code

Describe the bug
So, in my game, i have an AI which chooses the best option against you in Rock Paper Scissors but when i use [Text set to ToString(Variable(Picked))] it just shows 0. Also, yes, picked is a Text variable but it wants me to do ToString or it wont work. Even just straight up changing the text doesn’t even work. [SOLVED]

Now, my problem is that when i made some other code which changes the text when another condition is met, it works but after it just breaks all other code except the text changing just to scissors and only the buttons work. Even when i started a new preview it didn’t work, but when i did a second one it finally fixed. [Main problem still not fixed after].

Share the complete GDevelop project showing the bug

And here is the screenshot of my new code:

Please fix or show me how to change it, and thanks in advance!
[Dont mind the spelling error on Scissors :)]

In the most recent versions, you can use just the variable name without Variable() and VariableString()

This is trying to get a string but Variable() attempts to get the variable as a number. If the variable contains a string then instead of crashing it changes the value to 0.

If you’re using a newer version, you should be able to remove the old syntax and just use
Text = Picked

Using the old syntax it would be VariableString() instead of Variable() if the variable is a string.

2 Likes

Ah ok, thank you so much! It works just fine now! Should i just delete this or what?

1 Like

No need to delete it. We learn from previous posts no matter what the outcome is. Maybe change the category since it’s not a bug.

Actually i just discovered some thing else and i think its a bug.

So, i just made an advanced AI for my Bob, but when it does it once it just breaks the game, like the code doesn’t work at all except for bob just always choosing scissors and buttons working.

Here’s a screenshot of my code:

Do you know how to fix it or is it an actual bug?

From the snippet, I can’t really understand your process. Can you explain it further? Maybe more of the code needs to be shown.

Since, you’re using basic variable events, it’s unlikely to be a bug with the app. I would check the debugger to see what the value of the main variables are.

You could also add the values to the debugger output or add a text object and set it to the variable’s value. I like to use a text object then I can always see the value without using the debugger.

Maybe Learning isn’t the right value.

If the choices are equal this doesn’t check the learning value.

Is it supposed to set learning back to 0 like the other choices.

So For the equal one just exclude it as its supposed to work like normally either way, And here’s some screenshots of all my code:

(It leads to Bob’s AI code)

(After Bob’s AI code)

Also i’m confused. When i used debugger it worked just fine and it fixed everything even onto a non debugger preview until after i did the advanced AI thing and clicked scissors, it didn’t work. so yeah. (Same problem i said on the topic)

I’m still looking. Here’s what I see so far.

When the player clicks rock, it sets rock to 1 and not rock plus 1.

It’s setting playerChoice to plus 1. I wonder if those were supposed to be reversed.

If the last player choice was 3 then it would become 4.

There are events for each side winning. Is it checking for draws meaning same choice.