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?
Your own error
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Your own error
You can use the commands error and assert. See in PiL.
Check out my blog on gamedev
Re: Your own error
Thanks, that's exactly what I need!micha wrote:You can use the commands error and assert. See in PiL.
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
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.
If you are in Linux you can forward the error messages from the console to a textfile using this command:
Code: Select all
love . 2> error.txt
Check out my blog on gamedev
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Your own error
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.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.Code: Select all
love . 2> error.txt
Help us help you: attach a .love.
Re: Your own error
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.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Who is online
Users browsing this forum: No registered users and 4 guests