Page 1 of 1

Console clear screen

Posted: Wed Oct 21, 2020 1:04 pm
by philfaint
Hello,

i've been printing some values to console, like fps for instance, but it writes it in a new line every second (used print()). Is there any way to clear the console to make it print value on the same position in console, clearing the screen in between? I tried to use os.execute('cls'), but it gives me weird results (attached).
Thanks!

Re: Console clear screen

Posted: Wed Oct 21, 2020 5:06 pm
by pgimeno
Maybe with the classic ESC [ H ESC [ 2 J? Not sure if that works in a Windows terminal.

Code: Select all

for i = 1, 50 do
  print("\027[H\027[2JThis tests printing a control sequence that clears the screen")
end