Does anyone know how to do this?
I've looked for solutions on sites like StackOverflow, but I don't understand any of the answers.
I have tried running T-Engine from the command line, using the ">" operator to send the standard output / error to a text file. However, it doesn't seem to do anything.
I need this because I'm working with AI.
And yes, I'm aware print is a function!
View output of "print" statements when running on Windows
Moderator: Moderator
Re: View output of "print" statements when running on Window
You should have a te4_log.txt file in your T-Engine directory that contains all of the print output.
As explained in the wiki, you can add --flush-stdout to force the log file to be updated immediately. (Otherwise, it's buffered, which means that there may be a delay before print statements' output shows up.) --flush-stdout can slow the game down, and I rarely have to use it.
As explained in the wiki, you can add --flush-stdout to force the log file to be updated immediately. (Otherwise, it's buffered, which means that there may be a delay before print statements' output shows up.) --flush-stdout can slow the game down, and I rarely have to use it.
Re: View output of "print" statements when running on Window
Some lua files, like ai-files, disable the print function. If you find this at the start:
prints inside your codechanges probably won't do nothing.
If you are working with the console, the output of print (variable) / table.print (variable) is inside te4_log.txt, as Castler explained. You can flush with a keytroke (CTRL + F), if you are using Marsons wonderful Developer Tools: http://forums.te4.org/viewtopic.php?f=5 ... lit=marson
Code: Select all
local print = function() end
If you are working with the console, the output of print (variable) / table.print (variable) is inside te4_log.txt, as Castler explained. You can flush with a keytroke (CTRL + F), if you are using Marsons wonderful Developer Tools: http://forums.te4.org/viewtopic.php?f=5 ... lit=marson
Re: View output of "print" statements when running on Window
Thanks, Dao Zeti!
It's not like I hadn't discovered te4_log.txt yet! It's just that from the point of view of someone looking at the middle of the AI files, not really having paid attention to how te4_log.txt is created in the past and discovering there is no way to view the Standard Output on Windows, the conclusion of "I have problems viewing print output on Windows" is a reasonable one, especially when not willing to delegate much time to such a side issue!
Moreover people I spoke to on #ToME were similarly baffled, and I couldn't find anything after searching through every thread on here related to "print". So I figured it was high time to make a thread for people to look up and reference in future.
But really, thanks!
It's not like I hadn't discovered te4_log.txt yet! It's just that from the point of view of someone looking at the middle of the AI files, not really having paid attention to how te4_log.txt is created in the past and discovering there is no way to view the Standard Output on Windows, the conclusion of "I have problems viewing print output on Windows" is a reasonable one, especially when not willing to delegate much time to such a side issue!
Moreover people I spoke to on #ToME were similarly baffled, and I couldn't find anything after searching through every thread on here related to "print". So I figured it was high time to make a thread for people to look up and reference in future.
But really, thanks!
Last edited by Nagyhal on Sat Jan 10, 2015 1:39 am, edited 3 times in total.
Re: View output of "print" statements when running on Window
So for other applications, does anyone know the quickest, easiest way to view the stderr and stdout?
Re: View output of "print" statements when running on Window
Sorry; I didn't realize that some files disable print. That seems very odd, and it seems like not a great idea, since, as you saw it, can be confusing. Oh well.
stdout and stderr don't really exist for Windows apps; at least, not in a standardized setup like they do for Linux. (See here for the full details.) I don't know if there's a standard way to get at them or not. In ToME's case, it takes the (otherwise nonfunctioning, I think) stdout and redirects it to a file; see here in ToME's main.c if your curious.
stdout and stderr don't really exist for Windows apps; at least, not in a standardized setup like they do for Linux. (See here for the full details.) I don't know if there's a standard way to get at them or not. In ToME's case, it takes the (otherwise nonfunctioning, I think) stdout and redirects it to a file; see here in ToME's main.c if your curious.
Last edited by Castler on Sat Jan 10, 2015 2:41 pm, edited 1 time in total.
Re: View output of "print" statements when running on Window
Yeah, perhaps it would be better to declare a function like
Oh well, it's obvious when you know about it.
And thanks, I think I understand the general practice regarding console output a lot better now!
Code: Select all
local debug=false
function doPrint(...)
if debug then print(...)
else return nil
end
end
And thanks, I think I understand the general practice regarding console output a lot better now!