Page 1 of 1
Your own error
Posted: Tue Jun 18, 2013 10:54 am
by a7s1h1
Is there any way to crash the game with an error manually (with your own error message text)?
I mean something like that:
if a==0 then
<game crashes and the error message appears with the text "Error! a=0">
end
This can be useful to check the code during running the game.
So is that possible?
Re: Your own error
Posted: Tue Jun 18, 2013 11:03 am
by micha
You can use the commands error and assert. See in
PiL.
Re: Your own error
Posted: Tue Jun 18, 2013 11:25 am
by a7s1h1
micha wrote:You can use the commands error and assert. See in
PiL.
Thanks, that's exactly what I need!
One more question. When an error appears, can I somehow write the text of the error to the error log file (error**.txt, where ** is a consecutive number of a file)?
Re: Your own error
Posted: Tue Jun 18, 2013 11:44 am
by micha
As far as I know, there is no standard functionality for this. You have to implement this on your own using
love.filesystem. Note, however, that LÖVE only has writing access to your game's save directory.
If you are in Linux you can forward the error messages from the console to a textfile using this command:
This will overwrite the error.txt each time.
Re: Your own error
Posted: Tue Jun 18, 2013 1:01 pm
by Robin
micha wrote:If you are in Linux you can forward the error messages from the console to a textfile using this command:
This will overwrite the error.txt each time.
You can do that in Windows and OS X as well. You need to run your game in a terminal window (CMD.EXE on Windows), but the same goes for Linux.
Re: Your own error
Posted: Tue Jun 18, 2013 6:49 pm
by T-Bone
Rather than running from a terminal/console, I'd say save yourself some trouble and run it from a script. They can also be distributed in case you want the end user to be able to make logs.