The same command chain works for some variables but not others? Please help!

Hello! I just made this account and though I've read lots of threads here before, have never posted. I am also very new to Javascript although I've picked some things up. So I apologize if this is in the wrong forum, or my terminology is off, or anything like that.

I'm creating an alchemy system where the player can choose three ingredients that they have, then those chosen ingredients are compared against all established "recipes" (specific sets of ingredient IDs) to see if any match. If so, they create a specific potion. If not, they create "Unidentifiable Sludge" and lose the ingredients. The variables used to store the chosen ingredient IDs are reset to 0 after each use, for a clean slate for next time.

Anyway, my issue is this:
I have four test recipes right now and only three of them work. They are all set up exactly the same, with the only thing differing being the IDs of the target ingredients. I noticed that the only thing that sets the non-working one apart from the others is that, while the target ingredient IDs for the first three are all single-digit values and thus formatted like "000x", two of the target ingredients in the non-working one have two-digit ID values and thus are formatted like "00xy".

I cannot even begin to fathom why this would make a difference. I changed these two-digit IDs to single-digit ones to rule out anything else, and voila! It suddenly worked! Changed them back to the original two-digit IDs, and it's not working anymore. I have double, triple, quadruple checked that I am using the correct item IDs. At the end of the day, something about those lines of script isn't compatible with "00xy" values or something, and I don't know why and don't know how to fix it...

I've included annotated screenshots to help with following along!

Anyone with more JS knowledge who knows what's going on or how I can fix/get around it? Thank you so much in advance!!
<3
Note that something like $gameVariables.value(9) === 13 simply says "is the value of game variable 9 currently equal to 13?". There is absolutely no need to use a script call for those conditions, since you can directly check a variable's value against a constant or another variable using the Conditional Branch > Variable event command. There might be other issues, but I'd try swapping out your script conditions first to see if that fixes it. 🙏

Also, in JavaScript leading zeroes on integers are unnecessary, and can cause issues if your project code is sufficiently old (pre-ES6, which I think is v1.5.1 or earlier). E.g. 0007 would be interpreted as "octal 7" which is equal to 7 in base-10 (a.k.a. decimal); 0013 would be "octal 13", which is 11 in decimal. 👋 This would affect your loseItem/gainItem script calls, especially since octal doesn't have "8" and "9" digits. I assume it would fall back to decimal for those, along with warnings in the console (F8 during test-play). 😴

(For non-integers you can safely include a zero before the point, e.g. 0.9. 😮‍💨)
leading zeros in scripts are always unneccessary for anything done in the RMs, even older ones with RGSSx.
And it has always caused problems exactly because it results in octal interpretation of the numbers.

The leading zeroes are only in the editor due to the way how the display is formatted, they should never be included in script based numbers.
Note that something like $gameVariables.value(9) === 13 simply says "is the value of game variable 9 currently equal to 13?". There is absolutely no need to use a script call for those conditions, since you can directly check a variable's value against a constant or another variable using the Conditional Branch > Variable event command.

Oh DUH!! This is exactly the perspective I needed, I've been so wrapped up in all this I didn't see the obvious LOL. I think the original reason I used a script was because I wasn't sure whether the leading zeroes were important, and I originally resorted to script instead because when I entered them in the Conditional Branch>Variable window, it defaulted from 000x format to just x. I should have taken that as a clue, duh!!

Also, in JavaScript leading zeroes on integers are unnecessary, and can cause issues if your project code is sufficiently old (pre-ES6, which I think is v1.5.1 or earlier). E.g. 0007 would be interpreted as "octal 7" which is equal to 7 in base-10 (a.k.a. decimal); 0013 would be "octal 13", which is 11 in decimal.
leading zeros in scripts are always unneccessary for anything done in the RMs, even older ones with RGSSx.
And it has always caused problems exactly because it results in octal interpretation of the numbers.

The leading zeroes are only in the editor due to the way how the display is formatted, they should never be included in script based numbers.

In any case, while this language is pretty foreign to me, it's enough for me to understand that at least there is a reason why these zeroes would make a difference, and that I'm not just going crazy!! Very good to know that the zeroes aren't needed. I was worried it had to be exact and I was so wrapped up in trying everything else that it hadn't even crossed my mind to try without. Case closed! 🙂

Thanks so much, guys!
<3

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/the-same-command-chain-works-for-some-variables-but-not-others-please-help.119334/