MV yep_attachaugments (trying to give random slots)

Hi, I'm using this plugin and trying to give the weapons a 20% chance per loop (should loop 3 times) to have a "Jewel" slot.

This is as far as I have gotten and it only adds 1 slot still
What am I missing here?

<On Creation Eval> for (let i = 0; i < 3; i++) { if (Math.random() * 5 >= 4) { item.augmentSlots.push("Jewel") item.augmentSlotEnable.push(true) } } </On Creation Eval>

Would be grateful for some help!
Do you see any error messages (red text) on the Console tab of the dev tools window? You can open it by pressing F8 during playtest (or F12 if F8 fails).

Maybe augmentSlots has not been set to an array yet? You could try this:

<On Creation Eval> // set to empty array if currently falsy (e.g. undefined) item.augmentSlots || (item.augmentSlots = []); item.augmentSlotEnable || (item.augmentSlotEnable = []); for (let i = 0; i < 3; i++) { if (Math.random() < 0.2) { item.augmentSlots.push("Jewel") item.augmentSlotEnable.push(true) } } </On Creation Eval>
I also changed the random condition because Math.random cannot generate a result of 1, so your setup was technically very very slightly less than 20% chance.

Plugin links, for easy reference:
I don't see any errors.
Using your code though produces the desired effect! I can modify this further as needed!
Thank you for the help, and I hope this helps someone else looking todo the samething.
Interesting! Good to hear it's working, happy RPG Making~ 👋

Original thread: https://forums.rpgmakerweb.com/threads/yep_attachaugments-trying-to-give-random-slots.153897/