• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Subtitle for Cinematic acting Weird

Status
Not open for further replies.
Level 17
Joined
Dec 11, 2014
Messages
2,004
JASS:
function Talk takes string s, unit u, real dur, sound snd returns nothing
 local integer slength = StringLength(s)
 local integer i = GetUnitTypeId(u)
 local integer i2 = 0
 local integer i3 = 1
 local timer t = CreateTimer()
 local string news = "\n\n\n\n\n\n" + s + "\n\n\n\n\n\n\n\n\n\n\n\n"
  if slength > 50 then
   set i2 = R2I(I2R(slength) / 50)
    loop
     exitwhen i3 > i2
      set news = SubString(news, i3 - 1, i3 * 50) + "\n" + SubString(news, i3 * 50, slength)
     set i3 = i3 + 1
    endloop
  endif
    //native DisplayTimedTextToPlayer takes player toPlayer, real x, real y, real duration, string message returns nothing
    call DisplayTimedTextToPlayer(Player(0), 0.8, 0.1, dur, news)
    //native SetCinematicScene takes integer portraitUnitId, playercolor color, string speakerTitle, string text, real sceneDuration, real voiceoverDuration returns nothing
    call SetCinematicScene(i, PLAYER_COLOR_RED, null, null, dur, dur)
    //call TransmissionFromUnitWithNameBJ(GetPlayersAll(), u, null, snd, null, bj_TIMETYPE_SET, dur, false)
    call TimerStart(t, dur, false, function ClearTextMessage)
 set t = null
 set news = null
endfunction

This is one of my first tries on JASS, I'm still a Noob :D

Alright.

If I type in:
  • Custom script: call Talk("Gear Beard meh bleh feh da google addict :D I saw sb sbing sb lolz meh feh da sup :Der heh yoblow yubuslaviu cake i <3 it thralla w00t dat jury. Zoo!", gg_unit_H000_0012, 100.00, null)
(I Know this is rubbish; I changed it so that there wont be Spoilers)

It will return:

attachment.php


How can i fix it? As you see it seems a bit random, and instead of creating a Line Break in 50 letters, it's in 44-47 IIRC.

Any help is highly appreciated.
 

Attachments

  • Rubbish.jpg
    Rubbish.jpg
    37.7 KB · Views: 131
Sometimes it is easier to just restart. :p What exactly are you trying to do with your code? Perhaps we can give an example of how you should do it, and we can work from there. Substrings can get pretty confusing when you have a bunch of \n characters since those count as actual characters detected by the Substring function. If I were you, I would first split up the substring before adding the series of \n's before and after the string. The process just becomes so much easier.
 
Status
Not open for further replies.
Top