LociOiling Lv 1
This recipe shows how to use the Lua "xpcall" function to provide a cleanup routine. The cleanup function in this recipe can be used in any recipe written using version 2 of the Foldit-Lua interface.
A cleanup function lets your recipe recover when the user cancels it or when it crashes due to a Lua syntax error or an incorrect argument to a Foldit function. Having a cleanup function allows the recipe to always do normal cleanup tasks, such as resetting secondary structure, deleting bands, and restoring the best score.
To avoid duplicating code, the mainline logic in your recipe should simply call the cleanup function when it's done. When the cleanup function in this recipe is called without an argument, it's treated as a normal termination at the end of the recipe.