Bit rusty with RGSS, so I need some help.

For a purpose in my game, I decided to code a window that would display some variable information, sorta as a records board (i.e, like the board in Mario's house in Paper Mario). I have the window frame and words down, and I already have it centered and size perfectly....but I need some help. I'm a bit a rusty anywya, so I've forgotten most of what I leanred from Law on RPGRevolution.
1. Is there a way to store the total number of currency earned throughout the game and show it as a variable?
2. How do I display a variable in a window again?
3. I'm using an event to call the window, and a parrelarel process event that will kill the window if a specific key is pressed, but I'm getting errors when I try it.

Screens:
Image
Image
Image
Not sure about that 3rd error, but there's definitely a way to code the first two.

1. In "Interpreter 4", the command for "Change Gold" is under "def command_125". Under the "value" line, you can add the following, where id is the variable you want to add to:
$game_variables[id] += value

2. To display a variable, instead of text, have the code:
$game_variables[id].to_s

Hope this helps!
Thank you bubbles!
Also, would this work for the third:
if Input.trigger?(Input::BUTTON)
Just for reference's sake, when you use a conditional branch for a button press, it corresponds to Input.press?(), which will run whenever the button is pressed, unlike trigger which requires it to be released before it will run again upon a keypress. Your window thereby disposed itself countless times when the X pad button was pressed. Another approach would be to change it into:

$window.dispose unless $window.disposed?

/Sark
BubblesVonSalamancer wrote:
Not sure about that 3rd error, but there's definitely a way to code the first two.

1. In "Interpreter 4", the command for "Change Gold" is under "def command_125". Under the "value" line, you can add the following, where id is the variable you want to add to:
$game_variables[id] += value

2. To display a variable, instead of text, have the code:
$game_variables[id].to_s

Hope this helps!


1. make sure you're not adding a negative value:
$game_variables[id] += value if value>0

2. yes, then you can use it like any self.contents.draw_text :
self.contents.draw_text(x, y, w, 32, text, align)

3. using events to control windows is possible, but buggy.
The usual way is to make a scene to update the window and dispose it. Then, in the event simply call $scene = Scene_Text.new .
The following code will show your window, and the map behind it, just like you get when using an event. It uses C button, not X.
  1. class Scene_Text
  2.  
  3.   def main
  4.     @window = Window_Text.new
  5.     @spriteset = Spriteset_Map.new
  6.     Graphics.transition
  7.     # Main loop
  8.     loop do
  9.       Graphics.update
  10.       Input.update
  11.       update
  12.       if $scene != self
  13.         break
  14.       end
  15.     end
  16.     Graphics.freeze
  17.     @window.dispose
  18.     @spriteset.dispose
  19.   end
  20.  
  21.   def update
  22.     @window.update
  23.     if Input.trigger?(Input::C)
  24.        $game_system.se_play($data_system.decision_se)
  25.        # Switch to map screen
  26.        $scene = Scene_Map.new
  27.        return
  28.     end
  29.   end
  30.  
  31. end
Expand to see the code.
Well, I have the window done as show by here:
http://img638.imageshack.us/img638/5672 ... smachi.png

One more question...is there anyway to have the window adjust it's width based on the character count of the variables being displayed?
I'm not sure what you mean by 'character count of variable', but you can get the width of any text by doing
w = contents.text_size(your_txt).width
To adjust the window's height/width, do something like:
  1. class Window_Text
  2. def initialize
  3.    height = n * 32     # n: num of variables
  4.    width = 640
  5.    super(0, 0, height, width)
  6.    ....
  7. end
  8.  
  9. end
Expand to see the code.
What's the four dots for?
by character count, how many numbers in a variable at the time, and it would probably go by the number that has the highest character count.
Miles Castea wrote:
What's the four dots for?

.... = the rest of your initialize method.
Miles Castea wrote:
by character count, how many numbers in a variable at the time, and it would probably go by the number that has the highest character count.

Nope, still no clue what you're saying.
The num of variables in a Array, each one is a string? :crazy:
Character count as in...take this for example.
The character count of the sentence above is 46 characters.
Now take this number: 2747. Despite being two thousand, seven hundred, and fourty seven...it's still 4 characters.
Again: 3647623747. I'm not counting that...figure it out for yourself kid. The character count of the number to the left is 10.

Character count for this entire post is 400.
just do

array = [4, 46, 876765654]
max_width = 0
array.each {|number|
txt = number.to_s
w = contents.text_size(txt).width
max_width = w if w> max_width
}
super(x,y,w,h)

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=71302