This function will write a string letter by letter to the screen.
The parameters are:
writeText( pos x, pos y, string$, wait-time[1 to 100])
sync on : sync rate 60
writeText(10,10,"Hello, my name is Zotoaster",50)
wait key
end
`Functions
function writeText(x,y,text$,wtime#)
repeat
inc curi#,wtime#/100
oldcur=ncur
ncur=int(curi#)
if oldcur<>ncur then cur=ncur else cur=0
cur$=mid$(text$,cur)
pos=pos+text width(mid$(text$,cur-1))
text x+pos,y,cur$
sync
until cur>len(text$)
endfunction
[edit]
Actually, it's not that much use as it is (well it is kinda) but it's a bugger to do multiple lines. Here's a slightly better version, just put a | wherever you want a new line, and it will go to a new line
sync on : sync rate 60
writeText(10,10,"Hello, my name is Zotoaster|This is my writeText function in action|Use it as you wish|No need for credit|It's only a simple function|I'm not that greedy|:)",20)
wait key
end
`Functions
function writeText(x,y,text$,wtime#)
repeat
inc curi#,wtime#/100
oldcur=ncur
ncur=int(curi#)
if oldcur<>ncur then cur=ncur else cur=0
cur$=mid$(text$,cur)
if cur$<>"|" then posx=posx+text width(mid$(text$,cur-1))
if cur$="|" then posx=-text width(mid$(text$,cur-1)) : posy=posy+text height(cur$)
if cur$<>"|" then text x+posx,y+posy,cur$
sync
until cur>len(text$)
endfunction
[edit]
If you put this bit in too, it will randomize the wait between each letter, making it appear like someone is typing it
string$="Hello, my name is Zotoaster|This is my writeText function in action|Use it as you wish|No need for credit|It's only a simple function|I'm not that greedy|:)"
for l=1 to len(string$)
writeText(10,10,string$,rnd(10)+15)
next l