Global Variables(?)

Status
Not open for further replies.

AcousticJamm

YouTuber
Veteran
Joined
Jun 1, 2019
Messages
166
Reaction score
7
First Language
English
Primarily Uses
RMMV
I want to be able to access global variables - variables that are across the whole game - in order to skip certain intros. What I mean is that the player sat through an intro to a boss fight. If they die, why should they be forced to watch it all again?

Or maybe I just want to count deaths like Sans does. I dunno. Here's what I mean by that comment.
"I mean, look at you, Ruki! You didn't die once! That's rather impressive!"
"I mean, look at you, Ruki! You're still in one piece! Well, despite that death."
"I mean, look at you, Ruki! Two deaths! I'd give that... Hmm... A B? B+?"
"I mean, counting your deaths, a B- is still a passing grade."

And so on.

So can someone help me like this?
 

MushroomCake28

KAMO Studio
Moderator
Joined
Nov 18, 2015
Messages
1,987
Reaction score
3,435
First Language
English
Primarily Uses
RMMV
I don't understand how you are trying to achieve what you're looking for with global variables. Skipping scenes and global variables are like different subjects.

But anyways, there are many accessible global variables:
Code:
// For everything related to game switches and variables.
$gameVariables;
$gameSwitches;
$gameVariables.setValue(id, value); // Sets the value of variable #id. Same method for switches
$gameVariables.value(id);           // Gets the value of variable #id. Same method for switches

// Global variable for party stuff
$gameParty;

// Global variable for actors stuff
$gameActors;
There are more global variables, but I don't think I have to list them all.
 

AcousticJamm

YouTuber
Veteran
Joined
Jun 1, 2019
Messages
166
Reaction score
7
First Language
English
Primarily Uses
RMMV
I don't understand how you are trying to achieve what you're looking for with global variables. Skipping scenes and global variables are like different subjects.

But anyways, there are many accessible global variables:
Code:
// For everything related to game switches and variables.
$gameVariables;
$gameSwitches;
$gameVariables.setValue(id, value); // Sets the value of variable #id. Same method for switches
$gameVariables.value(id);           // Gets the value of variable #id. Same method for switches

// Global variable for party stuff
$gameParty;

// Global variable for actors stuff
$gameActors;
There are more global variables, but I don't think I have to list them all.
Sorry IDK what it's called lol
You know those variables that get saved outside of the save but have to do with a single save? A good example would be Jevil. First time you (attempt to) fight him, you go through the full cutscene, then the rest, you go straight into the battle.
Edit: Not saving between attempts. Let's have these outside variables autosave upon edit.
 

MushroomCake28

KAMO Studio
Moderator
Joined
Nov 18, 2015
Messages
1,987
Reaction score
3,435
First Language
English
Primarily Uses
RMMV
There's nothing in the default engine that gets saved automatically and that is save file dependent (meaning unique within different save file). The only thing that is saved automatically is the option settings (variable is called ConfigManager ), but it is common across all save files.

EDIT: Meaning that to achieve what you're trying to achieve you'll need custom coding.
Also, even if you use the default ConfigManager to save stuff in it (which I do not recommend), there's still some coding to be done to make it work as ConfigManager wasn't design for that.
 

AcousticJamm

YouTuber
Veteran
Joined
Jun 1, 2019
Messages
166
Reaction score
7
First Language
English
Primarily Uses
RMMV
There's nothing in the default engine that gets saved automatically and that is save file dependent (meaning unique within different save file). The only thing that is saved automatically is the option settings (variable is called ConfigManager ), but it is common across all save files.
Is it possible to save in the save folder as a new file, then? Let's call this file "Newvar.sav".

Here are the steps I want to be able to do with the commands I want to make:
Open the file: openvar
Close the file: closevar
Write to the file: writevar (group, variable, value)
Read the file: readvar (group, variable)
Save the file: savevar
 

Uzuki

Kawaii on the streets, Senpai in the sheets
Veteran
Joined
Aug 18, 2012
Messages
1,884
Reaction score
1,275
First Language
English
Primarily Uses
RMMV
How are you handling game overs? You could set the battles to Cannot Lose when making the battle processing event. If they do you do a one frame count to tint the screen black, add +1 to a variable and transfer the player to another location. Or you could use Hime's Sync Save Data plugin to sync your saves and variables.
 

AcousticJamm

YouTuber
Veteran
Joined
Jun 1, 2019
Messages
166
Reaction score
7
First Language
English
Primarily Uses
RMMV
How are you handling game overs? You could set the battles to Cannot Lose when making the battle processing event. If they do you do a one frame count to tint the screen black, add +1 to a variable and transfer the player to another location. Or you could use Hime's Sync Save Data plugin to sync your saves and variables.
I am using the real game over screen.

