Some very basic information on how the MD "ticks" is simply not there.
There are a few tutorials on how to do particular things.
This here is rather on why it is necessary to do them. Sort of an introduction to the "real" tutorials.
Script Editor (SE) experience is useful only insofar, that it helps understanding what the objects do, once the MD tells them to do something.
This is by no means a complete list but only the issues I... encountered so far.
- Where are the files?
Use Doubleshadow's Mod Manager to unpack director\*.* , starting with 01.CAT (provided you want the graphics) or 03.CAT. - Get an XML editor
You need one. (Yes, you do!)
Visual Web Developer 2008 is free and it works. - director.htm
Very important reference file.
Requires ActiveX so don't try opening it with Firefox. - MD file naming convention
director\*.xml
That's it.
If you mess up the XML structure, the whole file is ignored. - When are MD files read / activated / patched?
To "activate" your script once the game is *modified*:
Start new game ...or...
Load game
Once "in" the game, all cues stay loaded and are buffered in the savegame.
Deleting the *.xml file has no effect.
When loading a game, the buffered code of all cues in the savegame (including those "waiting to fire"!)
is overwritten by yourscript.xml, provided that the cue names match.
Therefore there is no need to "patch" the MD code itself and no need for a version check.
All that could require fixing is the state of the cues and which are currently "hot".
This isn't more or less work than with the SE... just different. - When do Cues unload? How to get rid of them?
The only way to completely remove cues from your savegame isfor all cue names you used.Code: Select all
<destroy_cue cue="xgz_mdl_setup"/>
That's the uninstall script or when you royally screwed up.
No idea if that automatically destroys all subcues with it. I would assume so, but... - Variables
All variables are assigned on the fly without requiring declaration.
They are not and cannot be limited to a data type. - Variable Scope
All variables are global and immediately accessible in all cues of all MD scripts.
Expect typical name concflict issues.
Only when a variable is used as "mycue.variable" (or in it's home cue, "this.variable"), it is created "semi-local".
For all practical purposes you just used a longer variable name in doing so, so the name is unique again.
Every local variable can be accessed in all cues of all MD scripts if you reference it as "mycue.variable" so it's not really "local".
Not tested:
Local variable might be affected by the destroy_cue action while global ones are not tied to a specific cue. - The Local / Global variable ambiguity
While using the same term, MD and SE use completely incompatible systems. - Objects
Just like in the SE:
unless you find/create an object, you have no object.
You have {player.ship} as a constant.
Supposedly object="" also defaults to {player.ship} but being verbose is far easier to read and debug. - Timing
Unless otherwise directed, a cue's actions execute instantly when the conditions are met.
If there is a delay then it's too small for me to measure.
So obviously, the conditon is checked every frame or nearly so.
But there ain't no such thing as a free lunch.
Have 200 unique cues simultaneously waiting for a condition like the distance between 2 objects... and watch your FPS drop.
The MD cannot magically check many things instantly without using CPU time to do that.
So just like in the SE - use sensible delays to limit how often things are checked.
Some conditons (ship destroyed) are "real" events, that are apparently driven by real hardcoded events/signals like in the SE.
Those are rather harmless in that regard. - When do Cues fire and what do they fire?
A cue will always wait patiently until all specified conditions are met.
Then it executes the <action> and all included subcues.Both messages fire at the same time.Code: Select all
<cue name="cue_test"> <condition> <object_exists object="gzstation"/> </condition> <action> <incoming_message popup="1" text="Test for condition: station EXIST"/> </action> <cues> <cue name="subcue_test"> <action> <incoming_message popup="1" text="Unconditional subcue of station EXIST"/> </action> </cue> </cues> </cue>
- When do Cues refire?
They don't.
Once a (non instanced) cue has run, it's done forever.
You want to keep doing something, you include a failsafe to reset and enable the cue to run again - based on it's conditions.When the "setup" runs, the subcue starts waiting for it's sole condition - which is that the required station is no longer there.Code: Select all
<cue name="xgz_mdl_setup"> <condition> <object_exists negate="1" object="gzstation"/> </condition> <action> <do_all> <reset_cue cue="xgz_mdl_setup_reset"/> <find_sector name="this.mdl_sector" x="0" y="0" nearest="1"/> <create_station name="gzstation" safety="0" race="neutral" typename="SS_DOCK_A_TRADE"> <position x="00km" y="00km" z="00km"/> <sector sector="this.mdl_sector"/> <equipment loadout="none"/> </create_station> <incoming_message popup="1" text="Object not found. New {object.name@gzstation} created."/> </do_all> </action> <cues> <cue name="xgz_mdl_setup_reset"> <condition> <check_all> <object_exists negate="1" object="gzstation" /> </check_all> </condition> <action> <do_all> <incoming_message popup="1" text="Setup complete, object 'gzstation' not found. Reseting setup script."/> <reset_cue cue="xgz_mdl_setup"/> </do_all> </action> </cue> </cues> </cue>
If that ever happens, it kicks the main cue back into action.
Note: The reset automatically applies to all (?) subcues, such as the failsafe cue itself.
(yes, there are other ways to have reoccurring missions and the likes but that's definitely not "basics") - Operators
There are (+-*/).
Nothing binary, no SQR, no nothing. Suck it up.
Check_Value can supposedly (not tested) compare a string to exact="xyz".
That's the complete list of string operations. - Game Data
Very little is accessible.
Any remotely intelligent weapon/loadout selection is impossible because the MD cannot read laser damage,
required ammo, missile damage / flags, or even the range of any weapon at all.
Whenever the MD selects an enemy ship and a weapon loadout it's deciding based on assumptions, not data.
You can hardcode such data points in your MD script but then your MD script will only work properly in the mod it was written for.
Since the MD cannot access SE global variables such as 'XTMOD.ACTIVE', it will have a hard time figuring out if a different mod is active.
Creative workarounds will be required.