DE EN FR ES IT CZ
Zurück Nach oben

Displaying Character Name along with Dialog

  • #1, by mikael32225 10 years ago Zitieren
    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.


  • #2, by sebastian 10 years ago Zitieren
    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? 
  • #3, by mikael32225 10 years ago Zitieren
    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?
  • #4, by sebastian 10 years ago Zitieren
    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)
    
    untested. 
    im not sure about that /n here.. maybe you need a normal html < br > tag... 
  • #5, by SimonS 10 years ago Zitieren
    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")
  • #6, by mikael32225 10 years ago Zitieren
    Simon, is your suggestion a separate script or should it still be combined with the positioning script?
  • #7, by sebastian 10 years ago Zitieren
    just add it under the existing script under the registerhookfunction smile 
  • #8, by SimonS 10 years ago Zitieren
    It's seperate.
  • #9, by mikael32225 10 years ago Zitieren
    Nothing seems to be happining. Tried both adding it below the positioning script and in a separate script.
  • #10, by mikael32225 10 years ago Zitieren
    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.


  • #11, by afrlme 10 years ago Zitieren
    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")