Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: RoseSkye on March 13, 2018, 11:15:07 am

Title: Script Call for changing multiple variables (like the batch variable command)
Post by: RoseSkye on March 13, 2018, 11:15:07 am
Does it exist?  It's very convenient
Title: Re: Script Call for changing multiple variables (like the batch variable command)
Post by: Blizzard on March 13, 2018, 12:27:40 pm
There is a way to batch-modify variables with events, isn't there? Or was that just for switches?
Title: Re: Script Call for changing multiple variables (like the batch variable command)
Post by: KK20 on March 13, 2018, 01:13:16 pm
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).
Title: Re: Script Call for changing multiple variables (like the batch variable command)
Post by: RoseSkye on March 13, 2018, 05:35:28 pm
Works beautifully and I've learned something new again. Thanks KK20 for showing me how & Blizz for stating that it also works with switches.
Title: Re: Script Call for changing multiple variables (like the batch variable command)
Post by: LiTTleDRAgo on March 16, 2018, 05:43:16 am
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
Title: Re: Script Call for changing multiple variables (like the batch variable command)
Post by: RoseSkye on March 16, 2018, 09:06:56 am
Wow, thanks!

That'll be useful as well in the future!