function love.load()
for i = 1, 100 do
os.execute("cls")
print(i)
end
end
The purpose of this is for the sake of updating the console to show a percentage without flooding the console with a wall of numbers, I've just simplified it for ease of understanding.
Last edited by Dr.Tyler O. on Mon Jul 06, 2015 11:54 pm, edited 1 time in total.
Any topic I have ever posted that I felt did not require a .love file, although they were requested, never required one so I would appreciate if you did not ask me to supply one unless you think that I am ignorant for not doing so.
That works fine in bash, just moves cursor up a line and to the beginning of column. Not sure what level of ANSI support cmd.exe has, but you should be able to find a cross-platform solution.
function sleep(n) -- seconds
local t0 = os.clock()
while os.clock() - t0 <= n do end
end
function love.load()
print()
for i = 1, 100 do
print(string.char(27) .. "[2F")
print(i)
sleep(1)
end
end
Takes 100 seconds to complete, make sure you have a way to kill the process if you don't want to wait.
AFAIK, this is a known problem after using os.execute, I had the same problem a while back.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
In this case you should write to [manual]io.stdout[/manual] instead of using print, you can use it as a file and move to an specific position, delete, rewrite, insert, etc
for i, person inipairs(everybody) do [tab]ifnot person.obey then person:setObey(true) end end
love.system.openURL(github.com/pablomayobre)
Positive07 wrote:In this case you should write to [manual]io.stdout[/manual] instead of using print, you can use it as a file and move to an specific position, delete, rewrite, insert, etc
But nothing happened. I've never heard of being able to "move to an specific position, delete, rewrite, insert, etc" with stdout (I've only ever seen it done with escape sequences, never seen stdout treated as a random access file, never believed it was possible). Can you give an example of how you did this?
Don't be sorry, I was just confused because OP marked this as [solved] right after you posted that. It would be good if people would take the time to leave a note about how their problem was solved to avoid confusing people who find the thread later. Could be that OP settled for printing everything on one line, so not having line breaks was a good enough soultion... who knows.
I assume stdout is an append-only stream on all platforms, though. If it were read-write it could be a security issue, one program could read the output from another.
The purpose of this is for the sake of updating the console to show a percentage without flooding the console with a wall of numbers, I've just simplified it for ease of understanding.
Oh, I will ask why you use os.execute xD
There something simpleeeeeeeer for doing this :
Long :
The \r is an ANSI code named "Carriage Return". What it does basicly ? It "returns" the "carriage". So, it sets the X position of the cursor to 0 (or 1 if you prefer. To the start of the line). If you want to know, on Windows, when you want to print to a new line, you add a CRLF character combination. CR = Carriage Return = \r : LF = Line Feed = \n. The role of the Line Feed is to add one to the Y position of the cursor !
Now, you know all you need. Create the new newgen 3D infinite-world sandbox role-playing-game !