I decided to make a post for when I have a non specific type problem. Such as something that relates to scripting in general and not to a particular script.
First: [spoiler]Is there anyway to make rand(#) exclude lower numbers? Reason: I want to have some variance in a sprite animation. It has a fast/slow/fast/slow type movement. Which I achieved by using:
if $blah == 1
@sprite.x += rand(5)
elsif $blah == 2
@sprite.x += rand(2)
elsif $blah == 3
@sprite.x -= rand(5)
elsif $blah == 4
@sprite.x -= rand(2)
end
Which works for the most part, but the part that is supposed to be faster keeps getting low numbers and moves slower than the rand(2) part. I need to somehow exclude numbers lower than 3 for the rand(5) is that possible? If not then any ideas?
I've actually gotten a really nice effect without the randoms, but if anyone has a better way to do the above please tell![/spoiler]
Edit: New problem 8/1/13
How do I freeze the whole game? I'm trying to pause the map, execute a transition (done by pictures) teleport to a new map, and resume.
I usually use this.
values = [0, 1, 2, 4]
value = values[rand(values.size)]
Thanks! That's exactly what I wanted!
Or to get a random between x and y, use:
New question:
I know that in java you can do
case 10:
case 11:
case 13:
something();
break;
Is there a way to include multiple cases in rgss? Or better a range of cases? Trying to display a specific world logo on save menu when on certain maps. I know there are other ways to do it such as
if mapname includes name, display logo x;
In fact i had just thought of it while typing, lol. But my question still holds because I know I will need this some time.
when 10, 11, 13 # will be executed when 10, 11 or 13
stuff
when 0...10 # all values from 0 to 9
more_stuff
Thanks again blizz :D