MV Help making Lunatic mode code for Yanfly's Item Core

I have a crafting level set to variable 64. I wanted to use Item Core's variance, with the upgrade slots extension, to make better items out with higher levels. I tested it out with some code but it didn't work at all.


<On Creation Eval>

if ($gameVariables.value[64]) == 0 {

item.randomVariance = 0; }

Else {

item.price += 100; }

</On Creation Eval>

I added in the price and the randomvariance to see what they would do, but the whole If statement doesnt even work at all.
You have a few oddities with your JavaScript syntax, I'm not sure if either of them is causing your script to fail outright (JS is a bit more loosey goosey with its syntax than some other languages). In the if statement, the parentheses should end after the entire evaluation, not with the ==0 outside of it.

Then, else is a reserved word and might not work properly if it's capitalized.

Lastly, definitely wrong, gameVariables.value is a function, not an array, so that needs to be in parentheses, not brackets: $gameVariables.value(64)

So, just to double check, how are you testing it? You're assigning a value to variable 64 and seeing if the item sells for more? You said you just added that in to see what it would do, how else do you know whether the if statement is working or not?
You have a few oddities with your JavaScript syntax, I'm not sure if either of them is causing your script to fail outright (JS is a bit more loosey goosey with its syntax than some other languages). In the if statement, the parentheses should end after the entire evaluation, not with the ==0 outside of it.

Then, else is a reserved word and might not work properly if it's capitalized.

Finally, just to double check, how are you testing it? You're assigning a value to variable 64 and seeing if the item sells for more? You said you just added that in to see what it would do, how else do you know whether the if statement is working or not?

I'm checking them by adding an armour piece, then changing the variable number and adding it again. I've fixed both of those things and now it's making the value for all of them +100.
In addition to what @ATT_Turan said,

I think it should be
$gameVariables.value(64)
not

$gameVariables.value[64]

So it should look like this(?):

<On Creation Eval>
if ($gameVariables.value(64) === 0) {
item.randomVariance = 0;
} else {
item.price += 100; }
</On Creation Eval>
You have a few oddities with your JavaScript syntax, I'm not sure if either of them is causing your script to fail outright (JS is a bit more loosey goosey with its syntax than some other languages). In the if statement, the parentheses should end after the entire evaluation, not with the ==0 outside of it.

Then, else is a reserved word and might not work properly if it's capitalized.

Lastly, definitely wrong, gameVariables.value is a function, not an array, so that needs to be in parentheses, not brackets: $gameVariables.value(64)

So, just to double check, how are you testing it? You're assigning a value to variable 64 and seeing if the item sells for more? You said you just added that in to see what it would do, how else do you know whether the if statement is working or not?
In addition to what @ATT_Turan said,

I think it should be
$gameVariables.value(64)
not

$gameVariables.value[64]

So it should look like this(?):

<On Creation Eval>
if ($gameVariables.value(64) === 0) {
item.randomVariance = 0;
} else {
item.price += 100; }
</On Creation Eval>
You are both beautiful people. The if statement works now. Now I just need to somehow work out how to change randomvariance.
Now I just need to somehow work out how to change randomvariance.
What part of its description do you not understand?
What part of its description do you not understand?
My apologies, I'm referring to UpgradeSlots from the extension, I just got confused when looking back. I've got it sort of working. It gives me 2 Upgradable slots, but it will say I have 2/3 or 2/4 on some of them. But that works fine for me.

Thank you so much for your help!
Well, the first number is how many slots are available, and the second is how many total - any difference between the two numbers should indicate you've already applied some upgrades to the item.

Original thread: https://forums.rpgmakerweb.com/threads/help-making-lunatic-mode-code-for-yanflys-item-core.137228/