Here's a first stab at a template for plugins. You will need my
http://www.b4x.com/forum/additional-libraries/3045-scripting-library-b4ppc.html#post17029
Run PlugInDemo then File->Load->test.src and press Run.
The interface to the plugin script is via the Plugin module which will need altering to suit the interface to the plugin that you define. You should not need to alter the Script module except to add new CallHost commands if you want.
There is no error handling at the moment. How errors are handled is probably best determined by experience of use.
Host data access is a bit clumsy but that is unavoidable without the indirect access to variables that I have requested in the Wishlist forum topic.
The next thing I will play with is an option to choose to run the script on a Thread or not.