Script needed: Adding multiple variables to make another variable

Status
Not open for further replies.

WaywardMartian

Is sometimes a giant bee
Veteran
Joined
Jan 1, 2017
Messages
191
Reaction score
512
First Language
English
Primarily Uses
RMMV
I know it can be done in an ugly way with events, and I expect it can be done in a pretty way with a script, but I cannot do Javascript to save my life. What would the script be for adding several Variables together to make another Variable? Just a basic v[1]+v[2]+v[3]+v[4]=v[5] type of thing.
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
@WaywardMartian Fancy-pants option :

Code:
$gameVariables.setValue(5, [1,2,3,4].reduce(function(a, v) { return a + $gameVariables.value(v); }, 0));
Normal option :

Code:
$gameVariables.setValue(5, $gameVariables.value(1) + $gameVariables.value(2) + $gameVariables.value(3) + $gameVariables.value(4));
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
This is a script call, not a request for a plugin.

[move]RPGMaker MV[/move]
 

WaywardMartian

Is sometimes a giant bee
Veteran
Joined
Jan 1, 2017
Messages
191
Reaction score
512
First Language
English
Primarily Uses
RMMV
@Ossra Thank you!

@Kes And thank you. I couldn't remember if script call requests went under plug-ins or general MV questions and picked the wrong forum.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,090
Members
137,586
Latest member
Usagiis
Top