How can I display text / chat / subtitles at the bottom of the screen?

  • #1, by lefooshWednesday, 21. January 2015, 01:07 6 years ago
    Hey all,

    Long time no speak! I was just wondering how I can have my characters chat content display at the bottom of the screen like Broken Age.

    Hopefully there's a way of doing this without scripting...?

    Thanks,

    Kris

    Newbie

    77 Posts


  • #2, by afrlmeWednesday, 21. January 2015, 01:41 6 years ago
    A'llo Kris grin

    Have you swapped back to using VS for Jason the Greek?

    I'm afraid it requires a little scripting but it's only a small hook function that needs writing & adding as a definition script. It will do the rest itself.

    Here you go... (it should work, although I've not tested it). Just change the offset value to suit.
    local offset = 100 -- offset from bottom (in pixels)

    function txtPos(text)
    if text:getLink(VTextOwner):getId().tableId == eCharacters then
    text:setValue(VTextPositon, { x = (game.WindowResolution.x / 2), y = (game.WindowResolution.y - offset) })
    return true
    end
    return false
    end

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

    Imperator

    6846 Posts

  • #3, by lefooshWednesday, 21. January 2015, 11:47 6 years ago
    I'm running a test this week, let's see how we go...

    Small scripting sounds about my limit, I've not done any scripting yet in vis but I've done a fair amount of lua in the past so hopefully this'll all come together.

    I know I need to make more time for coding - are there any scripting tutorials out there at all?

    Appreciate the help as always,

    Kris

    Newbie

    77 Posts

  • #4, by afrlmeWednesday, 21. January 2015, 13:15 6 years ago
    I've actually started rewriting / editing the scripting page & the data structure pages this week. I'm about 60% done for the scripting page. I've been editing the text, reformatting the page so it's easier to read & have been adding examples to the different command / functions.

    As for the data structure page: I've rewritten it a little bit & I've implemented a fancy tooltip so that when you hover over any [?] symbols it will slide in an example of how to call/read the data structure table. It doesn't provide how to set, but it does provide an idea of how the code is written. I've only sorted out the character table so far, as I was just testing the tooltip code.

    There's also my beginners guide to Lua script tutorial available on the wiki, although it's not finished yet but I've managed to write up a few sections already. wink

    Imperator

    6846 Posts

  • #5, by lefooshWednesday, 21. January 2015, 14:39 6 years ago
    I honestly think you might be the hardest working man in games...

    Can I get a link or two to the pages? Would be great to hook this up today!

    Newbie

    77 Posts

  • #6, by afrlmeWednesday, 21. January 2015, 14:47 6 years ago
    Go to script tab. Create new script. Paste the code I provided above into it & Bob's your uncle (or maybe he's not, but it's just an expression, so who cares). smile



    Pretty much all relevant links to scripting in Visionaire Studio.

    Imperator

    6846 Posts

  • #7, by lefooshWednesday, 21. January 2015, 22:17 6 years ago
    Thanks for the links and for the directions - I did exactly that but sadly no unexpected relatives arrived...

    Not sure if I'm doing something wrong - will this work for any spoken text or is it just going to work with dialogue?

    Thanks for all your help , really appreciate it!

    Newbie

    77 Posts

  • #8, by afrlmeWednesday, 21. January 2015, 23:11 6 years ago
    Sorry mate, my bad. Was some typo mistakes in it.


    This will affect both character spoken texts & narration texts.
    local offset = 100 -- 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


    If you don't want it to affect displayed text then just let me know.

    Imperator

    6846 Posts

  • #9, by lefooshThursday, 22. January 2015, 00:22 6 years ago
    Awesome, as ever. Added in and does indeed work like a charm.

    My next and possibly last question on the subject - how can i put a transparent black background on that to help the text stand out...?

    I know, i want the moon on a stick!

    Newbie

    77 Posts

  • #10, by afrlmeThursday, 22. January 2015, 00:36 6 years ago
    Well there's two methods you could use here:

    1. more scripting!. razz
    1b. more scripting! grin
    1c. Ok this method would involve creating a small event listener function which listens out for text started & text stopped, which could be used to show/hide an interface (or scene object) containing the background image, as needed. My only issue with this method is that it will keep toggling the background on & off when changing between different display text actions parts.

    2. Same as above but without any scripting. Create a scene object (each scene) or a single interface that will contain the background image for the displayed text. The next part will require a little work but it gives you absolute control of when it should or should not be displayed. As simple as using an action part to show/hide the interface or scene object, as needed. This way you could have it open without closing until you are ready to close/hide it.

    In the upcoming release, interfaces will be allowed to stay visible during cut-scenes so I recommend adding the image into an interface, as it saves messing about creating a scene object for each scene.

    ----

    Are you sure you don't want a slice of cheese instead?

    Imperator

    6846 Posts

  • #11, by lefooshThursday, 22. January 2015, 21:45 6 years ago
    Would love a slice of cheese, thanks!

    Trying to do your option 2 as that makes sense to me: basically turn on the interface when text appears, turn off after. It's a bit of a pain but soon it'll just be a copy/paste job.

    Thanks again!

    Newbie

    77 Posts

Write post