Global Switches and Variables - For Rpg Maker MZ
A downloadable Rpg Maker MZ Plugin
GENERAL
This is an utility plugin for Rpg Maker MZ that add a new feature to the default Switches and Variables. For real, it adds a whole new category of game data/s called Global Switches and Global Variables. This data is stored outside your savefile and it's useful for handling data that should be common to all the game despite the save data.
FEATURES
- You can declare Global Switches and Global Variables into plugin parameters. We'll see below their format.
- In particular, Global Switches works the same of the in-game default switches. You can set the value as true or false;
- Global Variables, as default, are intended to be used for numeric values. However, the plugin allows you to set a script that is interpreted each time the variable is called for their value. This is really useful for making complex systems if you know what you're doing.
- You can set the global switches and variables declared in the plugin parameters through plugin command directly from your events.
- The global switches and variable could be stored into their own saved file. You can decide if the changes to certain variables or switches could be saved if they're changed into the game directly inside plugin settings.
PLUGIN PARAMETERS - GLOBAL SV SETTINGS
Now, let's see how global switches and variables work. Most (well, all actually) the setup is done into plugin parameters. Indeed, opening plugin settings you'll find two macro-parameters:
Those are the lists of Global Switches and Variables. Now, let's examine the structure of both.
- NAME -> This is the name of the Switch. WARNING! The name is case sensitive.
- VALUE -> This is the value of the switch. It can be true or false;
- SAVABLE? -> This parameter determines if the switch is saved or not when edited through plugin command/script call in-game. The value is saved into a file called globalsv inside your save folder. This file is parsed when the game is loaded with the Switches/Variables that has the "savable?" parameter set to true.
- NAME -> The same of the Global Switches;
- NUMERIC VALUE -> You can set an integer value to the variable;
- SCRIPT VALUE -> You can set a script that is interpreted each time you call for the variable for parsing the value. WARNING! The SCRIPT VALUE goes over the NUMERIC VALUE. So, if the variable setting has both, SCRIPT VALUE will always prevail. Leave this void for not using it.
- SAVABLE -> The same explained above for Global Variables.
PLUGIN COMMANDS
Outside of the setup you can do using plugin parameters, for an enhanced experience you can change the values of Global Switches and Variables through plugin commands.
The structure of the plugin commands is mirroring the one inside the plugin parameters. When the plugin command is executed, if the switch or variable setup in the parameters contains the Savable? property set as TRUE the change will be saved inside the globalsv.rmmzsave file. If not, the change will have effect until the game is restarted again.
ADVANCED
Are you a JS guru or a new adept? Well, I just have some info for ya. As you probably know, inside Rpg Maker you have $gameSwitches and $gameVariables as global variables for accessing in-game switches and variables.
Global SV have something similar, but in the format of static classes. Specifically, you have two classes called Global_Switches and Global_Variables containing methods that are usually executed through plugin commands.
// Now, I'm going to show you the methods for each class. // Global_Switches Global_Switches.value(name) // Get the value of a global switch. Global_Switches.setValue(name, value) // Set the value of a global switch // Examples: Global_Switches.value("DEBUG") Global_Switches.setValue("DEBUG", false) // If the global switch does not exist, you'll get an alert error. // Global_Variables Global_Variables.value(name) // Get a global variable value. Remember that the value could be an int or an executed script. Script prevail; Global_Variables.setNumericValue(name, number) // Set a numeric value; Global_Variables.setScriptValue(name, eval) // Set a script value in the format of a string that will be put into an eval; // Examples Global_Variables.value("VERSION") Global_Variables.setNumericValue("VERSION", 2) Global_Variables.setScriptValue("PCUSERNAME", "process.env.USERNAME") // If the global variable does not exist, you'll get an alert error;
PLUGIN COMPATIBILITY:
This plugin should be compatible with VisuStella's core's plugins and It should not give problems with other plugins if they do not affect intensively default RPG MAKER MZ library.
RPG MAKER VERSION:
The plugin is developed on Rpg Maker MZ - Version 1.4.4 and with the related PIXI.js Version 5.2.4.
TERMS OF USE:
- Credits to BlueMoon.
- Avoid to change plugin information, filename and parameters name for the sake of integrity of the code.
- Edits to the code are allowed.
- The plugin can be used for both commercial and non-commercial projects.
- You can't redistribute this plugin as it is or incorporating portion of the code inside another plugin;
Status | Released |
Category | Tool |
Author | BlueMoon (Nebula Games) |
Tags | 2D, addon, asset, mz, RPG Maker, rpgmakermv, RPG Maker MZ, tool |
Purchase
In order to download this Rpg Maker MZ Plugin you must purchase it at or above the minimum price of $3.99 USD. You will get access to the following files:
Comments
Log in with itch.io to leave a comment.
how do you make an conditional branch that checks if a global variable is a certain number or higher?
How do you do an event that just does +1 in a variable ?
With the plugin command ?
Been a while since you posted this, and thank you, but is there any way to do a conditional branch with the global variables or switches?
As in, plugin command turns global switch on. NPC in game reacts differently based on whether global switch is on, regardless if same save or not.
Thanks!
If I wanted 2 global switches to be saved once you quit the game, would I set
say I set switch 9 named "Nine"
and switch ten as "Ten"
Would the name be Nine and Ten for the name and not the #s 9 or 10?
and the value true, and save as true?
I tried all versions anyways and also setting them to true, or false, or true and false, nothing seems to work. It doesn't seem to save for some reason. But I don't quite know what I'm doing wrong xD <3 any help is mega appreciated! Thanks dude. No rush if ur busy!
Hey there!
Sorry for the late reply, but I got mega-busy recently.
So, If I have understood correctly your question... Yes. Global Switches and Variables are indexed by the name you assign them into the configuration and not by their "id". Moreover, for making them interactive with the changes you do in game, the property "SAVABLE" must be set to true.
This mean that if you create a Global Switch named "FOO" and set the property "SAVABLE" to true and maybe edit them in game through one of the methods (plugin command or script call) the edit you do will be saved and accessible with the new value you assigned when you re-open again the game.
However, if you have a more specific issue that I have not satisfied with my answer, feel free to let me know :)
Never be sorry for living life dude! Thank you, I appreciate it!