ID:269326
 
=/
Could someone tell me how to do this? (Don't post the code, unless pseudo). I'm wondering how to make it so if a word drips off the line on to the next, it, well, won't, it'll just move to the next. =/
Create a function the seperates the text into individual words, then check the space left before putting a word up.
client/proc/map_text(T)
var/list/words=explode(T)
var
X=0;Y=0
for(word in words)
if(X+length(word)>max_chars_on_screen)
X=1
Y+=1
for(character in word)
place_character(character)

proc/explode(T)
var/list/L[0]
for(word in T)
L+=word
return L
Hell Ramen wrote:
=/
Could someone tell me how to do this? (Don't post the code, unless pseudo). I'm wondering how to make it so if a word drips off the line on to the next, it, well, won't, it'll just move to the next. =/

DmiFonts already supports this sort of functionality.

Lummox JR
In response to Loduwijk
Lummox: I checked Dmifonts, and as always, I can't understand your code. =/ So, I tried was Loduwijk said and came up with this:

proc
text2list(t)
var/list/l[0]
for(var/i=1 to length(t))
l+=copytext(t,i,i+1)
return l
textlist2wordlist(list/t)
var
list/g[0]
string
for(var/a in t)
if(a==" ")
g+=string
string=null
continue
string+=a
g+=string
return g
proc
showtext(mob/m,t)
var/client/c=m.client
if(!ismob(m)||!c)return
var
list
l=text2list(t)
g=textlist2wordlist(l)
for(var/obj/a in c.screen)
if(a.tag=="TextHUD")del(a)
var
sx=1
sy=21
k=1
for(var/a in l)
if(a==" ")k++
var/obj/h=new()
h.tag="TextHUD"
h.text="<font color=red bgcolor=#000001>[a]"
h.screen_loc="[sx],[sy]"
h.layer=TURF_LAYER**MOB_LAYER
c.screen+=h
sx++
if(sx+length(g[k])>21){sy--;sx=1}


The problem is, it's uber choppy and doesn't work. Like, if I did:
"Mickey Mouse, Mickey Mouse!" (I've listened to too many Disney songs today)

It'll come out as:
"Mickey Mouse, M
ickey Mouse!"

The only part I think I did wrong was checking g[k] over and over, but I can't think how to make it skip after the first time. Maybe an associative list?
In response to Hell Ramen
Hell Ramen wrote:
Lummox: I checked Dmifonts, and as always, I can't understand your code.

Uh, why would you have to? DmiFonts includes the routines to break up the text without you having to intervene. Tell it what to display and what sort of room it has to work with, and it'll build the icons for you.

Of course if you were trying to adapt this to some other sort of text-on-screen library, then duh, that's kind of across purposes. The routines for handling word breaks are not generic and were never intended to be.

Lummox JR
In response to Lummox JR
Well, I don't get how to use Dmifonts all together. >_>
I barely ever use libraries, the only ones I use are a few from Abyss, since I'm kinda' good in math and understand them now and how to use them. So, libraries really aren't my friend.
[edit]WillFit() isn't even used in the bubble :( Man
In response to Hell Ramen
Hell Ramen wrote:
Well, I don't get how to use Dmifonts all together. >_>

This is why it includes documentation.

I barely ever use libraries, the only ones I use are a few from Abyss, since I'm kinda' good in math and understand them now and how to use them. So, libraries really aren't my friend.
[edit]WillFit() isn't even used in the bubble :( Man

It's been a while since I checked those routines, but as I recall WillFit() isn't what you'd need for this purpose anyway; it's more of an internal affair.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
This is why it includes documentation.


Lummox JR

Those documentations are so easily understood by somebody who isn't a rocket scientist. >_>

=/
I'll tocuh up on this when I touch up more on the language itself.
Thanks so far Lummox&Loduwijk.