Skill Learned; Variable Modified [SOLVED]

Is it possible to modify a variable when Skill X is learned?

Solved;

var vally = $gameVariables.value(x) + y;
$gameVariables.setValue(x, vally);


x = variable
y = number
Yes. At least in RM2k3 it's possible, but I'm not sure how to do it on MV.

You use conditional branches to check if the Skill X was learned, then set the variable to the value you want.
there is an (currently untested and not yet published) plugin that can do that and a lot more. I plan to publish it after it has been tested, but that might take another month or two given current free time (none)...
Oh that sucks, so is there no other way around to do what I want to?
Other than Events and the plugin @Andar suggested, I don't know. =(
The easiest way to do this is very tedious.
Make 2 switches, one called parrllel and the other called check.
Make a common event, make it a parllel process.
In the event make a conditional branch checking if an actor has learned that skill.
Inside that branch make a conditinal branch that checks if switch check is off.
Inside that branch modify your variable, and turn the switch on.
Repeat this process over and over for different skills or actors, just use a new switch for the check switch each time.



Other ways this can be achieve inculde using Yanfly's Auto Passive States to run a javascript code that will check if an actor has learned a skill and you can modify the variable.
Sounds interesting, anyone knows how to write in Java?
If actor learn skill X
Variable(y) +z
Sounds interesting, anyone knows how to write in Java?
If actor learn skill X
Variable(y) +z
if ($dataActors.actor (x).skills().contains($dataSkills[n]))){
var vally = $gameVariables.value(y) + z;
$gameVariable.setValue(y,vally);
}

Where x = actor id, n=skills data, y= varia b le id, and z is the amount you want to change it.

Note you're going to need more code to get it where this is for any actir learning any skill.
I just now the code to check it and change the variable but not how to set it up so that it does keep doing this repeatedly. I really recommend doing it with a parllel process common event. It's easy to keep track of and easy to debug.


A good compromise(I'm assuming you're giving players skills as they level), if you're not for eventing or going full blown out javascript, would be if you use Yanfly Skill Learn System, and run this code in the lunatic mode of custom cost excution:
var vally = $gameVariables.value(y) + z;
$gameVariable.setValue(y,vally);

Make it where the skill is free, (you can make it visible or not, if there at the right level), and if they can see it make it where it requires the player to be at a specfic level. And then when the player gets the skill, the variable increase.
Lucky, I`m using Skill Learn System from Yanfly.
So i did what you said but I get this error;

ReferenceError: $gameVariable is not defined {stack: (...), message: "$gameVariable is not defined"}

Here`s the code in the skill notebox;

<Learn Cost Eval>
var vally = $gameVariables.value(54) + 1;
$gameVariable.setValue(54, vally);
</Learn Cost Eval>

Edit #1;

I edited the line to this;

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

I got it to work whoever, if i create another skill with the same code I get stuck with + 1.
So this means the code line is to set the variable to 1 and not add 1.
Try this:
var vally = $gameVariables.value(54) + 1;
$gameVariables.setValue(54, vally);
my $gameVariables was written as $gameVariable.
It works!
I`ll stick on the thread head so if anybody ever run into the same problem, they can check the first post.

Thanks a lot dude.

Original thread: https://forums.rpgmakerweb.com/threads/skill-learned-variable-modified-solved.77518/