MV Need help with Yanfly's Item Synthesis

Hi,
I'm trying to add a script in the notetags when crafting an item that returns some of the items when a certain switch is triggered.
My script call is

<Custom Synthesis Effect>

if ($gameSwitches.value(255) = 1 {

$gameParty.gainItem(5, 1);

}

</Custom Synthesis Effect>

but this does nothing. What am doing wrong?
Thanks in advance!
wrong number of (

remove the first one in the if line
if ($gameSwitches.value(255) = 1 {
I don't know where you got this, but this is wrong JavaScript syntax.

1 - you use two equal signs to check a value, you're trying to assign the value of 1 to a function

2 - switches are true and false, not 1 and 0

3 - as Andar pointed out (but was backwards in his fix), you never close the parentheses

The correct code would be
Code:
if ($gameSwitches.value(255) == true)
or just
Code:
if ($gameSwitches.value(255))
OK, I was too quick and stopped looking after seeing the first error...
I don't know where you got this, but this is wrong JavaScript syntax.

1 - you use two equal signs to check a value, you're trying to assign the value of 1 to a function

2 - switches are true and false, not 1 and 0

3 - as Andar pointed out (but was backwards in his fix), you never close the parentheses

The correct code would be
Code:
if ($gameSwitches.value(255) == true)
or just
Code:
if ($gameSwitches.value(255))

So it should be

<Custom Synthesis Effect>

if ($gameSwitches.value(255)) {

$gameParty.gainItem(5, 1);

}

</Custom Synthesis Effect>

right? Still does nothing. I'm sorry, I'm trying to wrap my head around this and mostly cobbling together everything from the script call list.
mostly cobbling together everything from the script call list.
According to the script call list, gainItem() doesn't take a number for the first argument - it takes a database entry.

1731185724256.png


You would use $dataItems, $dataWeapons or $dataArmor depending on which category the item is in.
According to the script call list, gainItem() doesn't take a number for the first argument - it takes a database entry.

View attachment 322568

You would use $dataItems, $dataWeapons or $dataArmor depending on which category the item is in.

Aparantly I can't even do that properly >.<
But that did the trick! Thank you very much for your help!

Original thread: https://forums.rpgmakerweb.com/threads/need-help-with-yanflys-item-synthesis.173113/