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?
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