I'm trying to split text up properly based on the length of the dialog/text.
I'm looking for a means to "skip" to the next available space, period or comma then start the next line, OR simply go back a few spaces and push the entire word onto the next line.
In other words I'm not really looking for a delimiter or wanting to place a delimiter system n at this point, what I'm looking for rather is a way to cleanly break the text into lines by checking for " " or "," or "." once the length has reached or neared a certain point.
Example:
"The shelter from the wind seemed inade
quate as the temperature dropped into ar
tic levels." <--what i have.
"The shelter from the wind seemed
inadequate as the temperature dropped into
artic levels." <--what i want
What I use thus far:
CutLines(msg,cl=rgb(200,100,100))
var/x=1
var/begin=1
var/space=28
var/end=space
var/gm=max(1,round(length(msg)/space))
if(length(msg)>space)
var/a=round(length(msg)/space)
var/re=length(msg)%space
gm=a
if(re>0)
gm++
for(x,x<=gm,x++)
var/mm=copytext(msg,begin,end+1)
AddLines(WriteLine(mm,cl))
begin+=space
end+=space
As for the best method of doing all this, I'm not entirely sure. It'd be idea if you could simply check the end of the chunk for a space, then descend every 2 characters until you find a space, and force-crop the text once you get to about the middle (because more then likely you've got yourself a massive word at this point).
Truth be told, I've always been terrible at explaining things, and that's not likely to change. With that said, here's a bit of functioning script (at least I think it is, just wrote it up):
Above code output:
I know it's poor tutoring to just hand someone the answers, so I tried to explain what I felt needed explaining. So, hopefully this helps, and is what you were asking for.
*EDIT* I changed the script I provided because I realized it didn't check to make sure a space even existed in the chunk (meaning it would run the for() loop no matter what). Honestly, I'm torn as to whether it would be more idea to do the method I've provided, or more idea to parse through your spaces until you hit one that is too far out, then fall back onto the last one found.
Hopefully, someone else will come along and give some more insight into this dilemma.