n-th variable

Hi people 🙂

Is it possible somehow to get the n-th variable and change it in an event?

Eg. i have a counter variable, and if the count in that variable reaches 4, can i then get RPG Maker to take variable 004 and change that to a new number of my choice with the operators, or am i asking to much of the program?

I know i can manually assign a lot of conditions and say if counter variable equals 4, then variable 004 equals x, and repeat as much as required, however i have a lot of variables that need regular changing, and am therefore looking for an easy way to automate it. 

Kind regards.

Daniel
I think you should explain better what you want.

Any variable can be changed by either events (control variable command) or script ($game_variables[n]).

If you give a better example/description of what you want to do, then we can tell you how to do that...
Sure 🙂

Lets say i have variables 1-10 that tells a series characters stats, for example defence.

Lets then say i have variables 11-20 that tells the same series of characters "talent".

I would then like to take variable 1 and multiply it by variable 11, variable 2 to be mulitplied by variable 12 and so on.

I imagined someting like i set the counter variable to add +1 pr loop. Then it takes the counter variable result "1" and sets that as the variable that is going to be altered "Var001". That variable will the be mutiplied by the counter variable result +10 which gives "11", so it mutiplies by variable "Var011". So in short

Counter will be called "C" starts as 0, and loops by +1 pr. turn. So we get:

C = 0

label

control variable [C + 1] = 1 (This line Is easy enough to do)

Variable to be changed = Var( C) = Var001

Variable used to modify = Var( C+10) = Var011

control variable [Var( C) = * Var( C+10)] (This line is easy enough to do)

jump to label

and then the loop makes C = 2 and continues over and over until i break it.

Hope it's understandable 🙂
you cannot use the control variable command for that as that would require a fixed variable number to store the result (you would have to make one such command per iteration and cannot loop)

However, you could place such a loop in a script command inside the event.

I don't have the RGSS3 syntax for that - you'll have to wait until a scripter gives you that.
Ok, i'll be waiting then 🙂 Thank you for the replies.
Hi,

I was told to go on scripters forum with this little problem, so i hope you can assist me 🙂

Lets say i have variables 1-10 that tells a series characters stats, for example defence.

Lets then say i have variables 11-20 that tells the same series of characters "talent".

I would then like to take variable 1 and multiply it by variable 11, variable 2 to be mulitplied by variable 12 and so on.

I imagined someting like i set the counter variable to add +1 pr loop. Then it takes the counter variable result "1" and sets that as the variable that is going to be altered "Var001". That variable will the be mutiplied by the counter variable result +10 which gives "11", so it mutiplies by variable "Var011". So in short

Counter variable will be called "C" starts as 0, and loops by +1 pr. turn. So we get:

C = 0

label

control variable [C + 1] = 1 (This line Is easy enough to do with event creator)

Variable to be changed = Var( C) = Var001

Variable used to modify = Var( C+10) = Var011

control variable [Var( C) = * Var( C+10)] (This line Is easy enough to do with event creator)

jump to label

and then the loop makes C = 2 and continues over and over until i break it.

Hope it's understandable 🙂

It's for Ace btw
Please do not post multiple threads for the same question. If you've posted something in the wrong place, we will move it. If you realize you posted it in the wrong place, you can also report it and ask us to move it rather than waiting for us to see it.


If variable 1 contains the id of the other variable you wish to change, and variable 2 contains the id of the variable you wish to change it to, you would do it like this:

Code:
$game_variables[$game_variables[1]] = $game_variables[$game_variables[2]]
from what I gathered, you have a set of variables x through x+9, and y through y+9, aka 1-10 and 11-20. You wanna loop through the firs set and in-place multiply it by the corresponding y set variable, correct?

10.times do |i| n = $game_variables[i+x] m = $game_variables[i+y] $game_variables[i+x] = n*mendThis loops ten times, passing the index into the loop. Variable x+i(lets say 1) is in-place multiplied by Variable y+i(thus, 11),then moves on to 2 and 12, then 3 and 13, etc. Hope this helps.
you could have done


10.times do |i|


$game_variables[i+x] *= $game_variables[i+y]


end
Yeah, but I thought that might exceed the line character limit in the Script event command. That's why I split it up. I also split it up to make it more clear for the on who will be using it ^_^ They might not know what *= means, etc. I wanted them to understand what the code was doing so they could use it later without further help.
ah yeah... I forgot it was for the event commands... XD

Original thread: https://forums.rpgmakerweb.com/threads/n-th-variable.20698/