Here's a very simple framework for you:
Code:
//=============================================================================
// cy_VarSetter.js
//=============================================================================
/*:
*
* @plugindesc Sets variables or something
* @author cyanic
*
* @param firstVar
* @text First Variable
* @desc The first variable to set
* @type variable
*
*/
var Imported = Imported || {};
(function() {
var pluginName = "cy_VarSetter";
Imported[pluginName] = 1;
// Load parameters
var sysParams = PluginManager.parameters(pluginName);
var pluginParams = {
"firstVar": Number(sysParams["firstVar"] || 0)
};
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
if (command.toLowerCase() === "setvars") {
setVars();
}
};
function setVars() {
if (pluginParams.firstVar) {
$gameVariables.setValue(pluginParams.firstVar, $gameActors.actor(1).hp);
}
}
})();
Change your plugin settings to something meaningful. In the pluginCommand() function, you can see that it listens for "setvars" as the command, and the actual work happens in the setVars() function. To use, add the script into your plugin manager, set the variable, then when you need the values, do a plugin command for "setvars", and you can access the variables after that.
Well, I tested it but I don't really understand the command use.
It would be easier to simply set variables values that are always true, without a command.
A list like this for exemple :
$gameVariables.setValue(1, $gameActors.actor(1).hp);
$gameVariables.setValue(2, $gameActors.actor(1).atk);
$gameVariables.setValue(3, $gameActors.actor(2).mp);
$gameVariables.setValue(4, $gameActors.actor(3).def);
That would be perfectly fine.
EDIT : There is another problem : there is no auto-update of the value.
I'm using variables for damages values in skills descriptions.
For exemple, for skill n°1, it's "Deals \v[1] damages to the target", where \v[1] equals the damage formula, let's say actor 1 atk x 2.
If actor 1 is increasing his atk with a better weapon, then the variable value will not update. I need something that will update at any time.
I had a RGSS3 script for that (VX ACE), if it can help :
Code:
class Window_SkillList < Window_Selectable
def update_help
if item
if item.damage.none? != 0 then
$game_variables[1] = (item.damage.eval(@actor, @actor, $game_variables).to_i).abs
$game_variables[2] = $game_actors[4].mat * 4
$game_variables[3] = $game_actors[2].atk * 5
end
end
@help_window.set_item(item)
end
end