One of the latest additions to the plugin was the ability to create a dynamic template and thus allows:
- More control on the mission outcome.
- Easier transition of a standalone mission to a template.
- Create even more diversification to mission outcome based on Random Engine
At first the new addition, or enhancement, might sound useless since the Random Engine already creates diverse missions base on template rules, but when you delve a little bit more you will see that:
- Templates will generate missions randomly and hence you have little control on the exact content you will get.
- A template mission is good for one area or use case, but you might want to have different scenario in other areas/planes which makes it harder to predict, using current feature set.
- You need specialized template for specifc use cases
In order to achieve that I have integrated few key mechanisms into the plugin in order to get a more granular control of the template outcome and to allow more control of the template itself.
The new enhancements are:
- Added new template root element by the name <REPLACE_OPTIONS>
- Added new sub element <opt name=""> which stands for option element.
The <opt> root element represent a choice in a drop down list the simmer can take from the "template" screen before generating a random mission. - Enhanced the "Pick Template" screen to show the different <opt> options the simmer can pick before generating the mission.
- Added "copy_leg_as_is_b" attribute to a content set element for easier standalone mission conversion to a template one.
Dynamic Templating
It is all about options, let's take a look:
The <opt> sub element defines the text the end user will see and pick from.
The <find_replace> sub element defines which string to replace in the current “template” file and which "content file" or other "string" to replace it with (the plugin replaces all occurrences).
You can define one or more <find_replace> sub elements in same <opt> root element.
This new feature basically mimics "find"/"replace" mechanism, it is simple and effective, but you have to remember that when replacing a "string" with "content file" we basically take what ever is in the file and replacing with the current template string, that includes line feeds/tabs and such, so you are responsible for the end template output.
You can read more about this enhancement in the "Designing Templates" document guide.
The last feature I would like to share here is the addition of the attribute: "copy_leg_as_is_b" to "content set", meaning it comes in conjunction with the attribute: "is_set_of_flight_legs="yes"".
The "copy_leg_as_is_b" tells the Random engine to not generate or evaluate the <leg> element but to copy it as a whole. This is in cases when you want hardcoded flight legs or when you want to convert a mission to a template and just want to add some options to it.
The demo mission I prepared: "Townsvile to Palm and Back" is one such example. It is used to assist designers learn and have a reference in how to implement or use the plugin features. But once the plugin got new enhancements I did not want to create a new mission to demonstrate the new capabilities, and this is how the is_set_of_flight_legs was implemented at first. I needed a quick way to tell the Random engine to skip Leg generation and just use what is there already, this is very useful in such cases, and in my case, I could just create variance of the same mission while incorporating the new enhancements and all in the same template.
I has to dynamically manage:
- Mission information text
- GPS
- Choice Window
- Special Task (when to add the cargo task and when not).
- Datarefs
- and Scripts
This is how it looks in the template window:
Here are some more images from the template itself (as of this writing), and you can get it from the X-Plane.org page.
The "replace text" does not invalidates the XML syntax even if it is present in the end result, example "%cargo_datarefs%" won't invalidate the final XML file.