How to add a variable with Yanfly Skill Core Lunatic Mode?

Hello,


I tried to add value of a variable +1 for every actor who cast a skill.


So I try to use this notetag code on Yanfly Skill Core


<Custom Execution>


$gameVariables.setValue(1, +1);


</Custom Execution>


The problem is, it's look like my variable still stack at 1 value and never increase to 2, 3, 4, 5,... each he cast a skill.


How can I add a value each time he cast a skill with this lunatic mode notetag?


Thanks verymuch.
That won't work.


To add 1 to the value of your $gameVariables, use this


var variableValue = $gameVariables.value(1); // get the current value with that
$gameVariables.setValue(1, variableValue + 1); // and here add 1 to the value


or the shorter version

Code:
$gameVariables.setValue(1, $gameVariables.value(1) + 1);
That won't work.


To add 1 to the value of your $gameVariables, use this



var variableValue = $gameVariables.value(1); // get the current value with that
$gameVariables.setValue(1, variableValue + 1); // and here add 1 to the value


or the shorter version



$gameVariables.setValue(1, $gameVariables.value(1) + 1);



Wow it's work, so that's how the script call work.


Thanks very much.


Last Question. Is that possible with this cript call we do a random variable value?


Like set variable random to 1-100?
Last Question. Is that possible with this cript call we do a random variable value?


Like set variable random to 1-100?



There is a way to produce random numbers. For a number between 1 and 100, you can use this:


var randomValue = Math.floor(Math.random()*100) + 1;


Math.random() gets you a number between 0 (inclusive) and 1 (exclusive).


This value gets multiplied by the max value you want to have.


Math.floor() rounds that number to the nearest integer less than or equal to the given number.


At the end, it will be counted up by 1. This is necessary to avoid 0 and to get your max value (100).


A few sample calculations how it works. I'll use numbers with 4 decimals for this.


The numbers you can get with Math.random() can have more or less decimals.


1. for the highest number


var randomValue = Math.floor(0.9999 * 100) + 1;
var randomValue = Math.floor(99.99) + 1;
var randomValue = 99 + 1;
var randomValue = 100;


2. for the lowest number


var randomValue = Math.floor(0.0021 * 100) + 1;
var randomValue = Math.floor(0.21) + 1;
var randomValue = 0 + 1;
var randomValue = 1;




3. for any number in between

Code:
var randomValue = Math.floor(0.1349 * 100) + 1;
var randomValue = Math.floor(13.49) + 1;
var randomValue = 13 + 1;
var randomValue = 14;
Thankyou very much, Now I will try to learn this one. I want to implement this one for a random effect a casted skills. I can't wait for study more about script call on this plugin.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-add-a-variable-with-yanfly-skill-core-lunatic-mode.55804/