[Ace] Textbox height position

● ARCHIVED · READ-ONLY
Started by Pia Carrot 6 posts View original ↗
  1. Hi, I've been trying to move my textbox about 32 pixels away from the border in height, but with no success. I was able to edit the distance in width easily, but setting the y position value in Window_Message does nothing.

    class Window_Message < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(16, 0, 480, 150) self.z = 200 self.openness = 0 create_all_windows create_back_bitmap create_back_sprite clear_instance_variables end e5bd2f8cefe4b58029360cbea2e6576f.png

    If anyone could help me out with this I would be so grateful, I'm sure it's simple but I have been an XP user for years so VX Ace is very alien to me.

    I'm trying to get something like this:

    gfs_4826_2_12.jpg
  2. I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


    how are you setting the y value? By changing the arguments passed to super? Or by putting self.y = ??? after that call?
  3. First that you need to know(in case you haven't), the placement of window message in VXAce is dynamic, it can be changed place according to this:
    If you open event page in event command, then show text, there's an option for the user to decide the position of the window message.
    1. Top

    2. Middle
    3 Bottom.
    That's why editing y position value is not as easy as x value.

    This is the culprit :

    #-------------------------------------------------------------------------- # * Update Window Position #-------------------------------------------------------------------------- def update_placement @position = $game_message.position self.y = @position * (Graphics.height - height) / 2 @gold_window.y = y > 0 ? 0 : Graphics.height - @gold_window.height endThe system will update window message y value according to this @position = $game_message.position

    $game_message.position = 0 for if you choose Top in show text command
    $game_message.position = 1 for if you choose Middle in show text command
    $game_message.position = 2 for if you choose Bottom in show text command

    Now you know what you have to do right? Because I don't really know with what you want -__-a
    Please anybody can correct my if I'm wrong.
     
  4. I'm aware of the Top, Middle and Bottom commands, but what I am trying to do is move the textbox completely away from the border by a certain amount pixels, like so:

    gfs_4826_2_12.jpg
  5. Then is should be clearer to you, If you look at the code I post above, you should know that changing the y value will never get what you want, because every time for example if you choose bottom, then the y value will be Graphics.height - height(this is absolute) and the same goes for middle and top, what you want to do is edit the code above I give you and overwrite it in the window message section. Look again below

    #-------------------------------------------------------------------------- # * Update Window Position #-------------------------------------------------------------------------- def update_placement @position = $game_message.position self.y = @position * (Graphics.height - height) / 2 # <= this is the code that prevent you to get what you want @gold_window.y = y > 0 ? 0 : Graphics.height - @gold_window.height endlook at the code above. self.y = @position * (Graphics.height - height) / 2
    That is the code you must aware. @position value is determined by $game_message.position, which I had said above that it comes from Top = 0, Middle = 1, Bottom = 2.

    Spoiler
    Now for example you choose bottom at the show text, then
    @position value will be 2, now let's do the calculation here :

       self.y = @position * (Graphics.height - height) / 2
       self.y = 2 * (Graphics.height - height) / 2
       self.y = Graphics.height - height  #  <= This is what you get
    even if you change the y value or the window height, the position of the window message bottom border will still on the bottom screen.

    For the middle and Top is also same, Let's try Top
    @position value will be 0, now let's do the calculation here :

       self.y = @position * (Graphics.height - height) / 2
       self.y = 0 * (Graphics.height - height) / 2 <= this will result 0 because number 0 times whatever number will result in 0. 
       self.y = 0 #  <= This is what you get
     again, even if you change the y value or the window height, the position of the window message upper border will still on the upper top screen.

    Now do I need to try the middle ? I believe no..
    Let's just help you do this shall we?
    # Instructions# Place this below Materials, above Main Process. # Go to Editable Region and edit as your own wish.module PiaCarrot  module WindowMessage#-=-=-=-=-=-=-=-=-=-=-=-=# EDITABLE REGION#-=-=-=-=-=-=-=-=-=-=-=-=  # This for y coordinate when you choose upper  TOP_Y_COORDINATE = 10   # This for y coordinate when you choose middle  MIDDLE_Y_COORDINATE = 200     # This for y coordinate when you choose bottom  BOTTOM_Y_COORDINATE = Graphics.height - 10 - (4 * 24 + 24)   # Graphics.height - 10 - (4 * 24 + 24)  # number four is how many line number in your window message.#-=-=-=-=-=-=-=-=-=-=-=-=# EDITABLE REGION END !#-=-=-=-=-=-=-=-=-=-=-=-=  endend class Window_Message < Window_Base  #--------------------------------------------------------------------------  # * Update Window Position  #--------------------------------------------------------------------------  def update_placement     @position = $game_message.position    case @position      when 0        self.y = PiaCarrot::WindowMessage::TOP_Y_COORDINATE      when 1        self.y = PiaCarrot::WindowMessage::MIDDLE_Y_COORDINATE      when 2        self.y = PiaCarrot::WindowMessage::BOTTOM_Y_COORDINATE    end     @gold_window.y = y > 0 ? 0 : Graphics.height - @gold_window.height   end   end # End of class Window_Message Edit the window y coordinate at the Editable Region, this should do what you want.
  6. Ah, I understand now. Thanks a ton, seems to be working just fine now. Yeah, math has never been my forte so I've always just messed with code randomly and hoped that it works xD