Text in bubble or box

  • #20, by sebastianTuesday, 27. September 2016, 17:55 4 years ago
    should be right.
    if text = "teststring" then TextCount should be 10

    Thread Captain

    2336 Posts


  • #21, by Simon_ASATuesday, 27. September 2016, 18:18 4 years ago
    Mmh that's what I thought. So the problem must be elsewhere.
    Thanks a lot Seb!

    Great Poster

    321 Posts

  • #22, by afrlmeTuesday, 27. September 2016, 18:56 4 years ago
    Are you trying to access the local variable you created outside of the script, function or loop block it's in?

    Imperator

    6815 Posts

  • #23, by sebastianTuesday, 27. September 2016, 19:02 4 years ago
    if yes to afrlme's question, make it global by removing the "local"

    Thread Captain

    2336 Posts

  • #24, by Simon_ASATuesday, 27. September 2016, 19:03 4 years ago
    AFRLme: You said I have to use it inside of a registerEventHandler("textStarted")
    and that's what I'm trying to do, but I don't understand well the purpose.

    Seb: no I have already tried this, no success roll

    string.len(text) -> does it return an integer?

    Great Poster

    321 Posts

  • #25, by afrlmeTuesday, 27. September 2016, 20:03 4 years ago
    Yes, string.len should return an integer value.

    As for textStarted & textStopped, they are basically loops dedicated to listening out for when a display text or narration text is started or ends. You can check the owner of the text to see if it's from a specific character or from a character in general or if it's narration text - not sure if it listens out for object texts.
    -- * function that listens out for text (display, narration) started * --
    function txtStart(text)
    game.CurrentScene:to(100, {MusicVolume = (Values["v_temp-vol"].Int - 10)}) -- ignore this line, I am using it to dip music volume when characters speak.
    print( text.TextCurrentText, string.len(text.TextCurrentText) ) -- printing the string value of the text & the length to log.
    end

    registerEventHandler("textStarted", "txtStart") -- define event listener for handling text started
    1
    2
    3
    4
    5
    6
    7
    8

    Imperator

    6815 Posts

  • #26, by sebastianWednesday, 28. September 2016, 11:23 4 years ago
    wow that idea with turning the music down is great =)

    @Simon :
    inside the txtstarted function you can check the length and regarding to this set a condition or value to true/a number which activates a different design(height) for the bubble in the interface.

    Thread Captain

    2336 Posts

  • #27, by Simon_ASAWednesday, 28. September 2016, 11:34 4 years ago
    Thanks to both of you I think I succeeded to manage the length of text /bubble size.

    I still have an issue however: I need to change the line break width depending on the size of each bubble.
    I have 3 bubble size: small, medium and large. The small one is 320 pixels large, so the width of the text shouldn't exceed 300 pixels. But this value is different for the other bubble sizes...

    I have tried this without success:
    game:setValue(FontLineWidth, 190)

    Wrong syntax?

    Great Poster

    321 Posts

  • #28, by ke4Wednesday, 28. September 2016, 11:45 4 years ago
    I guess it needs to be with the V at the beginning.

    game:setValue(VFontLineWidth, 190)
    1
    2


    Or you can try

    game.FontLineWidth = 190
    1
    2

    Key Killer

    810 Posts

  • #29, by afrlmeWednesday, 28. September 2016, 12:15 4 years ago
    Aye, Ke4 is correct. If you plan on accessing / updating data structure values with the old getObject method then you need to include a V at the beginning of the data structure field name, like so... VCurrentCharacter, VFontLineWidth, VCurrentScene, etc.

    Even though the shorthand isn't documented, because there's multiple ways for accessing most of the data structure fields with it. Sometimes you can get away with shortening the data structure names & sometimes you have to type them out in full, for example...
    game.CurrentCharacter.Position -- instead of
    game.GameCurrentCharacter.CharacterPosition
    1
    2
    3

    ... though as you've seen, sometimes you have to use the full field name, like the TextCurrentText one I ammended after text to access the currently displayed text for the active text. text.CurrentText didn't seem to work. I didn't try text.Text though, so no idea if that works.

    Imperator

    6815 Posts

  • #30, by Simon_ASAWednesday, 28. September 2016, 12:34 4 years ago
    Oh ok, thanks. Where does this "V" come from?
    Is it the V or S from the storage column on the data structure page?

    Despite using the correct syntax now, the line break still doesn't work. It still uses the 400 pixels defined in the font (in the font editor), and doesn't update to 190 pixels with the code:
    game:setValue(VFontLineWidth, 190)

    I guess this code has to be called before the text is displayed, which doesn't seem to be the case with my script. I'll try to find what's wrong this afternoon.

    Great Poster

    321 Posts

Write post