So here's what I want to do.

Don't mind the commentary in this vid.
When you go to 4:40 of the vid, you can see that it is the full cutscene. However, at 14:42, you can see that the cutscene is shortened to actions, despite no progress being made, no saves, nothing.

Here is an example of the death counting:

As the attempts of this fight differ, so does the dialogue, counting up.

I want to be able to replicate these using those kinds of variables. All that the dialogue depends on is the number of times you've seen the scene without saving, or maybe a death count starting at a certain point. Think of it as an outside variable working on a specific file.
 

MushroomCake28

KAMO Studio
Moderator
Joined
Nov 18, 2015
Messages
1,987
Reaction score
3,435
First Language
English
Primarily Uses
RMMV
Is it possible to save in the save folder as a new file, then? Let's call this file "Newvar.sav".

Here are the steps I want to be able to do with the commands I want to make:
Open the file: openvar
Close the file: closevar
Write to the file: writevar (group, variable, value)
Read the file: readvar (group, variable)
Save the file: savevar
Yes you can do that, but since it's a new system that you're adding to your game you'll have to create the new objects to handle that. Plus, you'll need to create your auto-save system.

To create/write/read a save file, just refer to the DataManager and the StorageManager in the code. Both objects are pretty straightforward. Here's a list of methods that you can take inspiration from:
Code:
DataManager.loadGameWithoutRescu(savefileId);
DataManager.makeSavefileInfo();
DataManager.makeSaveContents();
DataManager.extractSaveContents(contents);

// More important stuff in the StorageManager object
StorageManager.save(savefileId, json);
StorageManager.load(savefileId);
StorageManager.saveToLocalFile(savefileId, json);
StorageManager.loadFromLocalFile(savefileId);
 

AcousticJamm

YouTuber
Veteran
Joined
Jun 1, 2019
Messages
166
Reaction score
7
First Language
English
Primarily Uses
RMMV
Yes you can do that, but since it's a new system that you're adding to your game you'll have to create the new objects to handle that. Plus, you'll need to create your auto-save system.

To create/write/read a save file, just refer to the DataManager and the StorageManager in the code. Both objects are pretty straightforward. Here's a list of methods that you can take inspiration from:
Code:
DataManager.loadGameWithoutRescu(savefileId);
DataManager.makeSavefileInfo();
DataManager.makeSaveContents();
DataManager.extractSaveContents(contents);

// More important stuff in the StorageManager object
StorageManager.save(savefileId, json);
StorageManager.load(savefileId);
StorageManager.saveToLocalFile(savefileId, json);
StorageManager.loadFromLocalFile(savefileId);
I'm not sure how exactly I can do that. I'm not sure if I exactly want the other save file. At the end of the day, I just want to be able to do what those 2 vids did. Newvar.sav was an idea of doing this.
 

Uzuki

Kawaii on the streets, Senpai in the sheets
Veteran
Joined
Aug 18, 2012
Messages
1,884
Reaction score
1,275
First Language
English
Primarily Uses
RMMV
Okay let's make this a bit simpler so you can handle it better. I couldn't find anything to do what you wanted on MV. Let's change up how game overs work with Hime's Gameover Events plugin. now when the player loses a losable battle, then they will be transported to a separate map that you can make a autorun event in which you can activate switches and variables from and then send the player back to a previous save point or even right before the boss fight. When the boss fight starts, activate a switch and when the player is transferred to your game over map you can have a conditional branch check if that boss switch is on and if it is then you +1 to a variable. Once the player gets back to that fight again, you can either have a separate page or use conditional branches from there.
 

AcousticJamm

YouTuber
Veteran
Joined
Jun 1, 2019
Messages
166
Reaction score
7
First Language
English
Primarily Uses
RMMV
Okay let's make this a bit simpler so you can handle it better. I couldn't find anything to do what you wanted on MV. Let's change up how game overs work with Hime's Gameover Events plugin. now when the player loses a losable battle, then they will be transported to a separate map that you can make a autorun event in which you can activate switches and variables from and then send the player back to a previous save point or even right before the boss fight. When the boss fight starts, activate a switch and when the player is transferred to your game over map you can have a conditional branch check if that boss switch is on and if it is then you +1 to a variable. Once the player gets back to that fight again, you can either have a separate page or use conditional branches from there.
So what I'm gathering is that it increases a certain variable per death? At that, why don't I make it increase the variable, send them to their last save spot, and force save? (Then again, how can I find their last save spot?)
 

Uzuki

