MV Conditional Branch... is weird?

Hallo, sorry it's me again, but because I'm a noob I need your help again.

I understand most of the things in RPG Maker MV (at least the basic stuff) but I don't understand this.
Iam using the SelfVariable-Plugin of Hime, which works perfectly fine!

Know I wanted to event that I give something Food, and wanna let it check if its the Favorite Food.
So I made a SelfVariable which Contains the Number of the favorite Food. Let the Player decide
which Item to give (with modernalgebras choose-Item-Plugin) and wanna check if
"FaveFood" and "ChoosenItem" is the same Number. If "true" it should say "Favorite Food" if not, just "Food"

My problem now: even if FaveFood = ChoosenItem
It don't say "Lieblingsessen", but just "Essen", which tells me for the conditionalbrund the 2 variables are not the same.
(but the text command which tells me which numbers are in the variables says they are the same)

I'm super confused what I do wrong, because conditional branches aren't a problem normaly... maybe you see, why the "If"-Condition came out "false"?

Screenshot of EvenPage
1697122167217.png

(it's just a test-EventPage, because I dont understand, why it's not working, thats why I have a text which tells me what the variables contain)
Is Item auswahl definitely variable 9?
Yes! Definitly! See the command
1697122972034.png

Which stores the Item-ID in Variable 9 (and choose Items with note 6)

Also in the text Iam askig what V9 is containing. It says the correct number.

I even made a new Event and checked super simple if its working. (without choosing item with the PlugIn, without FaveFood in the self-variable)
Its working, without all that! So it's not a problem with the conditional Branch itself...
But I don't understand the problem with the plugIns, because they are working fine in every other event Iam using them.
Never had a problem using the self-variables or the choose-item-plugin

1697123090229.png

Is Item auswahl definitely variable 9?
Yes! Definitly! See the command View attachment 279862
Which stores the Item-ID in Variable 9 (and choose Items with note 6)

Also in the text Iam askig what V9 is containing. It says the correct number.

View attachment 279864
Okay, at the point where your message says "Essen" can you open the dev console and input the following?

JavaScript:
console.log(`${$gameVariables.value(9)} ${$gameVariables.value(18)}`);
It also says both are the same number 🙁

Here my text to check
1697123774126.png

1697123812921.png

and the dev console
I'm guessing that you've set FaveFood to the string "2" instead of the number 2. Try replacing that conditional branch with a script condition $gameVariables.value(9) == $gameVariables.value(18) (yes, this is double equals, not triple).
If that works, then types are indeed the problem - you'd need to either use scripts such as this for comparing them or find some way to set that variable to a number instead of a string.
Oh, that sounds like a logical problem to me!
this is how I randomize the favorite food number:
JavaScript:
this.set_self_variable("FaveFood", [Math.floor(Math.random() * (7 - 1 + 1)) + 1])

Could that be write into a number, or do I have to use it and compare them in the conditional branch your way?
(will try the == condition right now)

____
IT WORKED! You are right! The 2 for FaveFood is indeed a string! I didn't think about that!
With your $gameVariables.value(9) == $gameVariables.value(18) its working and gicing Lieblingsessen!

I'm guessing that you've set FaveFood to the string "2" instead of the number 2. Try replacing that conditional branch with a script condition $gameVariables.value(9) == $gameVariables.value(18) (yes, this is double equals, not triple).
If that works, then types are indeed the problem - you'd need to either use scripts such as this for comparing them or find some way to set that variable to a number instead of a string.
I'm guessing that you've set FaveFood to the string "2" instead of the number 2.
Good thought, but the console should indicate that in its output.

1697125232646.png

The lack of quotations in the OP's screenshot tells me it is, in fact, a number.
Oh, that sounds like a logical problem to me!
this is how I randomize the favorite food number:
JavaScript:
this.set_self_variable("FaveFood", [Math.floor(Math.random() * (7 - 1 + 1)) + 1])

Could that be write into a number, or do I have to use it and compare them in the conditional branch your way?
(will try the == condition right now)

____
IT WORKED! You are right! The 2 for FaveFood is indeed a string! I didn't think about that!
With your $gameVariables.value(9) == $gameVariables.value(18) its working and gicing Lieblingsessen!
I'm glad it worked 🙂 The way you're randomising it should return a number - I'm guessing the way the self variable plugin works turns those into a string. I guess you'll just have to use the script method for comparing them.
Good thought, but the console should indicate that in its output.
Trihan's snippet puts both of them in a string though 😉
1697125532700.png
But his solution works!
Maybe its because the way Iam getting the number 2?
Because that could be indentified as a string?

JavaScript:

this.set_self_variable("FaveFood", [Math.floor(Math.random() * (7 - 1 + 1)) + 1])


Thank you really really much @Mac15001900 !!
I was really confused why something so simple isn't working!
Good thought, but the console should indicate that in its output.

View attachment 279872
The lack of quotations in the OP's screenshot tells me it is, in fact, a number.
Yeah, type mismatch seems to be what the issue was. So hopefully that's it sorted!
Trihan's snippet puts both of them in a string though 😉
Oops, I missed that!
You people are great!
Thank you so much!
Hopefully I don't need to make a new question to soon. 🙂
Remove the [square brackets] and I think it'll work.

[2] is an array containing the single number 2. If coerced to a string, it becomes "2".
You are right! Its working when I left the [] !
Thank you!
Remove the [square brackets] and I think it'll work.

[2] is an array containing the single number 2. If coerced to a string, it becomes "2".

Original thread: https://forums.rpgmakerweb.com/threads/conditional-branch-is-weird.161952/