Kiriashi 117 Report post Posted August 16, 2010 I am trying to open a scene if a random number = x, but no matter what, it opens the scene everytime. @leonscookies = rand(10) if @leonscookies = 6 $scene = Scene_Gameover.new end It goes to the scene everytime. I tried doing this: @joy = rand(10) print @joy And it showed a random number just fine. What am I doing wrong? Share this post Link to post Share on other sites
0 Leon 55 Report post Posted August 16, 2010 Your error is with your 'if' statement. look at some examples. ;P Share this post Link to post Share on other sites
0 Broken Messiah 20 Report post Posted August 16, 2010 I believe that there should be two equal signs in the if statement. Share this post Link to post Share on other sites
0 Polraudio 122 Report post Posted August 17, 2010 if @leonscookies = 6 WRONG!!!!! LOL if @leonscookies == 6 Yes it was that simple lol. Share this post Link to post Share on other sites
0 Broken Messiah 20 Report post Posted August 17, 2010 I was right . . . :drool:doesnt leonscookies = 6 set leonscookies to 6? Share this post Link to post Share on other sites
0 Kiriashi 117 Report post Posted August 17, 2010 Ah.. xD Thanks guys. ^~^ EDIT: But printing a random number worked just fine. Just the scene thing didn't.. Share this post Link to post Share on other sites
0 Kiriashi 117 Report post Posted August 17, 2010 Check this out. I have this code: Which produces this: I'm not using double equal signs. Share this post Link to post Share on other sites
0 Broken Messiah 20 Report post Posted August 17, 2010 It would have returned a nil I think if you were using == since 4 is not 5 Share this post Link to post Share on other sites
0 Zeriab 9 Report post Posted August 17, 2010 if var = 4 # Stuff end It first evaluates the conditional which sets var to 4 and returns 4 var = 4 It then comes to look like this: if 4 # Stuff end if (value) is anything other than nil or false it is considered as being true. Note also that @number is a different variable from number so using == would probably give you an error. Share this post Link to post Share on other sites
0 Kiriashi 117 Report post Posted August 17, 2010 It would have returned a nil I think if you were using == since 4 is not 5 That picture was actually an accidental paste. That's not the code I was using. xD if var = 4 # Stuff end It first evaluates the conditional which sets var to 4 and returns 4 var = 4 It then comes to look like this: if 4 # Stuff end if (value) is anything other than nil or false it is considered as being true. Note also that @number is a different variable from number so using == would probably give you an error. Thank you very much Zeriab! *hugs* Share this post Link to post Share on other sites
0 Leon 55 Report post Posted August 17, 2010 Oh, Zeriab, such a savior. And here I wanted to toy with Kiri! I never get to! -pouts- Share this post Link to post Share on other sites
0 Kiriashi 117 Report post Posted August 18, 2010 ^~^ #=============================================================================== # * Zeriab and Leon are Awesome Window #------------------------------------------------------------------------------- # * Object Initialization #=============================================================================== class Window_First < Window_Base def initialize super(180, 100, 256, 96) self.contents = Bitmap.new(width - 32, height - 32) refresh end end #=============================================================================== # * Refresh #=============================================================================== def refresh self.contents.clear self.contents.font.color = text_color(2) self.contents.draw_text(0, 0, 256, 32, "ALL PRAISE ZERIAB!") self.contents.font.color = system_color self.contents.draw_text(85, 40, 256, 32, "...and Leon") end Share this post Link to post Share on other sites
I am trying to open a scene if a random number = x, but no matter what, it opens the scene everytime.
It goes to the scene everytime.
I tried doing this:
And it showed a random number just fine.
What am I doing wrong?
Share this post
Link to post
Share on other sites