var scriptPattern:RegExp = /--%%LUA-SCRIPT%%--/;
var stack:Array = lua.doString( scriptWrapper.replace( scriptPattern, script ));
Where the scriptWrapper is the wrapper.lua file, and script is the string that's being INSERTED into the wrapper script.
About the errorCode variable:
The errorCode will ALWAYS return zero UNLESS YOUR SCRIPT SETS IT TO ONE. The errorCode variable is the mechanism by which you, the script author, inform the modelCore that the outcome of your script was either successful, or failed. The errorCode variable DOES NOT mean that the script itself failed to parse, or encountered a nil where a variable was needed or whatever. In other words, the errorCode variable is not magic, and it's there for you to use as you see fit within your code. It has nothing to do with the lua engine whatsoever
Hope this helps.
Bobby