I copied a function of the Lua C API in the code to prevent some Lua libraries (io, system and debug) to be accessible from plugins.
The variable LC_interface was added so the plugins knows if they are run on the GUI, or the CLI
For the layers, I moved the active layer variable from the layer selection widget to CadMdiChild, it will allow plugins to access the selected layer if they run in GUI version.
The selected layer is now remembered if we move between 2 or more documents.
The layer "0" is now created with the document, and impossible to remove.