[SOLVED] Just general Questions about "storing information"

I'm still quite new to events, switches, and the scripting in MV in general, so I'm still not sure about some stuff.

The most important for me:
- is it possible to "store" an information like "the player gave answer B in the dialogue" or "the player found item xy"?

It has to be storable for the whole game. So if you move to another map, or if you save and close the game and load it again, the information has still to be there. Because I'm making a decision based RPG where near the end even decisions from the beginning have impact, I need to use basically something like
if PlayersFirstChoiceFromTwoDaysAgo=2 and CompanionAffinity≥50, then [...]
else [...]
(companion affinity would be a variable that gets higher or lower with specific actions)
Yes, you could basically declare one of the control variables as an empty array at game start. Then every time the player made a choice, push their answer into that array.

It would look like this at game start:
Control Variables: #777 = [];

Then at the end of the game it would look something like
Control Variables: #777 = ['yes', 'no', '3', '1', 'yes', '1', 'no'];

The challenge would be keeping track of which value out of that array you want to fetch when the time comes to evaluate the data.
Storing an array in a variable is possible, but it requires a rather complex construct to get specific data points out of it.

Much easier is the option to assign a different switch or variable to each choice and store the result directly. This has the disadvantage that you'll need a lot of switches, but the enormous advantage that the engine can react to each decision directly by event page conditions.

So it depends on how big your decision tree is going to get - but considering the amount of work for each branch this should still be far below the maximum number of available switches and variables.

and yes, those are always stored per game - only the self-switches are stored per event, and even they are remembered for every event on every map at the same time.
So everything that @AquaEcho is absolutely right, but I feel like the whole array and getting into scripting is overkill for your question.

You have hundreds of game variables and switches available. Unless you have a game of boggling complexity that I've never seen from a full professional studio, you won't use up all of those storing significant answers. Just name variables/switches to a choice each and store the value indicating what the character answered.

Edit: what Andar said.
In addition to the other two suggestions, you could use an object instead of an array and have each key be what decision it is, so

Control variables #x = {};

When you want to add something to it you'd do $gameVariables.value(x).decisionKey = "string here";

Then when you want to retrieve or check it, you'd look at $gameVariables.value(x).decisionKey

You can also do $gameVariables.value(x)["decision key"] if you want keys with spaces in them.
Given that you're very new to this, I'm concerned that the variety of answers you're getting might confuse you. While nothing that anybody here said is incorrect, I feel that using either arrays or objects would be very excessive (considering the examples that you gave of what you're looking to do).

As Andar and ATT_Turan stated, Variables and Switches exist for the exact purpose that you're describing. Variables are ideal for holding number values, and Switches are ideal for holding boolean (true/false) values. You technically can store any type of value you want in a Variable, but the editor assumes that they contain numbers, so you will generally have to jump through some additional hoops to make use of variables that contain non-numerical values.

Unless you're running out of available variables and switches to use, I don't really see a good reason to pack a bunch of unrelated data together into an array or object, and doing so would stop you from being able to use those values in page conditions. There are certainly situations where it can make sense to use arrays and objects, but the things that you're talking about wanting to do aren't really included among those situations.
Given that you're very new to this, I'm concerned that the variety of answers you're getting might confuse you. While nothing that anybody here said is incorrect, I feel that using either arrays or objects would be very excessive (considering the examples that you gave of what you're looking to do).

As Andar and ATT_Turan stated, Variables and Switches exist for the exact purpose that you're describing. Variables are ideal for holding number values, and Switches are ideal for holding boolean (true/false) values. You technically can store any type of value you want in a Variable, but the editor assumes that they contain numbers, so you will generally have to jump through some additional hoops to make use of variables that contain non-numerical values.

Unless you're running out of available variables and switches to use, I don't really see a good reason to pack a bunch of unrelated data together into an array or object, and doing so would stop you from being able to use those values in page conditions. There are certainly situations where it can make sense to use arrays and objects, but the things that you're talking about wanting to do aren't really included among those situations.
To clarify, I admittedly didn't fully parse the OP and was basing my answer off of AquaEcho having included strings in the array.
So basically the value of a variable is saved for the whole game?

For example:
At the start of the game I choose answer 3 in a dialogue - and the variable for this dialogue is set to 3.
The variable keeps the value of 3 for the whole game (as long as I don't change it myself)?
So basically the value of a variable is saved for the whole game?

For example:
At the start of the game I choose answer 3 in a dialogue - and the variable for this dialogue is set to 3.
The variable keeps the value of 3 for the whole game (as long as I don't change it myself)?
That is correct (well, as long as the player remembers to save the game).
Thanks. Then this is for most of it the best solution.
Because for most choices there are 4-5 different answers that affect the story or how much a NPC likes/dislikes you, so a switch (with only on/off) would be not enough.(I thought the variables would be set to the default value everytime you start the game^^)
The other stuff can be done with an array.

Thank you all for the fast replies 🙂

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.

Original thread: https://forums.rpgmakerweb.com/threads/solved-just-general-questions-about-storing-information.156876/