Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Saving Pre-title-screen variable's value and use it later in the game

Axel

Villager
Xy$
0.00
Hey guys, as I say un the title, I wanna know how could I do to set a variable with a value before the title screen and then use it after the start of a new game or after loading a previous one.

For example the variable 001: Apples save it with the value 4 before the title screen and be able to call that variable after the title screen and find that it's value still is 4.... What happens is that in the title screen it resets the values so, even if I save the variable eith any value before the title screen, afeter the title screen its values becomes 0.

Thaks for your help
 

LTN Games

Master Mind
Resource Team
Xy$
0.01
Thats because the game does not load all variables until you either start a new game or load a game. As soon as you start a new game it loads a fresh slate and when you load a game it loads all variables in the save file. You could create a JS global variable and then as the game starts have an event which assigns the global variable to an in game variable.
JavaScript:
// Global JS Variable...  the '$' is not important just an identifier to let the scripter know it's global. Put in a plugin, ideally in an IIFE.
var $apples = 5;

//Then when the game starts use an event and put this
$gameVariables.setValue(1, $apples)
This is just one way of doing it. How are you assingnig the in-game variable anyways? if you explain a bit more of what you're trying to accomplish I may be able to help more.
 

Axel

Villager
Xy$
0.00
I want to choose a language and then reproduce a sequence, all this before the title screen and I want to safe the value of the variable that assigns the language to the game without re-choosing the language. I tried to use pre-title events plugin but when the sequence finishes and the game goes to the custom title screen it starts all over again. To fix this I tried using variables, switches and other events, but the only solution I have found is to send directly to the title screen instead of the custom one. But here I have to re-choose language when I start a new game. Could you help me @LTN Games , please?
[doublepost=1469110268,1468871899][/doublepost]@LTN Games Hey, I'm not very experienced creating plugins so... could you tell me if this is okay and if it will do what I need it to do??:

JavaScript:
/*:
* @plugindesc A little plugin that allows you to choose the language
* of the game in a pre-title event
*
* @param Language
* @desc Which map to show for pre-title processing
* @default 1
*
* @author AXL
*
* @help This plugin just allows to save the variable that will activate the
* language switch before and after the title screen. This DOES NOT change the
* game's or it's texts' language.
*
* You can set the language throw here or inside an event using this numbers
* 1 = English
* 2 = Spanish
* 3 = German
* 4 = French
*
* In an event choose script and write:
*
* $gameVariables.setValue(a, $lang);
*
* changing "a" with the number of the language.
*/
     var $lang = lang;

(funtion(){

    parameters = PluginManager.parameters('AXL_PreTitleLangSaver');
      lang = Number(parameters['Language']) || 1;
})();

Please tell me what's wrong?? and, if something's missing, what's missing??
 

LTN Games

Master Mind
Resource Team
Xy$
0.01
What you have already will work but it gets a bit confusing when you use a parameter, you don't need a parameter at all, all you literally need is the one variable in your plugin, because it's being used to pass a value to your in-game variable.

So your plugin only needs something like this var $language = 0;

Assuming you're using an evented title screen, or the pre-title events by himeworks, then I'm going to assume you're using basic Message with choices. In this case, as soon as the user selects the language is when you assign the choice made, to the JS variable so choice 1, you will make a script call to set the variable you made in your plugin to it. Like this example.
Screenshot_1.png

Then when the game finally starts, you have another event which will take the value of $language and pass it into an in-game variable. You can use control variable or script call like you said.
Screenshot_2.png
Sorry, I been feeling pretty sick yesterday and all today so my brain is not quite functioning properly, and I can't really think straight, took a lot out of me too write this lol. If you have any issues, give me a day to get feeling better and I'll help you some more, hopefully this time I'll be able to think better.
 
Top