Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

3 Important Questions!

OS

Sponsor

Hello. I have three little questions:

1. How do I check to see if Weather is active? I mean, if weather effects are active at all?

2. Also, how do I wait for a curtain period of time before executing a new method? For example, in my Lock Pick Script, a message is supposed to display saying "Attempting to Pick Lock!" and then a message saying "You Win" or "You Fail" is supposed to display, and then I wait for a key press. But "You Win" or "You Fail" show up automatically becuase the code executes too quickly. I want to have the player wait for a second or two before the text changes. I also want to wait for Keypress before closing a window.

3. And lastly I saw this script by Trickster in an other request, but how do you use it? Which Object do I call Sprite_Text.new?

Code:
class Sprite_Text < Sprite
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader :text
  attr_reader :width
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(text, x = 0, y = 0, viewport = nil)
    # Call Sprite#initialize and send viewport
    super(viewport)
    # Set Coordinates
    self.x, self.y = x, y
    # Set Bitmap
    self.bitmap = Bitmap.new(32, 32)
    # Set Text
    @text = text
    # Setup Text
    setup_text
  end
  #--------------------------------------------------------------------------
  # * Set Text
  #--------------------------------------------------------------------------
  def text=(text)
    # Return if same text
    return if @text == text
    # Set New Text
    @text = text
    # Setup Text
    setup_text
  end
  #--------------------------------------------------------------------------
  # * Set Width
  #--------------------------------------------------------------------------
  def width=(width)
    # Return if same width
    return if @width == width
    # Set New Width
    @width = width
    # Setup Text
    setup_text
  end
  #--------------------------------------------------------------------------
  # * Setup Text (Private)
  #--------------------------------------------------------------------------
  private
  def setup_text
    # Get Size of Text
    size = bitmap.text_size(@text).width
    # Dispose Previous Bitmap
    self.bitmap.dispose if self.bitmap != nil
    # Create Bitmap
    self.bitmap = Bitmap.new(@width.nil? ? size : @width, 32)
    # Draw Text onto bitmap
    self.bitmap.draw_text(0, 0, size, 32, @text)
  end
end
 

Mac

Member

I'm not sure about this, but i'll have a shot ^_^

1.
Code:
 if @weather.active = true
        return p "yayyy i'm active"

2. Put this in the main metod of the script you are using (i.e. under def main)
Code:
          @count = 0

Then add this in the def refresh section.
Code:
@count = (@count + 1) % 140
    if @count == 20
# process here, whatever you want
end

3. Which script?
 
For 1 it is a bit more complicated since it tries to add transitions between weathers. Check in Game_Screen under def weather and def update.

Trickster's script basically like this:
Code:
@text_sprite = Sprite_Text.new('Some Text', 0, 0)

There's nothing complicated about it. It's just a specialized sprite.
 

Anonymous

Guest

Akahi Aomitsu;135009 said:
Hello. I have three little questions:

1. How do I check to see if Weather is active? I mean, if weather effects are active at all?

Code:
if !($game_screen.weather_type == 0)
  # there is some sort of weather effect going on
  # protip:  this will work with my weather script, too!
end
 

OS

Sponsor

@Mac: Okay, I think I egt it, kind of maybe...

@SephirothSpawn: So how do I get the text to actually display. I am still a n00b at graphics handling in RGSS...:(

@Ccoa: Actually that's the script I intend to use the code for! lol. So to see if weather is not active I would use:
Code:
unless $game_screen.weather_type != 0

or

if $game_screen.weather_type == 0
?

If so, then this is perfect!

@all three of you: Thanks very much!
 

Anonymous

Guest

Akahi Aomitsu;135419 said:
@Ccoa: Actually that's the script I intend to use the code for! lol. So to see if weather is not active I would use:
Code:
unless $game_screen.weather_type != 0

or

if $game_screen.weather_type == 0
?

If so, then this is perfect!

Neither. Use

if $game_screen.weather_type != 0

or

unless $game_screen.weather_type == 0
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top