Y the heck does this code crash my plugin? I've tried so many things and checked my work over 10 times!!!
What is the larger function that this is inside of? Just putting this into a js file that you install as a plugin is going to make it try to run when you start up the program, and there are no gameVariables until you actually get past the title screen into the game. This needs to be encapsulated inside of a function (getCharm, etc.) that you then call at a specific time from inside your game to get that value. That could be causing your crash.
JavaScript:if ($gameVariables.value(1) <= 60) {
charmNo = 0;
} else if ($gameVariables.value(1) > 60 && $gameVariables.value(1) <= 120) {
Just to point it out, this (and the
entire rest of your code where you do the same thing) is wasteful. Logically, if you have gotten past your first "if" to be seeing this "else," the value
must be higher than 60, so there's no point in checking that again - you only care now whether it's <= 120.
Yes, the effect on your CPU is negligible, but it's still wasted work, and wasted typing on your part.
Code:} else if ($gameVariables.value(1) >= 300) {
Same thing here, by the time you get this far the value
has to be >= 300, so why bother calling the function? Just say "else".
Finally, if/else statements automatically apply to the one following command, so if you only have one command inside of each one, there's no reason for you to bother typing braces around it.
There's something funny to say about misspelling "intelligence"
:wink: