SM5 Lua: Error Reporting
I’m probably going to need a dance game sub-blog at this rate.
I really wish Stepmania didn’t crash (silently!) whenever it failed to find a file somewhere.
I’d love to write my own file loaders that didn’t fail on a missing file. Maybe simply shim everything to check if the file exists first?
TLDR:
SM(table)
in Simply Love that pretty prints tables and whatever strings you want to print. It will write to crashinfo.txt, log.txt, and to the command line.debug.debug()
will cause the game to hang until you hit enter in the command line.Warn
andTrace
seem not useful: they write to a text log in some random directory.print
is justTrace
.error
will bail out of your actors/functions on error, and print at the top of the screen.
-- I think this is built-in Lua functionality.
-- The fallback theme init script makes some shortcuts for this.
-- https://github.com/stepmania/stepmania/blob/27fdfb38718474253aeb33e9f9c7fd1a91ed823a/Themes/_fallback/Scripts/00%20init.lua#L11
-- aka print/Trace as defined in _fallback
lua.Trace('string') -- Writes 'timestap: string' to log.txt.
-- It looks like crashinfo.txt's partial log is the last few things that
-- were supposed to be written to log.txt, before they were written.
error('reason') -- Bails on the current actor. Will prevent it from loading
-- any further (basically exits out of it) and displays the error at the top
-- of the Stepmania screen (if error reporting enabled).
lua.Warn('String') -- aka Warn
-- Prints the following to log.txt:
-- /////////////////////////////////////////
-- 02:14.132: WARNING: String
-- /////////////////////////////////////////
Logs -> ~/Library/Logs/PRODUCT_ID