Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: Zexion on May 24, 2013, 07:05:32 am

Title: My General Questions
Post by: Zexion on May 24, 2013, 07:05:32 am
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.
Title: Re: My General Questions
Post by: Blizzard on May 24, 2013, 08:54:48 am
I usually use this.

values = [0, 1, 2, 4]
value = values[rand(values.size)]
Title: Re: My General Questions
Post by: Zexion on May 24, 2013, 09:49:31 am
Thanks! That's exactly what I wanted!
Title: Re: My General Questions
Post by: ThallionDarkshine on May 24, 2013, 10:01:23 am
Or to get a random between x and y, use:
rand(y-x)+x
Title: Re: My General Questions
Post by: Zexion on May 25, 2013, 09:29:24 am
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.
Title: Re: My General Questions
Post by: Blizzard on May 25, 2013, 09:47:28 am
when 10, 11, 13 # will be executed when 10, 11 or 13
  stuff
when 0...10 # all values from 0 to 9
  more_stuff

Title: Re: My General Questions
Post by: Zexion on May 27, 2013, 01:53:00 pm
Thanks again blizz :D