Text in bubble or box

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

    Kapitán

    2346 Posts


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

    Čestný člen

    321 Posts

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

    Imperátor

    7285 Posts

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

    Kapitán

    2346 Posts

  • #24, z Simon_ASATuesday, 27. September 2016, 19:03 hodinky 8 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?

    Čestný člen

    321 Posts

  • #25, z afrlmeTuesday, 27. September 2016, 20:03 hodinky 8 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
    

    Imperátor

    7285 Posts

  • #26, z sebastianWednesday, 28. September 2016, 11:23 hodinky 8 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.

    Kapitán

    2346 Posts

  • #27, z Simon_ASAWednesday, 28. September 2016, 11:34 hodinky 8 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?

    Čestný člen

    321 Posts

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

    game:setValue(VFontLineWidth, 190)
    


    Or you can try

    game.FontLineWidth = 190
    

    Zabiják klíčů

    810 Posts

  • #29, z afrlmeWednesday, 28. September 2016, 12:15 hodinky 8 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
    

    ... 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.

    Imperátor

    7285 Posts

  • #30, z Simon_ASAWednesday, 28. September 2016, 12:34 hodinky 8 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.

    Čestný člen

    321 Posts