Anatomy of a Lua Api Plugin - pytha-3d-cad/pytha-lua-api GitHub Wiki
Plugin-Location
Each PYTHA-plugin is contained in one folder. For PYTHA to recognize a plugin, its folder must be located inside PYTHA-Settings-Directory\plugins, where PYTHA-Settings-Directory is the folder that you can access from PYTHA-Central. In a standard installation, its full path is C:\Users\USERNAME\AppData\Roaming\PYTHA25.0.
Files
Inside the plugin-folder, you can typically find the following files:
config.xml
A configuration file that describes the functionality supplied by the plugin. If this file is not present, PYTHA will automatically generate a bare-bones configuration file. A detailed description of the configuration options can be found here.
*.lua
These are the source files of the plugin. PYTHA initially loads all files with a *.lua extension that it can find in the plugin folder (sub-folders are not taken into account, the names of the lua files do not matter). When the plugin is invoked, PYTHA executes the respective entry-point (often called function main(), see below).
*.xliff
(Optional) Translation tables related to the pyloc function.
Execution
When the plugin is invoked by the user, PYTHA tries to call the entry point described the the configuration file. By default, the entry-point is called function main(). If no such function is defined, an error will be displayed for the user.
Note: when PYTHA "loads" the lua files, it actually reads the files and executes the lua code at file-scope. At this point in time, the Lua-Api entry points (e.g. pytha.* and pyui.*) are not available yet! So only place functions and initialization code at file-scope. Also, the order in which PYTHA loads the different files is undefined and may change from run to run. So structure your initialization code to be independent of the order in which files are executed!