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.

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:
disposeevent.png

callwindow.png

errori.png
 
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!
 
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":14yk9oci said:
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.
[rgss]class Scene_Text
 
  def main
    @window = Window_Text.new
    @spriteset = Spriteset_Map.new
    Graphics.transition
    # Main loop
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @window.dispose
    @spriteset.dispose
  end
 
  def update
    @window.update
    if Input.trigger?(Input::C)
       $game_system.se_play($data_system.decision_se)
       # Switch to map screen
       $scene = Scene_Map.new
       return
    end
  end
 
end
[/rgss]
 
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:
[rgss]class Window_Text
def initialize
   height = n * 32     # n: num of variables
   width = 640
   super(0, 0, height, width)
   ....
end
 
end
[/rgss]
 
Miles Castea":ok48myid said:
What's the four dots for?
.... = the rest of your initialize method.
Miles Castea":ok48myid said:
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.
 

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