Looking at the printString function, we have:
function printString(stringV)
stringV = tostring(stringV)
lenght = string.len(stringV)
for i = 20,-lenght,-1 do
screen.setCursorPos(i, 1)
for j = 0,lenght do
printCar(i + j, 1, string.sub(stringV, j + 1, j + 1))
end
sleep(0.4)
shell.run("clear")
end
end
Say the string has eight characters in it (so "lenght" is eight) - the first "for" loop (using "i") will count from 20 to -8 (repeating 28 times total). With each iteration, the string gets printed one character more to the left.
To print the string, you run the second "for" loop (using "j"), which counts from 0 to 8 (repeating 9 times). First it'll print the eight characters in stringV, then it'll try to print a ninth character - but there's no ninth character in the string, so it writes "" instead. Whatever character was there already gets left there - you really want to write a space over it.
You could re-write the function as:
function printString(stringV)
stringV = tostring(stringV)
for i = 20,-string.len(stringV),-1 do
screen.setCursorPos(i, 1)
screen.write(stringV.." ") -- This writes everything in stringV, then concatenates ("adds") a space.
sleep(0.4)
screen.clear()
end
end
Edit: To be clear, "write()" uses word-wrap. "term.write()" does not, so you don't need to check each character to see if it'll fit on the screen or not. Your monitor's "write()" function ("screen.write()" here) is much the same as "term.write()".