Best method to store game data?(might be math related)

heyo,

Im creating a game where you basically have to go around having interactions with different people and build friendships, and whatnot. And with that comes that I wish to track all kinds of stats about all the different individuals roaming around that you can interact with - for instance, how many times you made a joke to that person, what their current friendship level is, how many times you failed an interaction, etc, etc.
With my current knowhow - the only method i can think of to actually store all that data, is to create switches and variables specifically for each individual person; and with all that i wish to track, id have about a total of 40ish switches and variables distributed to each person available, and with approximately about 30-40 people, those variables/switches will take up alot of space.

Now ive also thought about something to try to store 4 switches in one variable to make each switch one of the four digits, for example:
if player has ever talked to said person + 100 = true. if player has ever hugged said person + 10 = true. etc. Which would make the variable 0110, which would basically tell me that both those "fake switches" are both true. So for that solution id also like to know if theres a good math solution to efficiently make the game realise that 1000, 100, 10 and 1 are all individual switches. Instead of me having to go through all the trouble of making conditional branches like these:
Code:
conditional branch:
if $gameVariable.value(24) === 1000 || if $gameVariable.value(24) === 1100 if $gameVariable.value(24) === 1010 if $gameVariable.value(24) === 1001 if $gameVariable.value(24) === 1110 etc etc
Switch 1 = on

So bottom line is: Im looking for a way to store alot of data, without having to make a ton of variables, and switches.
same premise, but take it to conversion between binary and hexadecimal.
you'll see the idea.
40 variables for 40 people isn't much memory. If I were you I would use yanfly's
http://yanfly.moe/2016/08/06/yep-113-self-switches-variables-rpg-maker-mv/
Well, If those characters aren't involved in combat, you could make their stats represent affection level, then you only need switches for conversation/storyline plots. for example. 100 attack = max affection and you would simply need to run a check for that stat for that actor to make sure its right. If they are involved in combat, you could maybe try to streamline it? Replace luck for instance with affection, and then, the higher their affection, the more they'll crit as per the games base luck mechanics in addition to it being a makeshift replacement for switches. Then players can view how high the stat is as well.
@gstv87 Hmm, but would there be a math solution to easily recognize which hex code is which option?
@winkr7 I mean its not about the memory - its just about how huge a chunk all those variables and switches would take in the variable and switch naviator; the navigator being so tiny and all. And that plugin is not exactly what im looking for i think.
@Darkfire1408 hmm ive thought about this myself too, before. but as far as i know, stats are just more limited variables, being able to go up to 999 only.

Anyway im just really curious if theres actually a way to make several switches out of one variable, this would save me time if theres actually a proper math solution to make a good distinction between those variable switches.
@gstv87 Hmm, but would there be a math solution to easily recognize which hex code is which option?

lay down the total variables you want evaluated..... say, 30.
you'd have something like (100101110011100110110100110011)
group by 4, starting from the lowest bit
(0010 0101 1100 1110 0110 1101 0011 0011)
turn that to hexa, that's only 8 characters: 2 5 C E 6 D 3 3

that is basic binary to hex.
look it up, it's easy to understand.
I think if you use code your life would be much more easier.

Say you want to register a Hug from Friend ID 2, you could use the line:
$gameFriends.get(2).addHug();

And save all the data in just one Variable any time with the code:
$gameFriends.save()

This its just an illustration, the code isn't working, but can be used as base for this feature:

Spoiler
Code:
   /*** The friend Class ***/
   function Friend() {
        this.initialize.apply(this, arguments);
    }

    Friend.prototype.initialize = function(newFriendID) {
       this.id = newFriendID;
       this.talkTimes = 0;
       this.hugTimes = 0;
       this.friendShipLevel = 0;
    };
   
   Friend.prototype.addHug= function(){
       this.hugTimes++;
   }
   
   /*** The static class for the friends list, save and load ***/
   $gameFriends = {}
   $gameFriends._data = [];
   
   $gameFriends.newFriend = function(friendID){
       this._data.push( new Friend(friendID));       
   }
   
   $gameFriends.get = function(friendID){
       return  this._data.filter(function(v) {
           return v.id === friendID;
       })[0];
   }
   
   $gameFriends.saveFriends = function(){
       $gameVariable.setValue(24,this._data);
   }
   
   $gameFriends.loadFriends = function(data){
       this._data = $gameVariable.value(24);
   }
@gstv87 Hmm, but would there be a math solution to easily recognize which hex code is which option?
@winkr7 I mean its not about the memory - its just about how huge a chunk all those variables and switches would take in the variable and switch naviator; the navigator being so tiny and all. And that plugin is not exactly what im looking for i think.
@Darkfire1408 hmm ive thought about this myself too, before. but as far as i know, stats are just more limited variables, being able to go up to 999 only.

Anyway im just really curious if theres actually a way to make several switches out of one variable, this would save me time if theres actually a proper math solution to make a good distinction between those variable switches.
Well, you said you wanted like 40 variables for 40 characters right? Say the largest affection increasing event you have (kiss, marriage, what have you) is worth 20 points. If every event was that high, you could go up to 49 events to total at 980 affection points. In addition, if they're not involved in combat and the stats are hidden, you could use any and every stat to measure, including HP and MP which can go over 1000, making your options virtually limitless. For instance, excluding MP, you could use HP for an overall affection, and have 6 different stats For different scenarios. So you could make attack measure how often you've spoken, defense how often you've hugged, magic attack how often you've kissed, etc. You could even, with some working, make a dialog box to state the level of the stats however you want to word it, inserting the appropriate value behind the new name.
Alright people, as of now, I kinda figure that i should up my math and programming knowledge first, before I am gonna make good use of all the information youve given me. ill check back later to see if I have any more questions. But as for now; I thank you all for your input!

Original thread: https://forums.rpgmakerweb.com/threads/best-method-to-store-game-data-might-be-math-related.85129/