I would place the text above character in lua

  • #1, by wimfFriday, 09. February 2018, 17:10 6 years ago
    Currently, text when my character is speaking is set with the function setTextPosHook

    code :

    local txtP = getObject("Conditions[invopen]")
    function setTextPosHook(text)
     if text:getLink(VTextOwner):getId().tableId == eCharacters and text:getLink(VTextOwner):getName() == "Ben" then
    if txtP:getBool(VConditionValue) == true then
         text:setValue(VTextPosition, {x= game:getPoint(VGameWindowResolution).x/2, y= 700})
       text:setValue(VTextPosition, {x= game:getPoint(VGameWindowResolution).x/2, y= 850})
    return true
    registerHookFunction("setTextPosition", "setTextPosHook")

    But I will like this (script for VS5):

    That the text is placed each time above the character who speaks (as in deponia), so follow the movement of my character, and if the character is too far right or too much left, that the text is not truncated

    I am looking for several hours in lua but I can not find the solution.

    Thank you for your help

    Forum Fan

    238 Posts

  • #2, by sebastianFriday, 09. February 2018, 17:53 6 years ago
    Just dont use the script. That what you want is default for VS.
    You can also configure in your font the maximum line length. If the length is more than that number a next line will be used.

    Thread Captain

    2346 Posts

  • #3, by afrlmeFriday, 09. February 2018, 18:03 6 years ago
    Um.... the script in the function Daedalic used for Deponia is a lot of lines & if queries. Well over 100 lines with various if queries about x scene & y character & various other factors.

    Setting above the character requires a bit of math. First you need to check the positon of the talking character, then you need to offset on the y-axis based on the current scale percentage of the character, then you would need to offset on the x-axis based on your characters position from the left or right side of the scene. Personally I recommend using the standard display text system or creating a bounding box & displaying all text inside of that. Less hassle overall.


    7278 Posts

  • #4, by wimfFriday, 09. February 2018, 18:32 6 years ago
    Thank you both. When i delete my script, it work smile

    But I think to use a script as explained by AFRLme, because the function "Max.line with" is ok if I am in 1920x1080, but if I decreases the resolution, the line break is strange

    Forum Fan

    238 Posts