Dialogue box question

  • #1, by redskyburnsFriday, 20. March, 10:37 5 months ago
          Hey all -  I set my dialogue area up with a portrait of the main character, and a rectangle attached to the side of it to frame the text of discussions.   I set the dialogue area of the npc's in the same fashion.   So of course my main characters initial statement looks great, but then the NPC reposnse is floating in the scene without his portrait/text frame, and my characters response to them then shows up without the portrait/text frame from the initial statement either.    Clearly I took the wrong approach.
        Is there a way to set things up  where the portraits (with speech animations) and text frames to remain  throughout the conversations?  Or the portraits going back and forth as the conversations are exchanged?

    Thank you kindly*

    Newbie

    8 Posts


  • #2, by esmeraldaFriday, 20. March, 17:33 5 months ago
    In the dialogue area the dialogue choises are displayed, not the spoken text.
    You need only the dialogue area of the main character for that. (or for every playable character if you have more than one)

    What you want to do can be done with interfaces.

    or with lua

    here is a thread about it

    Great Poster

    385 Posts

  • #3, by redskyburnsFriday, 20. March, 22:54 5 months ago
    Thank you Esmeralda!   I will dive into that thread.

    Newbie

    8 Posts

  • #4, by redskyburnsSaturday, 21. March, 09:37 5 months ago
    I have a question that delves into some basic elements, after searching about on the forum, am still at bit of a loss.   I  had no problem creating my custom dialogue boxes as their own interface, and know that I can use conditions (or values, but I'd like to keep it simple with conditions at the moment) to bring up the new interface...  That said I am at a loss at how to do so.    I understand the concept, but not how to execute it.   Clearly I have no Lua experience, so would like to stick with work arounds through interfaces in the basic Visionare Studio 5 workspace.  And I have watched through some conditions tutorials, but only those on basic items, not controling interfaces.  Appreciate any  input or simply a link to a feed that talks about controling various interfaces through conditions (I'll keep searching for one!).   May be a long shot, but thank you kindly for any input!

    Newbie

    8 Posts

  • #5, by afrlmeSaturday, 21. March, 12:12 5 months ago
    I would recommend using Lua script & specifically the event handlers for textStarted & textStopped, why? because it will let you automate the whole thing instead of having to manually show/hide the interface & change conditions/values.

    Let's say you have created an interface & called it "dialog_portraits". You want to go into the properties for it & tick the "show interface permanently" option - this will allow the interface to be shown during cutscene events.

    Now assign the interface to your playable character via the "interfaces" tab.

    Next open up the main game settings section of the editor, & open up the "at begin start following action" as we need to add a line of code to hide the interface when the game starts. So create an execute a script action part & add this line of code to it.

    Interfaces["dialog_portraits"].Visible = false
    1

    Now open up the script section of the editor, & add this to it - edit it to suit your needs.

    -- * table to store character names & portrait_index value (case sensitive) * --
    local portraits = {

    ["Tom"] = 1,
    ["Barry"] = 2,
    ["Angela"] = 3

    }

    -- * text started event listener * --
    function sText(text)

    if text.Owner:getId().tableId == eCharacters then -- check text belongs to a character

    Interfaces["dialog_portraits"].Visible = true -- show the dialog_portraits interface
    Values["portrait_index"].Int = portraits[ text.Owner:getName() ] -- specify which character portrait to show

    end

    end

    -- * text finished event handler * --
    function eText(text)

    if text.Owner:getId().tableId == eCharacters then -- check text belongs to a character

    Values["portrait_index"].Int = -1 -- reset portrait_index value back to -1 to hide all portrait images
    Interfaces["dialog_portraits"].Visible = false -- hide the dialog_portraits interface

    end

    end

    -- * event handlers * --
    registerEventHandler("textStarted", "sText") -- event handler for begin text
    registerEventHandler("textStopped", "eText") -- event handler for end text
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36


    Now go to the dialog_portraits interface you created. Click on the "values" tab & create a new value & call it "portrait_index".

    Now you need to start creating buttons, 1 per character (rename each button so that it has the same name as the character) & start adding images or animations to each of them (add images to inactive image section if you plan on using static sprites instead of animations). If you plan on using animations then don't forget to set them as active in the properties section for the button. Also don't forget to set the button types to "action area". You also need to link the portrait_index value to each of the buttons you have created ( use operator type = ) & make sure they reflect what values you added inside of the "portraits" table in the script.

    What should happen is that whenever text is started it should show the dialog interface & update the value based on which character is talking, which should display the correct portrait image/animation. Then when text ends it should hide the interface & portrait image/animation.

    I know this is a massive wall of text, but I don't have any examples setup to screenshot/record, so this will have to do.

    Anyway, good luck. smile

    Imperator

    6817 Posts

  • #6, by redskyburnsSaturday, 21. March, 21:30 5 months ago
       Looks like it's time to roll up the sleeves and dig into this.   Thank you for the in depth response Afrlme!

    Newbie

    8 Posts

  • #7, by redskyburnsFriday, 27. March, 00:12 4 months ago
    By using the script Afrlme posted, I have the dialogue interface looking about how I would like it (Thank you!).    Basically the Main character portrait on the bottom left, with a black box/border next to it for text, and the NPC portrait on the top right, with a black box/border off to the left for text.  

    I found this script for placing text  which is great..

    -- 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=358, y=281})
      return true
     end
    end

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

    This basically is setting all of the conversation in one place.  Is there a simple way to alter this script to set the main characters dialogue to show in on area, and then another script for placing NPCs dialogue?     Also, how can I set boundaries for the dialogue text?   So it stays within the box/border I have for the characters text?   As now it just print's the entire dialogue all at once and blows past the box/border.

    I know this is a lot of questions here, thanks for any help -  Take care!

    Will

    Newbie

    8 Posts

  • #8, by afrlmeFriday, 27. March, 01:25 4 months ago
    You can enforce a max width limit to force linebreaks for each font. Enable automatic line break & then specify the width via max line width [pixel].

    You can modify the text position handler in the same way as the functions I gave you. add queries to them to check if text.Owner:getName() == "Tom", etc if you want to insert custom positions for each character, or you could insert them into a Lua table. There's multiple ways you could go about it.

    Anyway here's what you are asking for...

    function setTextPosHook(text)

    if text.Owner:getId().tableId == eCharacters then

    if text.Owner:getName() == game.CurrentCharacter:getName() then
    text.Position = { x = 358, y = 281}
    else -- text doesn't belong to current character
    text.Position = { x = 100, y = 100}
    end

    return true

    end

    end

    -- let's create the event listener for handling position of displayed text
    registerHookFunction("setTextPosition", "setTextPosHook")
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18

    Imperator

    6817 Posts

  • #9, by redskyburnsFriday, 27. March, 07:48 4 months ago
    Thanks Afrlme,   sorry for these basic questions!   I had been tinkering with it but was using the assigned  number not the names.    Thank you again.   I appreciate all the help, and the help you clearly give to so many on this forum.   I will try to further wrap my head around this to not have to ask such basic questions.   Thank you and take care.

    Newbie

    8 Posts

Write post