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.

closing a message?

Ok this is probably so simple that it will make some one else cry, but I'm experimenting with scripts and created a window with the picture of the guy Im talking to in it, which is called by an event (guy standing around) using window_base as super class, but I want to make it so that when I press b or nay other button the message will go away like all other default messages in the game do. I've tried "If Input.trigger(Input::B)" then New_Window.dispose which doesn't work (New_Window is hte name of the class), and just goes to the acutal items menu instead over lapping my message. Also when ever enter is pressed the message keeps overlapping itself. How do I fix these problems?
 

OS

Sponsor

What variable is New_Window in?

It should be my_new_window_variable_name_here.dispose

Assuming you even put it into a variable in the first place...
 
Thanks OS, I put it in variable but its still not workin, now when i go up the the event it just freezes and gives me stack level errors

heres my scripts:

class New_Window < Window_Base

def initialize
super(0, 0, 640, 200)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = "Arial"
self.contents.font.size = 24
@bitmap = RPG::Cache.battler("Weirdface", 0)
@my_new_window = New_Window.new
update
end

def update
self.contents.clear
self.contents.font.color = text_color(6)
cx = contents.text_size("I have a weird face!").width
self.contents.draw_text(200, 100, cx, 32, "I have a weird face!")
self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, 200, 200), 160
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to Menu screen
@my_new_window.dispose
end
end
end

In the event I call it by saying "New_Window.new"
 

khmp

Sponsor

You're creating an infinite loop of windows. Calling initialize by saying New_Window.new goes through New_Window's initialize. Goes to create a window and then sees this line:

Code:
@my_new_window = New_Window.new

So New_Window's initialize is called again so it creates another window until it reaches this line:

Code:
@my_new_window = New_Window.new

ad infinitum. So there's your stack overflow problem. To correct this toss out that line. And to dispose of the window in the update replace '@my_new_window.dispose' with 'self.dispose'.

Good luck with it boomdoggydawg! :thumb:
 
thanks heaps khmp, did that and the pressing B works the first time to get rid of the message(sometimes it works anyway..), but it just closes msg and goes to menu straight away. The second time and times after that pressing B does the same thing, makes the menu come up overlaying the message until the message automatically goes away

Sorry to be a pain, but I just want it so that when u press any button after the message comes up it goes away and back to just the map scene, every time. I tried lookin at the default rmxp scripts to see how they did it, but get lost trying ':| ...
 

khmp

Sponsor

Hey no problem. Ok so I think I understand what you're trying to do. But there's some ambiguity on my side I was hoping you would be able to fill me in. By any input closes the window do you mean any key press closes it? Or any key that RMXP uses? You might require the aid of a input script.

Second I don't know why it only works once. My guess is that the event calling the script is failing to do so more than once but again sadly I don't know why.

Since the window is being called inside Scene_Map I don't know how to get the scene to ignore input directed at the window to not be carried into the scene. Like when you press the 'B' button to close the window. Scene_Map catches the fact the 'B' was pressed and opens the menu.

However despite the lack of answers you might have more success closing the window the first time by using 'Input.press?' instead of 'Input.trigger?'.
 
thanks again khmp, yea by any input I mean any key pressed. So if i press any key (onlykeys already allocated by rmxp to do something like enter and esc etc), the message will close and go back to just the scene_map. I think what I am trying to do may be more complicated than I first thought...

I just want the message to come up like a default rmxp message would when u tlak to someone, and then go away when u press a key. The only real difference in my script to the default message script is that my window is in a different place and has a picture of the person I am talkin to in the window. Other than that I want it to be the same... I guess I jsut want to find out how to do the script myself...
 

khmp

Sponsor

Hmmm... I would recommend your window derive from Window_Message instead of Window_Base then and overwriting certain functions to achieve the result you want. But this is beyond my scope you'll need the help of a much more knowledgeable scripter than me :) I will inform you though that the items you are seeking are already accomplished. Not that I'm trying to discourage you trying to learn but there are other options. Sorry boomdoggydawg, in the end I couldn't be much help. :s

Good luck with it! :thumb:
 

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