MZ Visustella Item Crafting System: <JS Crafting Effect> to Add # of Items Crafted

I wanted to know if anyone else knew exactly how to use the <JS Crafting Effect> notetag to make more than one item per usage of the Item Crafting System.

For example, let's say I had 1 wood and 1 stone to craft one stone axe, and let's suppose that I wanted to make it craft 2 axes instead of one per use.

I want to make sure that it works to add extra items for each instance of crafting because I've tried a Common Event before to add in extra items, and the problem with that if you select multiples, let's say, you were creating 5 stone axes at once, then the common event only creates 1 extra stone axe for the entire batch (for a total of 6 instead of the target of 10). I would need to use the <JS Crafting Effect> to make it add one axe for each instance of crafting.

<JS Crafting Effect>
code
code
code
</JS Crafting Effect>

- Used for: Item, Weapon, Armor Notetags
- Replace 'code' with JavaScript code to determine what kinds of effects you
want to occur upon crafting this item.
- The 'item' variable represents the item being crafted.
- The 'number' variable represents the number of items being crafted.


So, obviously, I would have to insert some code that represents 'number' that would alter the number of items received with each instance of crafting. The problem is that I don't know what to put there.

Is there anyone who might have a suggestion? I appreciate any advice, thank you.
Sorry admins, I just wanted to update that I SOMEWHAT solved the problem, and I hit the wrong button. Didn't mean to make a reply to my own post.

I played around with it, and got it to work using this:

<JS Crafting Effect>
$gameParty.gainItem($dataItems[ID], #);
</JS Crafting Effect>


Simply replace "ID" with the ID number of the item you want to add (could be other items, doesn't have to be the item crafted), and replace # with how many. You could do this multiple times if you want.

HOWEVER, THIS DOES NOT ADD ITEMS PER INSTANCE!! It still has the same problem I described before, meaning that, for example, if you craft 1, add 2 via JS, it will give you a total of 3, but if you craft 2 instances of the item, it will give you a total 4 (i.e. it's still adding ONLY 2)... meaning that it does NOT add for each instance crafted, or in other words, players would have to craft one at a time to get the full effect intended.

Does anyone know how to solve that? (I suspect it might have to rely on what hidden game variables Visustella is using to add items, but I don't know how to find that data.)

It also does NOT appear to be added in the preview when crafting the item, so to the player's eye, it looks like you're only crafting one. I had to use <Once Craft Common Event> to add a note for the player that it has crafted more than one item for them with each craft.
Sorry admins, I just wanted to update that I SOMEWHAT solved the problem, and I hit the wrong button. Didn't mean to make a reply to my own post.

I played around with it, and got it to work using this:

<JS Crafting Effect>
$gameParty.gainItem($dataItems[ID], #);
</JS Crafting Effect>


Simply replace "ID" with the ID number of the item you want to add (could be other items, doesn't have to be the item crafted), and replace # with how many. You could do this multiple times if you want.

HOWEVER, THIS DOES NOT ADD ITEMS PER INSTANCE!! It still has the same problem I described before, meaning that, for example, if you craft 1, add 2 via JS, it will give you a total of 3, but if you craft 2 instances of the item, it will give you a total 4 (i.e. it's still adding ONLY 2)... meaning that it does NOT add for each instance crafted, or in other words, players would have to craft one at a time to get the full effect intended.

Does anyone know how to solve that? (I suspect it might have to rely on what hidden game variables Visustella is using to add items, but I don't know how to find that data.)

It also does NOT appear to be added in the preview when crafting the item, so to the player's eye, it looks like you're only crafting one. I had to use <Once Craft Common Event> to add a note for the player that it has crafted more than one item for them with each craft.
Little confused with the wording. Can you describe what u want to do and what you want the outcome to be?

Just guessing as to the result you're after:


Code:
<Crafting Ingredients>
 Item 7: 1
</Crafting Ingredients>

<JS Crafting Effect>
$gameParty.gainItem($dataItems[item.id], number * 2) // For every one crafted, create two more
</JS Crafting Effect>
Little confused with the wording. Can you describe what u want to do and what you want the outcome to be?

Just guessing as to the result you're after:


Code:
<Crafting Ingredients>
 Item 7: 1
</Crafting Ingredients>

<JS Crafting Effect>
$gameParty.gainItem($dataItems[item.id], number * 2) // For every one crafted, create two more
</JS Crafting Effect>
Well, once again, you geniuses never cease to make me feel like a total idiot. Ha ha! But you taught me something valuable when interpreting Visustella instructions from now on. It's so simple, but I just didn't understand that they meant 'number' to be a variable.

I tested it, and it works great. I really appreciate that. The only problem left is that it doesn't show it visually when selecting how many items you want to create, but it does add the extra number after it is crafted, and I'm not sure that the item number can be visually shown when selecting the amount anyway, at least, not without more info on Visustella's end. For now, I'll just stick to putting up a message on the first time crafting so the player knows.

Thanks again!
If the goal is to always have bonus(1 + 2) crafted per craft, why not just make the output 3?
I have the exact opposite problem actually. I need to know how many items are being crafted.
The <Repeat Craft Common Event: EventID> doesn't recognize if you crafted 1 or 100 items in a batch. I need an exact count of items being crafted. For example let's say a quest says: Craft 5 Potions. If you craft 5 potions in 1 craft: it only knows 1 craft was done so will only activate once - stopping me from counting down the crafted items correctly.

Is there any way currently to recognize that more than 1 item was crafted in the batch?

Original thread: https://forums.rpgmakerweb.com/threads/visustella-item-crafting-system-js-crafting-effect-to-add-of-items-crafted.159645/