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
36,991
Reaction score
10,007
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,864
Reaction score
1,923
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,864
Reaction score
1,923
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,864
Reaction score
1,923
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

So, yeah. It's there.

Clarn Hold
(No storylines)
There was a tutorial on how to draw anime eyes. Just draw Among Us. So I tried.
Screenshot_107.jpg
DamageActor3_7.png added!
index.php

Making a "characters first appearance" drawing for my game. Now I just have to finish the sprite art animation for her grand entrance.​

Forum statistics

Threads
125,540
Messages
1,171,821
Members
164,614
Latest member
guymelul
Top