JS: How to overwrite/ check lines of a JS script in MV

Recently I realized that variables and switches are for the most part of my game not very efficient.
I use them for the gameplay features and they work just fine.
BUT:
My story is a decision driven one. So every answer the player gives in a dialogue changes one or several variables in the story on how other characters see the player and how things in the world develop.
Literally hundreds of different true/false states or integer values.
To do this in the engine with switches and variables would be a confusing nightmare in the long run.



So I want to create a JS that simply lists all the values, something like this:
Gamevalues.js
[AFFINITY]
AffinityVlad = 5
[...]
[KNOWLEDGE]
KnowsHyuuga = FALSE
[...]

And ingame I want to check and modify it (with a script call or whatever).
Just an example:
The player talks to the character "Vlad". The current affinity level is checked and a text with choices is shown depending on the value. Depending on the choice the value gets overwritten.

Basically like this, but I don't know the correct way to check/overwrite specific lines in a JS-file
◆If
_◆"Gamevalues.js": "AffinityVlad" = 5
_◆Text:
_ : ____ : Will you help me?
_◆Show Choices: Yes, No
_ : When Yes
__ ◆ set "Gamevalues.js":" AffinityVlad" = +1
_ : When No
__ ◆ set "Gamevalues.js": "AffinityVlad" = -1

So I need help with the correct way for changing an integer value by add/subtract or changing true/false values from inside RPG Maker MV.
JavaScript:
// For Internal Use Only
this.yourVariable1 += 1
this.yourVariable2 -= 3

If you wanna use script calls, then you could create new functions for Game_Actor.

JavaScript:
let actor = $gameActors.value(ActorId)
// OR
let actor = $dataActors.value(ActorId)
// This should always work after defining the corresponding functions.
actor.yourNewFunction1(1)
actor.yourNewFunction2(-3)
So, if I understand you correctly, it would look like this:
(if I name the JS-File "Gamevalues.js" like above)

to check the current value:
◆If: Script: Gamevalues.AffinityVlad = 5

to change the value from 5 to 6:
◆Script: Gamevalues.AffinityVlad += 1
or to change a value from FALSE to TRUE:
◆Script: Gamevalues.KnowsHyuuga = TRUE

-> I probably get something wrong here. And do these changes overwrite the value in the "Gamevalues.js" file? (sry, still quite a noob to js since I barely need it in most parts of my game ^^")
Nope, you'll still need to save that data. The easiest way to do this is to make them dependable on an existing game object, like Game_Actor or Game_Party or Game_System, etc. by creating them as one of its local variables, i.e. (this.affinityVlad = 0 at the creation of that object in its initialize function IIRC.)
There are times when using code is more efficient than event commands, but I don't see the benefit to what you're describing here.

You're not talking about doing anything you can't do with MV's built in variables, so why not use them? The only thing you're doing is making up a naming scheme, but you can assign names to the game variables.

And if you have a hard time keeping track of those for some reason, you can keep an Excel sheet of which variable has which ID.

But it just doesn't seem like you're gaining anything by trying to code this (particularly when you don't know how, and you'd have to either spend time learning or money to commission it).

Maybe I'm missing something.
This is probably wild, but why not start using game variables to save game objects/JSON objects?
Disclaimer: I don't remember the JS script call, but probably something like this
Code:
$gameVariables.setValue(1, {"AffinityVlad": 5, "OtherVariable": 10})
Then you can use it like
Code:
$gameVariables.value(1).AffinityVlad += 1
The catch is, you need to initialize it at the start of the game.
It's just easier for me to handle a single text file with everything listed where I can see all the variables and switches with their value directly.

But honestly, I expected it to be way easier. ^^"

Until now I managed all the stuff with my VERY limited JS knowledge quite well. And even the complex problems when I needed help were in the end often just a very simple command that I was able to understand and to modify.

But in this case it really seems easier to handle it with variables in the engine. And to make the variables with "true/false" states simply to variables with integer values too.
It can be way easier. Because I don't have MV/MZ installed on my current machine, I can't test it. But the idea can be like this. (Spoiler alert: it is a plugin)
JavaScript:
var GameValueVariableID = 1 // Change ID here
function initGameValues() {
   $gameVariables.setValue(GameValueVariableID, {
      "AffinityVlad": 5,
      "OtherVariable": 10
  })
}

function GameValues() {
  return $gameVariables.value(GameValueVariableID)
}
Register it as a new plugin.

What you need to do is to call initGameValues at the very beginning of the game.
Then onward, you can use script calls like
JavaScript:
GameValues().AffinityVlad += 5
@TheoAllen I think the salient part is the OP was looking for some way to manage this from an external file, which is not easily done.

Any changes to custom properties like that would be saved in the MV save file, which is not human-readable.

You'd have to code an entire process that writes these values to (and reads them back from) a readable text file.
@ATT_Turan The OP mentioned changing the value mid-game while also mentioning managing it from an external file. Being a plugin is an external file by itself. Being saved allows you to change it mid-game.

Unless they mean to export these values to an external file.
@ATT_Turan The OP mentioned changing the value mid-game while also mentioning managing it from an external file. Being a plugin is an external file by itself. Being saved allows you to change it mid-game.

Unless they mean to export these values to an external file.
That's my understanding:
It's just easier for me to handle a single text file with everything listed where I can see all the variables and switches with their value directly.

There's no way to have a text file that shows the current values of all variables and switches unless you write your own code to create and export to such a file.

I personally think it's easier to use the regular game variable/switches and check them in the F9 debug console.

But maybe I'm misunderstanding, I don't mean to interfere with you helping.
In that case, checking the value can be easier by just typing and executing GameValues() in the F12 console instead of using F9. It will print the entire variables.

Original thread: https://forums.rpgmakerweb.com/threads/js-how-to-overwrite-check-lines-of-a-js-script-in-mv.165757/