Moving comment set text position away from character?

  • #1, by RadicaaSunday, 15. February 2015, 00:33 6 years ago
    Hey, just a quick question I guess. In our game the MC never speaks and the exposition is always displayed as narration text rather than characther text. Comment sets however always place the text above the character. Is there any way to change the position of the comment set text? (perhaps with Lua?)

    Thanks

    Newbie

    25 Posts


  • #2, by afrlmeSunday, 15. February 2015, 11:34 6 years ago
    I'm not really sure you can just force comment set text away from a character. You can reposition all text spoken by the character &/or narration text though...

    Just use the registerHookFunction with the textPosition hook.

    local offset = 34 -- offset from bottom (in pixels)
    local x = (game.WindowResolution.x / 2) -- calculate center value of resolution width
    local y = (game.WindowResolution.y - offset) -- calculate offset of text from bottom

    function txtPos(text)
    text:setValue(VTextPosition, {x = game.ScrollPosition.x + x, y = game.ScrollPosition.y + y})
    return true
    end

    registerHookFunction("setTextPosition", "txtPos")
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11

    ...this script will automatically set the text to the bottom-center of the screen. Adjust offset to adjust distance from the bottom.

    Imperator

    6842 Posts

  • #3, by RadicaaSunday, 15. February 2015, 17:23 6 years ago
    Thank you very much. I'll try it.

    Newbie

    25 Posts

  • #4, by RadicaaMonday, 16. February 2015, 19:27 6 years ago
    Well, it works but now all text, including NPC:s text is moved to the narration position. Is there anyway to tell the script only to position the text of the main character in this manner?

    Newbie

    25 Posts

  • #5, by afrlmeMonday, 16. February 2015, 19:51 6 years ago
    Indeed. You can query the textOwner.

    local offset = 34 -- offset from bottom (in pixels)
    local x = (game.WindowResolution.x / 2) -- calculate center value of resolution width
    local y = (game.WindowResolution.y - offset) -- calculate offset of text from bottom

    function txtPos(text)
    if text:getLink(VTextOwner):getName() == game.CurrentCharacter:getName() then
    text:setValue(VTextPosition, {x = game.ScrollPosition.x + x, y = game.ScrollPosition.y + y})
    return true
    end
    end

    registerHookFunction("setTextPosition", "txtPos")
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13

    Imperator

    6842 Posts

  • #6, by RadicaaMonday, 16. February 2015, 21:47 6 years ago
    Nice. I guess I have to enter the character name into the getName() part? or is the part "game.CurrentCharacter:getName ()" already assigning it to the main character?

    Newbie

    25 Posts

  • #7, by afrlmeMonday, 16. February 2015, 22:14 6 years ago
    game.CurrentCharacter:getName() is automatically returning the string name of the current character. So if the string name of the text owner is the string name of current character it will reposition the text, otherwise it will ignore the text.

    P.S: I messed up the script a little previously. I've updated the block with the correct code.

    Imperator

    6842 Posts

  • #8, by RadicaaMonday, 16. February 2015, 22:16 6 years ago
    Alright, thanks again. What the world do without AFRLme? grin

    Newbie

    25 Posts

  • #9, by afrlmeMonday, 16. February 2015, 22:18 6 years ago
    No idea? In the case of the online world regarding VS... probably curl up into a little ball & cry. In the case of the real world... carry on as per usual, most likely. grin

    Imperator

    6842 Posts

Write post