How do I move text box by scripting?

Status
Not open for further replies.

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
How do you want to move it? The Window_Message.update_position method would probably be what you need to be looking at, but unless you're more specific, we can't help you further.


Also, you didn't state whether you're using Ace (which is the most common one, and what I'm assuming), or VX as in your profile. VX probably has different requirements, because I believe the scripts were significantly reorganized between VX and Ace.
 

XinChao

Veteran
Veteran
Joined
Jun 11, 2012
Messages
117
Reaction score
3
Primarily Uses
Ok, What I am trying to do is to temporary move the window message box in X position in an event and resize it. The RMVXace.

For example, I know the script below are wrong but I just want to give you an idea what I am trying to do.

class Window_Message_Box < Window_Base 

@Message_Box = Window_Message.update_position (0, 0 ) # I can't seems to find the Window_Message_Update method

end

So, I will call that method inside an event via script.

Message_Box = 100, 200 # where X = 100 and Y = 200
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Yeah, it doesn't really work that way. The position of the window is updated BY the message window script, so that doesn't get called until you use the Show Text command. However, using Show Text also halts all other processing until after the window is removed, so your script call in the event will not get run until after the window goes away.


Anywhoo ... the message window, by default, takes up the full width of the game screen. Changing its x position is only going to move it to the right or left a bit, leaving a blank space on the opposite side. If you actually have a BOX with 4 sides, that is not the entire width of the screen, then you must be using a script that already alters the behaviour of the window.


Are you? Do you have a link to it? If you aren't using a message script, maybe you should take a screenshot of what it's doing now, then draw on it to indicate what you'd LIKE it to do, to give a better understanding.
 

XinChao

Veteran
Veteran
Joined
Jun 11, 2012
Messages
117
Reaction score
3
Primarily Uses
I just want to move the Text Box upward (Y position) about two squares in certain event. I need simple script to do that. I can't find any, so I am trying to write one for myself but dont know how to do it.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Can you not just tell it to position to the middle?

If you add the following script into a new slot:

class Game_Message attr_accessor :oy # override window y positionendclass Window_Message < Window_Base def update_placement @position = $game_message.position p $game_message.oy self.y = $game_message.oy.nil? ? @position * (Graphics.height - height) / 2 : $game_message.oy @gold_window.y = y > 0 ? 0 : Graphics.height - @gold_window.height endendYou can do this in an event's Call Script command:
Code:
$game_message.oy = 50
and then execute a Show Text command, and it'll put the window at y=50.And afterwards, to reset it (so the rest of the messages go back to the default), do this in a Call Script command:

Code:
$game_message.oy = nil
Problem is, if you have several text boxes in a row, the setting won't update - you need a brief pause between them. So add a Wait 1 Frame before the script call, and that should do it.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
That's a bit easier :)
 

XinChao

Veteran
Veteran
Joined
Jun 11, 2012
Messages
117
Reaction score
3
Primarily Uses
I look at it and I can't understand how it works.

So, I add below class Scene_Map < Scene_Base

#————————————————————————–

# ● This is to script call Show Message on the Map.

# ● SceneManager.scene.message_window.move(x, y, w, h)

#————————————————————————–

attr_reader :message_window

Then I call this script in event 

x=SceneManager.scene.message_window.x

y=SceneManager.scene.message_window.y

w=SceneManager.scene.message_window.width

h=SceneManager.scene.message_window.height

$game_variables[88] = x

$game_variables[89] = y

$game_variables[90] = w

$game_variables[91] = h

SceneManager.scene.message_window.move(x, y, w, h)

Where do I put the value to adjust window message? 

SceneManager.scene.message_window.move(x, y, w, h)
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
XinChao, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.
 

XinChao

Veteran
Veteran
Joined
Jun 11, 2012
Messages
117
Reaction score
3
Primarily Uses
I made the second post 4 hours after the previous one pal. Look at the time I posted. Btw, thanks for the script.  I am using yours and it works.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Forum Rules said:
4. Do NOT post disruptively. This includes, but is not limited to, double posting (posting directly underneath yourself, this is only allowed if 72 hours have passed since your last post), ...
Glad the script works :)


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Last edited by a moderator:
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:

Forum statistics

Threads
105,854
Messages
1,017,004
Members
137,562
Latest member
tamedeathman
Top