Kawaii on the streets, Senpai in the sheets
Veteran
Joined
Aug 18, 2012
Messages
1,884
Reaction score
1,275
First Language
English
Primarily Uses
RMMV
You will create all that in a autorun event that you have in the game over map. As for getting save spots, use switches. I advise you just set aside a bunch of empty switch slots specifically for those save spots. Then when the player interacts with a save spot, turn off all the switches and turn on the switch for that spot.
 

AcousticJamm

YouTuber
Veteran
Joined
Jun 1, 2019
Messages
166
Reaction score
7
First Language
English
Primarily Uses
RMMV
You will create all that in a autorun event that you have in the game over map. As for getting save spots, use switches. I advise you just set aside a bunch of empty switch slots specifically for those save spots. Then when the player interacts with a save spot, turn off all the switches and turn on the switch for that spot.
Is it possible to use a variable instead? And how do I force the save onto the file?
 

Uzuki

Kawaii on the streets, Senpai in the sheets
Veteran
Joined
Aug 18, 2012
Messages
1,884
Reaction score
1,275
First Language
English
Primarily Uses
RMMV
Very possible. just be sure to remember what number you have for each save spot and have the proper conditional branches. As for the force saving I couldn't find anything about forcing a save on a certain file, so the only way I know how to do that is with an Autosave plugin.
 

AcousticJamm

YouTuber
Veteran
Joined
Jun 1, 2019
Messages
166
Reaction score
7
First Language
English
Primarily Uses
RMMV
Very possible. just be sure to remember what number you have for each save spot and have the proper conditional branches. As for the force saving I couldn't find anything about forcing a save on a certain file, so the only way I know how to do that is with an Autosave plugin.
Alright. However, I want the player to have only the level and EXP they had at their last save when the game over screen does what it does. Plus, I can't find an autosave plugin that doesn't just save on its own. I just want one that will allow me to force a save. Do you know any like that?
 

Uzuki

Kawaii on the streets, Senpai in the sheets
Veteran
Joined
Aug 18, 2012
Messages
1,884
Reaction score
1,275
First Language
English
Primarily Uses
RMMV
What you could do is at save spots have the game put the player's level and exp into variables and then when the game over event have the game set the players level and exp to those variables. What autosave plugins have you tried? Most of the ones that I know of allow you to customize when they save so you could completely turn off everything and just use plugin and script commands at your leisure.
 

AcousticJamm

YouTuber
Veteran
Joined
Jun 1, 2019
Messages
166
Reaction score
7
First Language
English
Primarily Uses
RMMV
What you could do is at save spots have the game put the player's level and exp into variables and then when the game over event have the game set the players level and exp to those variables. What autosave plugins have you tried? Most of the ones that I know of allow you to customize when they save so you could completely turn off everything and just use plugin and script commands at your leisure.
How exactly do you "set" a level and EXP? I know you can remove all levels and EXP, add the saved levels and EXP, subtract 1 from level, but I don't want to do all that. Such a hassle.

And could you recommend one or two?
 

Uzuki

Kawaii on the streets, Senpai in the sheets
Veteran
Joined
Aug 18, 2012
Messages
1,884
Reaction score
1,275
First Language
English
Primarily Uses
RMMV
Sadly game developing sometimes requires you doing hassling tasks and workarounds to do simple stuff. Especially if you don't know how to code. For Autosave plugins I usually use Yanfly's and then I found this one on itch.
 

AcousticJamm

YouTuber
Veteran
Joined
Jun 1, 2019
Messages
166
Reaction score
7
First Language
English
Primarily Uses
RMMV
Sadly game developing sometimes requires you doing hassling tasks and workarounds to do simple stuff. Especially if you don't know how to code. For Autosave plugins I usually use Yanfly's and then I found this one on itch.
So how exactly can I save the switches using variables? (I am using one switch for each story point and variables per background info)
And the problem with the autosave plugin on Itch is that it creates new autosave files (I want it to save directly into the file). I also have a problem with there being no command to autosave. As for Yanfly's, I don't have access to my money.
 
Last edited:

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
14,065
Reaction score
7,756
First Language
English
Primarily Uses
RMMV

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Oh, stop with the Melodrama...

...Listen to it instead!

anybody else like getting baked whilst coding?

When you go to the beach watch out for coconuts. Coconuts are more dangerous than sharks. Fact.
Try to get into pixelart again, so far its a sucess.
Also finally found a useful pixeltutorial which helps a lot.
♫ Anyone knows an ant can't move a rubber tree plant, but he's got high hopes, he's got high hopes, he's got high apple pie in the sky hopes ♫

Forum statistics

Threads
93,615
Messages
913,982
Members
123,180
Latest member
tdominach
Top