I would place the text above character in lua

  • #1, by wimfFriday, 09. February, 17:10 3 months 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})
        else
       text:setValue(VTextPosition, {x= game:getPoint(VGameWindowResolution).x/2, y= 850})
          end
    end
    return true
    end
    registerHookFunction("setTextPosition", "setTextPosHook")
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14



    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

    226 Posts


  • #2, by sebastianFriday, 09. February, 17:53 3 months 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

    2134 Posts

  • #3, by AFRLmeFriday, 09. February, 18:03 3 months 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.

    Imperator

    6001 Posts

  • #4, by wimfFriday, 09. February, 18:32 3 months 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

    226 Posts

Write post