Jump to content




Textutils.slowPrint not rendering properly [1.5.2]


  • You cannot reply to this topic
10 replies to this topic

#1 Galactica4

  • Members
  • 44 posts
  • LocationAustralia

Posted 14 July 2013 - 02: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

#2 svdragster

  • Members
  • 222 posts
  • LocationGermany

Posted 14 July 2013 - 03:14 AM

I don't think it's a bug.

#3 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 14 July 2013 - 11:15 AM

Picture:
Posted Image

#4 Galactica4

  • Members
  • 44 posts
  • LocationAustralia

Posted 14 July 2013 - 05:16 PM

View PostDlcruz129, on 14 July 2013 - 11:15 AM, said:

Picture:
Posted Image
Thanks for the pic, it explains better :)

#5 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 14 July 2013 - 08: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

#6 Symmetryc

  • Members
  • 434 posts

Posted 15 July 2013 - 09:45 AM

View PostPixelToast, on 14 July 2013 - 08:38 PM, said:

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.

#7 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 15 July 2013 - 10: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

#8 Apfeldstrudel

  • Members
  • 161 posts

Posted 15 July 2013 - 10:38 AM

Ofcourse its a bug!

#9 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 15 July 2013 - 11:44 AM

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.

#10 DavEdward

  • Members
  • 17 posts

Posted 03 May 2014 - 04: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 by DavEdward, 03 May 2014 - 04:59 AM.


#11 DavEdward

  • Members
  • 17 posts

Posted 03 May 2014 - 05: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 by DavEdward, 03 May 2014 - 05:18 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users