So, I have this plugin I'm working on.
The problem is that it constantly executes it's code. What I want it to do is execute the code any time the player interacts with an event.
while(true) {
$gameVariables.setValue(Skurry.Param.LVID, $gameParty.leader().actorId())
}
How can I change this so that it will only run when an event is called?
There's a few ways to do that. Either define a new function in the Game_Interpreter, which will allow you to call it using the "script" command in an event, or alias the pluginCommand function in the Game_Interpreter, and then you can call it using the Plugin Command event command. Creating a new function is probably going to be easier, but a Plugin Command might be better for a future maker, we can't really say for sure.
However I'm also concerned about your code snippet itself.... why are you using an infinite loop, which you never even explicitly break out of, to set a variable value...? You could just have it set the value once and avoid looping at all...
Ok, yes, it'll constantly set the value. And nothing else will run. That loop will halt the game until it's done running, which happens to be never.
But now I'm confused. You want the variable to always be set to the party leader's ID, but you want it to only get set when you call the function in an event? That's a contradiction, they're opposites.
Well, I'd recommend making a function in the Game_Interpreter and calling it from a "Script..." command in the events you want it to work with. A plugin command is a little more annoying to implement, but if you're up for the challenge, go for it. It's probably debatable whether or not one method is better than the other, but it'll be quicker and easier to just add and call a function.