Set variable x

emperorlulu

Villager
Member
Joined
Aug 16, 2016
Messages
8
Reaction score
0
First Language
english
Primarily Uses
I've been looking all over for some form of how to do this, but I couldn't find any.
I simply want to know how to set variable x, where x is the value of another variable. For example, if the independent variable is set to 3, it will change the value of variable 3. If it is set to 4, the of variable 4. At the moment, I have conditional branches that check the value of the first variable and set them that way. (if variable 100=1, set variable 1 etc) But this is an extremely long and complicated method, and gets even more so if I want to increase the number of variable that can be changed this way later. If there is a plugin or script call that can do this that would be great to know.
 

Zarsla

Veteran
Veteran
Joined
Jan 23, 2015
Messages
710
Reaction score
228
First Language
English
Primarily Uses
Using Events:
1 Make a new event
2 on page 1 of event commands, go to control variables.
3. On control variables select variable 3.
4. make the operation set.
5. make operand variable 4.


Using Script Calls/JS code:
$gameVariables.setValue(3, $gameVariables.value(4));
What the code above says is set variable with id 3, to the current value of variable 4.

Now Variable 3 is set to what ever Variable was set to.

Note that variable 4 has to be set to a number before you set variable 3 equal to what ever it has.
 

emperorlulu

Villager
Member
Joined
Aug 16, 2016
Messages
8
Reaction score
0
First Language
english
Primarily Uses
Using Events:
1 Make a new event
2 on page 1 of event commands, go to control variables.
3. On control variables select variable 3.
4. make the operation set.
5. make operand variable 4.


Using Script Calls/JS code:
$gameVariables.setValue(3, $gameVariables.value(4));
What the code above says is set variable with id 3, to the current value of variable 4.

Now Variable 3 is set to what ever Variable was set to.

Note that variable 4 has to be set to a number before you set variable 3 equal to what ever it has.
I understand how to set a variable to another variable, but what I mean is how to set multiple variables based on the value of another variable. I do want to set variable x to the value of variable y, but I want variable x's ID to be the value of variable z.
 

Zarsla

Veteran
Veteran
Joined
Jan 23, 2015
Messages
710
Reaction score
228
First Language
English
Primarily Uses
@emperorlulu

Let me used the example I used then.

$gameVariables.setValue($gameVariable.value(5), $gameVariables.value(4));
Set the variable that is equal to the current value of variable 5 to the current value variable of 4.

So let's say variable 5 is set to 7, abd variable 4 is equal to 100.
Then variable 7 is set to 100.

And as always set variable 5 & 4 to the values you want.

As this code:
$gameVariables.setValue(x, y);
means set variable id x to the value of y. Where x & y means any javascript eval/code. Most people put numbets but you can put variable values, ids of classes or anything else you can think if.
 

emperorlulu

Villager
Member
Joined
Aug 16, 2016
Messages
8
Reaction score
0
First Language
english
Primarily Uses
@emperorlulu

Let me used the example I used then.

$gameVariables.setValue($gameVariable.value(5), $gameVariables.value(4));
Set the variable that is equal to the current value of variable 5 to the current value variable of 4.

So let's say variable 5 is set to 7, abd variable 4 is equal to 100.
Then variable 7 is set to 100.

And as always set variable 5 & 4 to the values you want.

As this code:
$gameVariables.setValue(x, y);
means set variable id x to the value of y. Where x & y means any javascript eval/code. Most people put numbets but you can put variable values, ids of classes or anything else you can think if.
I know that this will work for what I need, but it just says $gameVariable not defined when it executes. I copied it exactly, only changing the variable IDs, so I'm not sure what's wrong.
 

Zarsla

Veteran
Veteran
Joined
Jan 23, 2015
Messages
710
Reaction score
228
First Language
English
Primarily Uses
$gameVariables.setValue($gameVariables.value(5), $gameVariables.value(4));
Sorry, it was a typo.
 

emperorlulu

Villager
Member
Joined
Aug 16, 2016
Messages
8
Reaction score
0
First Language
english
Primarily Uses
$gameVariables.setValue($gameVariables.value(5), $gameVariables.value(4));
Sorry, it was a typo.
haha, looks like just a single letter was off. Just shoes why I couldn't figure this out myself if I didn't even notice that. regardless, looks like that was just what I needed, so thanks a lot!
 

emperorlulu

Villager
Member
Joined
Aug 16, 2016
Messages
8
Reaction score
0
First Language
english
Primarily Uses
$gameVariables.setValue($gameVariables.value(5), $gameVariables.value(4));
Sorry, it was a typo.
I actually have one more question. I need to set a variable equal to the value of variable x. Kinda the opposite of earlier. instead of setting different variables with one command it sets one variable equal to the value of multiple variables, if you know what I mean.
 

Naveed

Veteran
Veteran
Joined
Nov 2, 2013
Messages
314
Reaction score
146
First Language
English
Primarily Uses
RMMV
I actually have one more question. I need to set a variable equal to the value of variable x. Kinda the opposite of earlier. instead of setting different variables with one command it sets one variable equal to the value of multiple variables, if you know what I mean.
If you mean how to set the value of a variable to another variable, you can do that with the Control Variables event command.
 

Zarsla

Veteran
Veteran
Joined
Jan 23, 2015
Messages
710
Reaction score
228
First Language
English
Primarily Uses
@emperorlulu AFAIK a variable can only hold 1 value at a time, not multiple ones.

Now this:
$gameVariables.setValue(y, $gameVariables.value(x));

this means variable y is equal to the value of variable x.
 

Naveed

Veteran
Veteran
Joined
Nov 2, 2013
Messages
314
Reaction score
146
First Language
English
Primarily Uses
RMMV
@emperorlulu AFAIK a variable can only hold 1 value at a time, not multiple ones.
Actually, a variable CAN hold multiple values. It can hold as many values as you want by converting it into an array. However, assuming that the OP is still sort of new to MV, I would suggest not trying to do so until you're more familiar with the program.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,018
Messages
1,018,358
Members
137,803
Latest member
andrewcole
Top