Displaying Character Name along with Dialog

  • #1, by mikael32225Monday, 10. July 2017, 10:23 3 years ago
    I display all my dialog in the same area, as if watching a subtitled film, but I worry about the player missing who is doing the talking.

    Is there an easy way to display the name of the character talking?

    I basically want dialog to look like this:

                             SAM
    Hi, my name is Sam and I'm talking.


    Newbie

    42 Posts


  • #2, by sebastianMonday, 10. July 2017, 10:34 3 years ago
    the easiest way would be to write that name also in the display text action part as the first line. 
    Also im pretty sure you could enhance the Lua script youbuse to reposition the display text by adding the characters Name in feont of it... 

    what scriot did you use here? 

    Thread Captain

    2337 Posts

  • #3, by mikael32225Monday, 10. July 2017, 11:18 3 years ago
    I'm using the basic script that you pointed me to in another thread:

    -- let's create the function which sets the position of displayed text
    function setTextPosHook(text)
     -- if text owner is a character then...
     if text:getLink(VTextOwner):getId().tableId == eCharacters then
      text:setValue(VTextPosition, {x=630, y=625})
      return true
     end
    end
     
    -- let's create the event listener for handling position of displayed text
    registerHookFunction("setTextPosition", "setTextPosHook")
    I'm not very good with Lua yet, would it just be something like adding a print command?

    Newbie

    42 Posts

  • #4, by sebastianMonday, 10. July 2017, 11:32 3 years ago
    try to add these lines after or before the new position line'

    newtext = text:getLink(VTextOwner):getTextStr(VCharacterName).. "/n".. text:getTextStr(VTextCurrentText)

    text:setValue(VTextCurrentText, newtext)
    1
    2
    3
    4
    untested. 
    im not sure about that /n here.. maybe you need a normal html < br > tag... 

    Thread Captain

    2337 Posts

  • #5, by SimonSMonday, 10. July 2017, 12:16 3 years ago
    If you want to change the text, you need to use the textText Hook, looks like the rest.

    function text( obj )
      return obj.Owner.name .. "\n" .. obj.CurrentText
    end

    registerHookFunction("textText", "text")

    Thread Captain

    1380 Posts

  • #6, by mikael32225Monday, 10. July 2017, 12:40 3 years ago
    Simon, is your suggestion a separate script or should it still be combined with the positioning script?

    Newbie

    42 Posts

  • #7, by sebastianMonday, 10. July 2017, 12:42 3 years ago
    just add it under the existing script under the registerhookfunction smile 

    Thread Captain

    2337 Posts

  • #8, by SimonSMonday, 10. July 2017, 12:45 3 years ago
    It's seperate.

    Thread Captain

    1380 Posts

  • #9, by mikael32225Monday, 10. July 2017, 12:51 3 years ago
    Nothing seems to be happining. Tried both adding it below the positioning script and in a separate script.

    Newbie

    42 Posts

  • #10, by mikael32225Monday, 10. July 2017, 13:07 3 years ago
    This is what it looks like now:

    -- let's create the function which sets the position of displayed text
    function setTextPosHook(text)
     -- if text owner is a character then...
     if text:getLink(VTextOwner):getId().tableId == eCharacters then
      text:setValue(VTextPosition, {x=630, y=625})
      return true
     end
    end

    -- let's create the event listener for handling position of displayed text
    registerHookFunction("setTextPosition", "setTextPosHook")


    -- adding character name to dialog
    function text( obj )
      return obj.Owner.name .. "\n" .. obj.CurrentText
    end

    registerHookFunction("textText", "text")


    There is nothing that indicates any change. For instance the linebreak doesn't show up either. It's like it wasn't there at all.


    Newbie

    42 Posts

  • #11, by afrlmeMonday, 10. July 2017, 13:18 3 years ago
    I'm pretty sure you can't add line breaks into the text.

    Anyway, it won't do anything as you need to manually call the text function. It's not automatic.

    -- let's create the function which sets the position of displayed text
    function setTextPosHook(text)
     -- if text owner is a character then...
     if text:getLink(VTextOwner):getId().tableId == eCharacters then
      text:setValue(VTextPosition, {x=630, y=625})
      txt(game.CurrentCharacter)
      return true
     end
    end

    -- let's create the event listener for handling position of displayed text
    registerHookFunction("setTextPosition", "setTextPosHook")


    -- adding character name to dialog
    function txt(obj)
      return obj.Owner:getName() .. ": " .. obj.CurrentText
    end

    registerHookFunction("textText", "txt")
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21

    Imperator

    6846 Posts

Write post