Questions to text output

  • #1, by LebosteinWednesday, 11. February 2015, 12:09 9 years ago
    I have two questions about the beautification of the text output:

    a) It is possible to define a text padding of some pixels? At the moment the text starts at the edge of the screen if the character is near the image border. That looks not balanced...
    b) How I can define the vertical distance/offset between text and character? I suspect the distance is related to the sprite height? I need some space on top of my character for some animations (much more space than my scribbled test character on the screenshot) and now the text output is to high. Maybe there is a simple offset parameter I 've overlooked?

    https://dl.dropboxusercontent.com/u/13472834/visionaire/textoutput.png

    Key Killer

    621 Posts


  • #2, by afrlmeWednesday, 11. February 2015, 12:18 9 years ago
    Well no, but you can use the hook function "textPosition" to offset or position the text anywhere you like.

    http://wiki.visionaire-tracker.net/wiki/RegisterHookFunction

    In VS 4.x you could modify example 1 by getting the sprite position of the character instead of the characters position & then subtracting x pixels from the y value, which would allow you to control offset above the characters head.

    If you want more control I do recommend fixing the displayed texts into a bounding box / section at the top or bottom of the screen instead as it's much neater & often easier to read than text floating above characters heads.

    Imperator

    7278 Posts

  • #3, by LebosteinWednesday, 11. February 2015, 16:12 9 years ago
    OK. Thank you.

    But the distance between text and characters head should be a simple to edit parameter inside the character definition: "Y-Offset of text output" or like that. I think many users would change/customize this. Maybe one day it will added to the editor....

    Key Killer

    621 Posts

  • #4, by afrlmeWednesday, 11. February 2015, 16:16 9 years ago
    Aye maybe. I guess Simon might add some more display text options at some point. He said he wants to overhaul it, but he wasn't sure exactly how, or in what way, yet.

    Imperator

    7278 Posts

  • #5, by LebosteinMonday, 16. February 2015, 22:43 9 years ago
    To modify the text position via lua script I need the size (width and height) of the text box with the current text and the character height. How I get it?

    Key Killer

    621 Posts

  • #6, by afrlmeMonday, 16. February 2015, 23:14 9 years ago
    no idea about the text box. I believe you can return the position of the top left pixel of the sprite with the new getPosition() function. See here for more information & an example of getPosition() in use.

    Imperator

    7278 Posts

  • #7, by LebosteinTuesday, 17. February 2015, 07:23 9 years ago
    Then it is impossible to write a function that generates a margin around the text... and it is impossible to modify the y-position of spoken text only. If I overwrite the "setTextPosition" function, I can not only modify the y-position like the example in the wiki. With that example I destroy the automatic x-position correction at the edges of the screen. For that correction I need informations about the width (and height) of the text output.

    Here the code from the wiki:
    function adaptedTextPosition(text)
      -- show texts of character Hero 10 pixel below character position
      local owner = text:getLink(VTextOwner)
      if owner:getId().tableId == eCharacters and owner:getName() == 'Hero' then
        local pos = owner:getPoint(VCharacterPosition)
        pos.y = pos.y + 10
        text:setValue(VTextPosition, pos)
        return true
      end
      return false
    end
     
    registerHookFunction("setTextPosition", "adaptedTextPosition")
    

    Key Killer

    621 Posts

  • #8, by afrlmeTuesday, 17. February 2015, 12:31 9 years ago
    Well I'm not sure you can return the width / height of the text itself. Why I recommend forcing all text into the center of a bounding box at the bottom or top of the screen, as it's much cleaner.

    I think your game would probably look nice with speech bubbles (based on the artwork in the screenshot you provided). You could do them manually by creating each displayed text as an image or by wrapping the max-width of the text via it's properties tab & then using Lua script to place the required speech bubble image behind the text; although the latter is certainly the most complicated approach to this.

    Imperator

    7278 Posts

  • #9, by LebosteinTuesday, 17. February 2015, 12:46 9 years ago
    by wrapping the max-width of the text via it's properties tab

    That is what I asked. I need the width of the current text. And if I don't get this value, speech bubbles are also impossible to handle.... to write a parametric speech bubble routine, I need the width and the height (or number of lines) of the printed text as well

    Key Killer

    621 Posts

  • #10, by afrlmeTuesday, 17. February 2015, 12:54 9 years ago
    http://wiki.visionaire-tracker.net/wiki/Data_Structure#Activ...
    http://wiki.visionaire-tracker.net/wiki/Data_Structure#Font

    As you can see there are no fields returning the current width of the displayed text. You can force all text being displayed by a specific font to only allowed to be x width in pixels before it automatically generates line breaks, other than that I have no idea what to tell you.

    Imperator

    7278 Posts