MZ Updating the list of recipes via the Custom Effect tag in the YEP_ItemSynthesis.js plugin

How can I make the item crafting window update immediately after creating an item? The idea is to update the list of recipes immediately after creating an item. However, the plugin command in the <Custom Effect> tag does not work on both versions of RPG Maker MV/MZ.

I tried calling the commands in the same tag:
$gameParty.gainItem($dataItems[itemId], n);
$gameParty.loseItem($dataItems[ID], amount);

But instead of the expected effect, I received an error.
We need the plugin to change the list of recipes immediately after upgrading an area of the house.

Code inside each <Custom Effect>:

<Custom Synthesis Effect>
$gameTemp._synthRecipe = undefined;
SceneManager._scene.onCancelOk();
$gameSwitches.setValue(195, true);
$gameTemp.reserveCommonEvent(195);
</Custom Synthesis Effect>

The plugin I use is YEP_ItemSynthesis.js.
Hiya, looking at the code snippet you've posted, it seems like you're trying to refresh the scene or update the switches to reflect the changes after the item synthesis. The error might be due to the way the scene refresh or how a common event call is being handled.

After synthesizing an item, the plugin should automatically handle the refresh. You might want to look into the plugin's documentation or the help file that comes with it to find the exact command for refreshing the item list.

If the plugin doesn't have a built-in method, you could try calling a refresh manually by using the `SceneManager._scene.refresh()` method, if such a method exists for the synthesis scene. You can place this call after the item has been synthesized.

The use of `$gameTemp.reserveCommonEvent(195);` is usually to call a common event, and it should be correct as long as the common event ID 195 is set up correctly in your database to refresh the crafting window. Make sure that common event contains the necessary commands to update the item list.

Also, remember that changes in the game's database like updating a recipe list might not reflect immediately during playtest unless the scene is reloaded. If all else fails, consider looking for a script call that forces the scene to reload, which in turn should update your recipe list.

Good luck with your synthesis system ^_^
But instead of the expected effect, I received an error.
That doesn't tell us anything - what is the error?

Press F8 and go to the Console tab and post a screenshot of the error trace.
Making_JRPGs_with_AI, ATT_Turan
And so... After much manipulation with the code, I found a solution:
<Synthesis Ingredients>
item 200: 6
item 194: 4
item 204: 6
item 206: 2
</Synthesis Ingredients>
<Custom Synthesis Effect>
$gameTemp._synthRecipe = undefined;
$gameParty.loseItem($dataItems[155], 1);
SceneManager._scene.refreshWindows();
</Custom Synthesis Effect>

As soon as a player creates an item, he loses the recipe for this item($gameParty.loseItem($dataItems[155], 1)😉 and the crafting window is immediately updated (SceneManager._scene.refreshWindows()😉.
"$gameTemp._synthRecipe = undefined;" - I'm not sure what it is, but I decided to leave it just in case.
You really only need to refresh that one window, but it doesn't hurt anything to do them all.

"$gameTemp._synthRecipe = undefined;" - I'm not sure what it is, but I decided to leave it just in case.
Then why have it? Where did the line of code come from?

ATT_Turan​

Not sure if this line of code is needed. But I decided to leave it just in case.
I originally thought that I should clear the local recipe list database first and then do the rest.

Original thread: https://forums.rpgmakerweb.com/threads/updating-the-list-of-recipes-via-the-custom-effect-tag-in-the-yep_itemsynthesis-js-plugin.162631/