My General Questions

Started by Zexion, May 24, 2013, 07:05:32 am

Previous topic - Next topic

Zexion

May 24, 2013, 07:05:32 am Last Edit: August 02, 2013, 12:32:57 am by Zexion
Spoiler: ShowHide
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.

Blizzard

I usually use this.

values = [0, 1, 2, 4]
value = values[rand(values.size)]
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.

Zexion

Thanks! That's exactly what I wanted!

ThallionDarkshine

Or to get a random between x and y, use:
rand(y-x)+x

Zexion

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.

Blizzard

when 10, 11, 13 # will be executed when 10, 11 or 13
  stuff
when 0...10 # all values from 0 to 9
  more_stuff

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.

Zexion