Using an variable as an Game Variable Index

I have a rather advanced problem up ahead that I need an answer to up front.

I'm about to store a set of variables that should be accessed by an index variable. What I need to do is to calculate which variable I want to access. Like this:

Index = 30 + (5 * Variable A) + (Variable 😎

And then have something like this:

X = $gameVariables.value(Index)

I can easily do the index computation in the game, but what is the proper way to get the second part in MV.

Thanks in advance.
If I understand you correctly, you want to know how to access a specific value in an array via script call.

$gameVariables.value(variableID)[index]

Example:

$gameVariables.value(3)[5]
Actually, I wanted to make a formula for X and have X replace VariableID
Oh my, I'm sorry!

In this case, depending on how you want to use this, you could put the formula directly in the variable ID spot, like with a script call:
$gameVariables.value(30 + (5 * $gameVariables.value(A)) + $gameVariables.value(B ));

You can also use a second variable and the Event Editor. Choose the variable to hold the result of your formula, then tick the box by Script and type your formula in there. Just like this: 30 + (5 * $gameVariables.value(A)) + $gameVariables.value(B )

To use the result variable as a reference, you have to use a script call.
$gameVariables.value($gameVariables.value(result));

[EDIT]I couldn't stop thinking about this problem and why it doesn't work for you.

Could it be that you defined the variable "Index" and did the calculating in a seperate script call? You then tried to refer to that variable in another script call box?

Alas, the script call box is very small, so if you want to put a longer textblock in it, you could use a javascript compressor.

Variables defined in a script call are only temporarily existent in this one script call. You can only refer to them in the same script call or you have to use other means.

The easiest one would be to use a normal $gameVariable. They are easier to keep track of and can be altered with the event editor.

In case that you only need this variable in this very special case, but you want to make it permanent and accessible outside, you would have to first define the variable in a script. Yes, a script - not a script call. After installing your variable-script, you can then alter this variable via script calls as you wish and the value is stored throughout the game.
I tried that in events and it works. I basically intend to do the math in an event (because I don't know how to do a simple Plugin where I send a command and a script does all the heavy lifting. Object Oriented Programming is like Greek to me.) and use $gameVariables.value($gameVariables.value(INDEX)); in a script call. I just needed to know if I could do that, and I can. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/using-an-variable-as-an-game-variable-index.82439/