MV Item Core Yanfly Script Question

Hello everyone! and thanks in advance for your help. I am using yanfly item core and I have a specific question about random variance and if there is a possible way to set each mod roll for each stats.

If I understand correctly the use of random variance in the tag note.
<Random variance: 3> are defined for each stat that has at least plus or minus 0.


I am Mushie the shroommi!
bump
Yes. The end of the documentation provides an On Creation Eval tag that allows you to supply JavaScript that will be run when the item is created. Enter whatever formulae you like for individual stats.
I'm currently learning about JavaScript and {On Creation Eval} so if i did something wrong.. can you give me a hand?


<On Creation Eval>

(Math.random($item.params[3]) * (5));

</On Creation Eval>
?
You also wrote me a PM with the same question - if you want to get someone's attention in a thread, you can Quote something from them, or type @Username.

I'll quote my PM reply here, for anyone else looking at the thread:

It's a little hard to know if you did anything wrong without knowing what you want to do. The one thing that's immediately wrong is your code is going to throw an error - there's no such thing as "$item".

Once you type it correctly, your code will increase the wielder's Attack by a random number between 0 and 4. Is that what you want it to do?

Aside from that, you have a lot of extra, random parentheses. They shouldn't make the code not work, but they're unnecessary, and it'll make it harder for you to stay organized when you do need them to group information. Your line should just be: Math.random(item.params[3])*5;
You also wrote me a PM with the same question - if you want to get someone's attention in a thread, you can Quote something from them, or type @Username.

I'll quote my PM reply here, for anyone else looking at the thread:

It's a little hard to know if you did anything wrong without knowing what you want to do. The one thing that's immediately wrong is your code is going to throw an error - there's no such thing as "$item".

Once you type it correctly, your code will increase the wielder's Attack by a random number between 0 and 4. Is that what you want it to do?

Aside from that, you have a lot of extra, random parentheses. They shouldn't make the code not work, but they're unnecessary, and it'll make it harder for you to stay organized when you do need them to group information. Your line should just be: Math.random(item.params[3])*5;
And that line won't do anything either. The evaluation of the code will return the value he's looking for, I imagine, but it's not being assigned to anything so that value will never actually go anywhere.
@ATT_Turan
Sorry for the double reply, i was trying to contact you first.
What i want to do is (exemple) each stats should have a random roll but not the same min and max range.
ATK Random Roll -5 to 5
DEF Random Roll -6 to 4
And that line won't do anything either. The evaluation of the code will return the value he's looking for, I imagine, but it's not being assigned to anything so that value will never actually go anywhere.
LOL! I've been working overtime all week and barely slept, pretty much every post I wrote today is wrong. SO...
Code:
item.params[3]=Math.random()*5;

This is what I get for trying to hobby instead of sleeping.

@ATT_Turan
Sorry for the double reply, i was trying to contact you first.
What i want to do is (exemple) each stats should have a random roll but not the same min and max range.
ATK Random Roll -5 to 5
DEF Random Roll -6 to 4

So you need to do that. params[] is an array of parameters from 0-7, in the order you see in the Classes tab of your database. If they're going to have different min/max ranges, you need to set them each individually. The line I wrote above is a correct example of how to set a parameter.

The formula to use random() with a minimum and maximum value is:
Code:
Math.random() * (max - min) + min;
Note that the "max" value is exclusive, so you make that number one higher than you want to possibly receive.
For -5 to 5, you can do Math.randomInt(11) - 5. For -6 to 4 it'd be Math.randomInt(11) - 6.
Nice, I don't think I knew about that function.
You guys are legends! thank you so much.
here a Buffed Mushroom Reward for your help.

Original thread: https://forums.rpgmakerweb.com/threads/item-core-yanfly-script-question.137328/