This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Galactica4's profile picture

Textutils.slowPrint not rendering properly [1.5.2]

Started by Galactica4, 14 July 2013 - 01:39 AM
Galactica4 #1
Posted 14 July 2013 - 03:39 AM
Hi just postin an bug
When you do textutil slowPrint, if the line is too long, it will half write an word and then it does not fit so it re writes it:

Code:
Textutils.slowPrint ("hello I am writing a long line of text to be written")

Output: (] means the side of the computer screen )

hello I am writing a long line of te –cuts out
text to be written

Cheers
svdragster #2
Posted 14 July 2013 - 04:14 AM
I don't think it's a bug.
Dlcruz129 #3
Posted 14 July 2013 - 12:15 PM
Picture:
Galactica4 #4
Posted 14 July 2013 - 06:16 PM
Picture:
Thanks for the pic, it explains better :)/>
PixelToast #5
Posted 14 July 2013 - 09:38 PM
not really much of a bug, just check if the string is greater then max horozontal if its really that much of a problem
Symmetryc #6
Posted 15 July 2013 - 10:45 AM
not really much of a bug, just check if the string is greater then max horozontal if its really that much of a problem
I don't think that the OP is talking about it being cut off, I think they are saying that when it does get cut off, the cut off word is repeated in its entirety rather than leaving off from where it was cut off.
Dlcruz129 #7
Posted 15 July 2013 - 11:30 AM
I think it's a bug, I think it should either output

hello i am writing a long line of text to be writte
n

Or,

hello i am writing a long line of text to be
written
Apfeldstrudel #8
Posted 15 July 2013 - 11:38 AM
Ofcourse its a bug!
Cranium #9
Posted 15 July 2013 - 12:44 PM
It is a bug, but it's not like it's something you can't fix yourself with your own slowPrint function. Simply check if the next word will fit, and if not, go to the next line.

I doubt it's going to be fixed that quickly, considering the minor impact this has.
DavEdward #10
Posted 03 May 2014 - 05:59 AM
I've been looking around for a solution for this issue myself.
I'm not good enough with LUA to know how to write a program to replace the slowprint program to resolve the issue of words that get cut off getting doubled.

Would anyone be up to writing a fix for this? So far my only solution is to manually line break every sentence every 18 characters myself in a program that has many, many lines of slowprint text.

Thanks in advance.
Edited on 03 May 2014 - 03:59 AM
DavEdward #11
Posted 03 May 2014 - 06:11 PM
A friend of mine who's a programmer was able to make a solution.
His version of the slowWrite command works like the old one but includes a 3rd argument that if 'true' it makes a new line like SlowPrint does.
Just for convenience I added a slowPrint function that adds the new line without an argument for those that want to easily swap out existing code.

The code is as is, as frankly I don't entirely understand all of it. It's a level well over my skill.
It seems to work great for me.
The only bug I know of is if you enter a single word that is longer than the screen it may throw an error. Just make sure no single word is longer than space on your terminal or monitor and you should be fine.


function slowWrite( sText, iRate, bNewLine )
  local iSleep = (1 / 20) -- Default rate
  local iScrWidth,iScrHeight = term.getSize()
  local iScrPos,y = term.getCursorPos()
  local sWord
  local bFirst = true
  local iLen
 
  if (iRate and iRate > 0) then --If nil ignore iRate
    iSleep = 1 / iRate
  end
  sText = tostring( sText )
  for sWord in string.gmatch(sText, "%S+") do
    iLen = string.len(sWord)
    if ((iLen + iScrPos) > iScrWidth) then
	  write("\n")
	  iScrPos = iLen
    else
	  if not bFirst then
	    sWord = " "..sWord
	    iLen = iLen + 1
	  else
	    bFirst = false
	  end
	  iScrPos = iScrPos + iLen
    end  
    for i=1,iLen do
	  sleep(iSleep)
	  term.write(string.sub(sWord,i,i))
    end
    bFirst = false
  end
  if bNewLine then
    write("\n");
  end
end

function slowPrint( sText, iRate )
    slowWrite( sText, iRate, true)
end
Edited on 03 May 2014 - 04:18 PM