For including a complex file of lua code (or a map overlay, or special images, or even a video) with your scenario, Scenario Attachments are the key.
Open from the Editor menu directly. Select the type of asset you are attaching, and press "Create New, of Type" button.
The system will load the file into the local repository of stuff identified with a guid, and it becomes available for all scenarios on that machine. (including your own)
To make use of it (or any loaded onto your machine), call ScenEdit_UseAttachment. Make an event that triggers on scenario load, and the asset will always be available in your scenario with very little other work.
After attaching, you must use the "Package Scenario for Distribution" menu option (just below the other)...
This option is only available after you have attached at least one asset through the above mechanism. In fact, this menu option becomes your new save mechanism. If you save the other way, the asset will not be attached, nor loaded on the target system automatically.
When you do this, the scenario and all the attachments are bundled into a zip file, which is what you distribute. The target audience must unzip the file to someplace on the machine, grabbing all the content, and then open the scenario file (ignoring the attachments folder that now appears next to the scenario, and not moving the scen file from next to the attachments folder). The new system seeing that folder adjacent to the scenario will load the assets into its local repository, where it is available for the scenarios on this machine. After this initial load, the end-user can remove the assets folder.
Now an observation: each file thus loaded is given a guid, and packed into the attachments folder under a sub-folder named with the guid, along with an xml description folder that tells the system what type of asset it its.
I assume there is a mechanism preventing loading as asset into the local repository more than one time. I suspect it is based upon the guid, perhaps upon the file name. I have not thoroughly tested it yet.
The official release statement for this capability is at: https://www.warfaresims.com/index.php?s=Auto+Bundling
The release statement talks about including directory structures. I did not see a way to do directory structures, other than grabbing each file individually, which is slow and painful. Furthermore, the directory structure was not restored on the target system, just a large collection of individual files. I may have missed something.
Overall, for including one or two assets, like a map overlay, or a video, or a single lua file, the mechanism works well.
I may actually use it to push my own lua library, though I have some packaging work to do... like collapsing it into a single Lua script file for distribution. This mechanism will handle versioning real well, removing the need to worry about backward compatibility. I just distribute my_library_version_1.lua, then when I upgrade, distribute my_library_version_2.lua and the system will recognize them as distinct things, and both will be included, making scenarios build with either runnable on the target system.
Now here is a question (for the devs): why can't the system read the zip folder of the scenario and the attachments directly? (do not force the end-user to unzip it, or take any action) When you force the user to take some action on the file system, then you introduce the possibility of them screwing it up. Doing this makes it almost transparent to the end-user. The only thing left to do would be to clean up the mess after importing into the local repository.
Well there could be a few additional steps to hide this from the end-user. (make it appear as part of the senario directly)
1. call the final packaged file a .scen file (not a zip). Upon file load, look at the file to see if it is zipped or not, if it is, unzip it within the system to unpack the scen data and the attachments, put them into a temp directory if needed, then load as normal, then clean up the temp folder.
2. On save (the original author) recognize the existence of (new) attachments and automate the packaging process. Or put a save with attachments, option on the file menu, just under 'save as', where the creator is expecting to see it. The same flag that enables the 'package for distribution' menu item, can be used to trigger these mechanisms.