Script Call for changing multiple variables (like the batch variable command)

Started by RoseSkye, March 13, 2018, 11:15:07 am

Previous topic - Next topic

RoseSkye


Blizzard

There is a way to batch-modify variables with events, isn't there? Or was that just for switches?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

KK20

Yeah, variables have that ability too.

The only scripting approach would be to make a loop and iterate through a range, like

for i in 1..10
$game_variables[i] = 100
end
$game_map.need_refresh = true

which would set variables 1 through 10 to a value of 100. The game map refresh at the end is needed for events to update their page conditions (you have to do the same thing with switches too).

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

RoseSkye

Works beautifully and I've learned something new again. Thanks KK20 for showing me how & Blizz for stating that it also works with switches.

LiTTleDRAgo

You can do it like this too.

[1,2,5,6,9,11,44, ..... ].each { |i| $game_variables[i] = 100 }
$game_map.need_refresh = true

RoseSkye