A single variable can't hold multiple values. So 123 can't be split into 1, 2, and 3
and stored in $game_variables[1], unless you're using either a hash or an array.
Otherwise, this would split up the variables into digits:
Code:
def split_digits(num)
digits = []
num.to_s.each_char do |bit|
digits.push(bit.to_i)
end
return digits
end
Calling split_digits(123) would return [1, 2, 3]. This is called an 'array'. If you then wanted to store it into variables, you'd do a script call and say
$game_variables[3], $game_variables[2], $game_variables[1] = split_digits(421)
And variable 3 would get 4, variable 2 would get 2, and variable 1 would get 1.
If instead you had called split_digits(53), variable 3 wouldn't get anything (it'd be empty) variable 2 would get 5, and variable 1 would get 3.