[Solved] Call Script popup

Started by Lylac#c0ffee, February 24, 2014, 09:18:54 am

Previous topic - Next topic

Lylac#c0ffee

February 24, 2014, 09:18:54 am Last Edit: February 24, 2014, 10:51:13 am by Lylac#c0ffee
For an easy way to notify players when they kill or pick up something for an active quest while using BlizzABS, I thought it would be a good idea to have some little popup window that says "You've killed # Bugs" (or something) using variables for the #s. I found this:

Spoiler: ShowHide

class Popup
 
 # Set the default size of the window. This is used when no size is defined.
 DEFAULT_SIZE = [320, 64]
 # Default number of frames the window displayes for when not defined.
 DEFAULT_DURATION = 60
 
 #-----------------------------------------------------------------------------
 #  * Display a Pop-up window
 #     text   - The text to display in the window
 #     time   - The number of frames to display window for
 #     width  - Width of the window
 #     height - Height of the window
 #-----------------------------------------------------------------------------
 def self.show(text, time = nil, width = nil, height = nil)
   width = (width == nil ? DEFAULT_SIZE[0] : width)
   height = (height == nil ? DEFAULT_SIZE[1] : height)
   x = (640 - width) / 2
   y = (480 - height) / 2
   @count = Graphics.frame_count + (time == nil ? DEFAULT_DURATION : time)
   @window = Window_Base.new(x, y, width, height)
   @window.contents = Bitmap.new(width - 32, height - 32)
   @window.contents.draw_text(0, 0, width - 32, height - 32, text, 1)
   Thread.new do
     while Graphics.frame_count < @count; end
     Popup.dispose_window
   end
 end
 #-----------------------------------------------------------------------------
 # * Dispose the window
 #-----------------------------------------------------------------------------
 def self.dispose_window
   if @window != nil && !@window.disposed?
     @window = @window.dispose
   end
 end
end


Call script is:
Popup.show(TEXT, FRAME_COUNT, WIDTH, HEIGHT)


Found it here:
http://forum.chaos-project.com/index.php?topic=12204.0

This does exactly what I want, but I'm not sure how to get variables to display with the text. Is there an easy fix for this? My scripting skills are practically nil; I just copy and paste and try to work things out. lol But this has my copy strategy stumped. If it can't be worked out, I'll just have to have a bunch of event pages for each variable amount. Doable, but kind of tedious.

Thanks in advance!  :D

Edit: Oops. Forgot to say it's for RMXP. You might've figured that out by now, but just in case.  ;)

G_G

Try this:
v = $game_variables[VAR_ID]
Popup.show("You've killed #{v} bugs.", FRAME_COUNT, WIDTH, HEIGHT)

Lylac#c0ffee

Of course it would be simple! lol

Thanks a bunch!

G_G

Yup! Not a problem! Just make sure if you do that trick, It has to be in double quotes " ". Single quotes don't evaluate #{}.