Hey again people. Just bumping in here to mention that I've started working on updated script error reporting code.
Right now it has specific error messages for the following conditions:
- Attempt to read the value of an undefined value or constant
- Attempt to call an undefined function
- Attempt to give an invalid parameter when calling a function (for instance, something like: UseRadians("lol");)
The way it is right now, you can only get the full error description in the log file - the menu only shows a one-liner indicating the outermost script from which the error occurs. My current plan is to add a button press or option in the menu that will allow the user to see the full info from the last script error that occured, and maybe also to save that info to a file.
The error reports look something like this (not exact, as the reporting isn't final):
Error in TheEnemy.initialize ...
Variable not defined: some_other_stuffIt will retain call stack information, so scripters will have a bit more context to help them debug their scripts.
There's still some work to do with it, though. At the very least, it still needs messages for when it can't load a file (image, sound, music, etc) and when it hits the infinite-loop protection. Am I missing other ones?
On the bright side, I've got some extra time this week, so I might be able to get something done before the next weekend.
EDIT:So much for that extra time ...
Work, finding out my website hosting expired, work, L4D, work, ... oh right MnD! :derp:
Got some more done with the error reporting tonight. It will now also create error messages if you try to load a non-existant file (image, sound, or music) as well as if you hit the infinite loop protection.
To note - since the image files are loaded right when they're needed in the graphics engine, rather than during script execution, the code can't (currently, at least) give script context for a missing image file.
I also moved the code that spawns the initial player and enemy objects so that it runs on the first game tick, rather than right after it finishes loading everything in the menu. This shouldn't have any visible effects, but it makes things more straightforward in the code (and gets rid of a bit of duplicated code).
Still need to get the "hey here's that error you just had" option into the menu, but then I think the new error reporting scheme is pretty much good to go for the time being.
Oh, crazy idea I just had while typing this - in addition to the option of saving the error report like described above, perhaps I could also add the option of saving the complete game state to a file. This would mainly include a listing of all objects currently in the game (position, image, type, object variables, ...) as well as global variables and, once they're implemented, similar information for tasks.