Tapael

Veteran
Veteran
Joined
Oct 23, 2021
Messages
31
Reaction score
8
First Language
n
Primarily Uses
RMVXA
Recently, I wanted to create a script.


How does it work?

@window = Window_textbox.new
@window.event_text("event!")


If you enter the script as above, you wanted to set the length of the sentence in parentheses in @window.event_text to the width of the text box.

However, when I created and ran the script, there was an error called disposed window.

The script is as follows.

class Window_textbox < Window_Base
def initialize(x = 256,y = 192,width = cal_width(), height = 50)

super(x,y,width,height)


end



def event_text(text)
return unless text.is_a?(String)
draw_text(text, 0, 0, 128, 25)
end


def draw_text(text, x, y, text_width, text_height, aligment = 0)
contents.draw_text(x, y, text_width, text_height, text, aligment)



end
end

def cal_width()
bt = Bitmap.new(1, 1)
rect= bt.text_size(contents.draw_text)
bt.dispose
return rect.width
end



I don't know how to fix it. Please help me.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
37,304
Reaction score
10,171
First Language
German
Primarily Uses
RMMV
where did you store your script, and where and when did you call it?

one of the mistakes many new programmers make is to believe that they can enter and call their scripts everywhere, but that doesn't work.
 

Tapael

Veteran
Veteran
Joined
Oct 23, 2021
Messages
31
Reaction score
8
First Language
n
Primarily Uses
RMVXA
where did you store your script, and where and when did you call it?

one of the mistakes many new programmers make is to believe that they can enter and call their scripts everywhere, but that doesn't work.
I put it under the material of the script editor.

And when I called the script, I called it an event on the map.

Create events on the map (auto-run), and then script them

@window = Window_textbox.new
@window.event_text("event!")

That's how it went this way.



And additionally, how do I make the window disappear when I press a specific key after creating the box?

def dispose2
contents.dispose unless disposed? if Input.trigger?:)C)
super
end

I've made it this way, but it doesn't work.

Thank you for your answer.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,898
Reaction score
1,952
First Language
Spanish
Primarily Uses
RMVXA
first of all: what exactly are you trying to accomplish here?
 

Tapael

Veteran
Veteran
Joined
Oct 23, 2021
Messages
31
Reaction score
8
First Language
n
Primarily Uses
RMVXA
first of all: what exactly are you trying to accomplish here?
I thought that the width of the window changes according to the length of the sentence.

And I thought that it would disappear if I pressed a particular button while the window was showing.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,898
Reaction score
1,952
First Language
Spanish
Primarily Uses
RMVXA
while the window was showing.
that is a condition that involves another process.
have you read the code to find that other process?
 

Tapael

Veteran
Veteran
Joined
Oct 23, 2021
Messages
31
Reaction score
8
First Language
n
Primarily Uses
RMVXA
that is a condition that involves another process.
have you read the code to find that other process?
If you're asking about the process of determining if a window is visible, you're not.

* I'm sorry. I'm not sure what exactly you mean by your question.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,898
Reaction score
1,952
First Language
Spanish
Primarily Uses
RMVXA
the window is held open while the text is displayed, and kept closed when there is no text to display.
do you know where that check comes from? that is the other process.

no point explaining how to do this if you don't understand the code you're reading.
 

Latest Threads

Latest Profile Posts

working on an A/V sync system for my game! was NOT expecting the first roadblock to be accessing a variable from a public class!! Computers are so finicky sometimes :kaosigh:
For the first real time since my game's inception I found myself actually having fun playing around with my party's skills while testing out some battles! So much so, that I actually forgot what I was doing for a minute and had to force myself to move on to the next thing! :guffaw:

That's got to be a good sign considering it only has place holder animations, enemy skills, troop comps, etc. right now. Feels good!
Bex
Finally upgraded to RMMZ.
ScreenShot_11_28_2022_7_52_34.png
FINALLY, I figured out how to get the "tail" to appear IN the window and not directly below it lol. now it looks like it's part of the window and not hanging from the bottom of it.
Twitch! Stream is about to go live with some Dark Souls 2! Feel free to drop by!

Forum statistics

Threads
126,925
Messages
1,182,398
Members
166,755
Latest member
Hahah520
Top