[XP] How do I trim Ccoa’s UMS gap?

Discussion in 'RGSSx Script Support' started by callmedan, Sep 13, 2019.

    Tags:
  1. callmedan

    callmedan Friendly Stranger Veteran

    Messages:
    562
    Likes Received:
    875
    Location:
    i'm behind you . . .
    First Language:
    Vietnamese
    Primarily Uses:
    RMXP
    When I use a command of the script, it will leave a gap at the end of the message line. The more command you use, the bigger the gap will get. It’s okay in normal window mode, but it’s not cool in FIT_WINDOW_TO_TEXT mode in my opinion.
    Is it possible to trim the gap and how do I do that?

    Ccoa’ Universal Message System

    Edit: The script commands may help sometimes. But there's some cases event codes can't be replaced by script commands, like drawing item into the message.
    For example:
    Code:
    Show Text: You received \oi[1] and \oa[50].
     
    Last edited: Sep 14, 2019
    #1
  2. slimmmeiske2

    slimmmeiske2 Little Red Riding Hood Moderator

    Messages:
    5,531
    Likes Received:
    4,121
    Location:
    Belgium
    First Language:
    Dutch
    Primarily Uses:
    RMXP
    What I do when I have too many commands is to use the Script commands instead of the event codes. That way you don't have that gap anymore.
     
    #2
    callmedan likes this.
  3. callmedan

    callmedan Friendly Stranger Veteran

    Messages:
    562
    Likes Received:
    875
    Location:
    i'm behind you . . .
    First Language:
    Vietnamese
    Primarily Uses:
    RMXP
    @slimmmeiske2 Thank you! My bad, I should have mentioned it in the first post. There's something can't be replaced by the script commands like drawing items into message.
     
    #3
  4. DerVVulfman

    DerVVulfman Resident Werewolf Veteran

    Messages:
    301
    Likes Received:
    147
    First Language:
    English
    Primarily Uses:
    RMXP
    I'm glad that you are familiar with the 'Shortcut' system that ccoa introduced into her system. At least that issue is covered. Your issue with ccoa's UMS is the same that would befall anyone with such codes in their custom menu system.

    Though you may not realize this, but the 'codes' are likely not functioning because you are surrounding your shortcut-text with double-quotes (ie " ). Attempt to use single quotes (ie ' ) and your \oi[1] and \oa[50] will be visible.

    And if your message has need of quotes in the message (ie: There's something afoot. ), you have custom codes you're not aware of. ( ie = 'There\'s something afoot.'). \' generates (').

    The \n command for line breaks only works if text is in double quotes. BUT, you can mix and match. Example:
    Code:
    $game_temp.message_text =
    'You found a \oa[1], \oi[1],'+"\n" +
    'and \ow[1]! \"Hahaha\".'
    I placed this in ccoa's UMS demo right in the top-right 'CHEST' event. And as long as the only thing in doublequotes is the line break code, it broke to the next line where I wished.

    HOWEVER, if I made the following code:
    Code:
    $game_temp.message_text =
    'You found a \oa[1], \oi[1],'+
    'and \ow[1]! \"Hahaha\".'
    .... you may be pleasantly surprised that there's not enough horizontal space! It makes the text one long line!
     
    #4
    callmedan likes this.
  5. Sixth

    Sixth Veteran Veteran

    Messages:
    2,130
    Likes Received:
    798
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    That is most probably because the script's author made a common mistake in these type of scripts, getting the text's width without removing the message codes first.
    Depending on what the message code does, it will make small or big errors in the width calculation.

    The only way of reliably getting the real width with message codes is to clone the text, process it character by character, and keep track of the width after each character/special message code, just like the draw_text_ex method does. This is why many scripts just make the text go through with draw_text_ex and add in a variable that will store the final width of the text even after the drawing, or they simply draw it in a dummy window, get the width from there, and copy the contents of the dummy window to the real window using the recorded width in the positioning.

    Fixing this would probably mean the complete rewrite of this section of that script. Simply using the text_width method on the complete original text won't help here, and I assume that is what has been done there. But can't be for sure, because you didn't give us the link to the script in question.
     
    #5
    callmedan likes this.
  6. callmedan

    callmedan Friendly Stranger Veteran

    Messages:
    562
    Likes Received:
    875
    Location:
    i'm behind you . . .
    First Language:
    Vietnamese
    Primarily Uses:
    RMXP
    @DerVVulfman Oops, I didn’t notice I could draw message with code like that. I should read the document again.
    @Sixth My bad, I just added a link to the script in the first post.
     
    #6

Share This Page