Moving comment set text position away from character?

  • #1, by RadicaaSunday, 15. February 2015, 00:33 9 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 9 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")
    

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

    Imperator

    7278 Posts

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

    Newbie

    25 Posts

  • #4, by RadicaaMonday, 16. February 2015, 19:27 9 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 9 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")
    

    Imperator

    7278 Posts

  • #6, by RadicaaMonday, 16. February 2015, 21:47 9 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 9 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

    7278 Posts

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

    Newbie

    25 Posts

  • #9, by afrlmeMonday, 16. February 2015, 22:18 9 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

    7278 Posts