This won't work because
test only exists within the function, so as soon as you exit the function, the variable is gone.
Instead you need a global variable, like this:
Code:
function go() {
test = "message";
}
By not writing "var" in front, the variable becomes global.
Or better yet, since other plugins might also need a global
test variable, do this:
Code:
MyPlugin = {};
function go() {
MyPlugin.test = "message";
}
"MyPlugin" here is intended as a namespace. It's basically a name that you're certain no other plugin will use, so no other plugin will overwrite it.
In your case, you can use "Flicker789" instead of "MyPlugin". If you intend to share variables between your plugins, you can also do this:
Code:
Flicker789 = Flicker789 || {}; // makes sure you don't overwrite it if it already exists
Flicker789.MyAwesomePluginName = {};
function go() {
Flicker789.MyAwesomePluginName.test = "message";
}
You get the idea.
Next, in order to show the variable's value in a message window, you need to put the variable's value into an RMMV variable.
Use "Control Variables" -> "Set" -> "Script" -> "test" or "MyPlugin.test" (without the quote marks).
In the message window, you'd write:
Code:
Hello \v[1] how are you today?
Assuming you stored
test into variable 1.
The easiest way to deal with this, however, is to reserve a variable for your plugin to use, then write directly into that variable:
Code:
function go() {
$gameVariables[1] = "message";
}
This writes "message" into variable 1, which you can then access with
\v[1].