[MD Tool] MD Control (Scripts can send vars to MD) v1.13a - 20Jan2010

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

h2o.Ava
Posts: 317
Joined: Sun, 12. Oct 08, 04:04
x3tc

Post by h2o.Ava » Mon, 15. Nov 10, 13:38

MD:
value={object.name@<object>}
example={object.name@enemy}

SE:
<RefObj> -> set name to <Var/String>

Found the best one.
This is becoming easier, I can stay at 10 total ships, and change the names of the stations and ships allowing for 20 variables to be passed between MD and SE.
Time for a break.. just browsed through 16k lines of director.xsd..

User avatar
apricotslice
Posts: 13737
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice » Mon, 15. Nov 10, 13:53

enenra wrote:@aprictoslice
Currently, the only way to effectively learn MD coding is to study the existing files extensively and then writing your own code, starting with, for example, a simple mission, later a first generic mission, then a next one etc.
During learning you'll need someone who knows the MD well to work with you, answer your questions quickly and look through your code.

That's the way I've learned it - only took me around 4 months of working with the MD every day around 6 hours. :P

There is an existing documentation pdf, which is horribly outdated but still useful to understand the general structure. There's also the html file Ketraar mentioned which I recommend strongly. No better place to learn of the MD's cspabilities. Finally you might want to take a look at the first mission I wrote and documented extensively - the Rescue the Boron Princess-mission. :)
There was a time when I would have taken you up on that little challenge. But I dont have the brain for it anymore.

My programming days are over. Learning a new language is beyond me now. Neither the brain power or the motivation is there any more.

Now theres a hell of an admission. Getting old sux. :(

The most I can do these days is cut and paste the more simple bits.

Doesnt stop me asking for the impossible to make it easier for other people though. :D

h2o.Ava
Posts: 317
Joined: Sun, 12. Oct 08, 04:04
x3tc

Post by h2o.Ava » Wed, 17. Nov 10, 00:00

I'm looking for someone that is good at manipulating strings.
If you're interested in assisting, I'd love it if you could take this string and turn it into 10 variables.

(00,11,22,33,44,55,66,77,88,99)

var1 = 00
var2 = 11
etc..etc


Also, if someone has a more user friendly idea for the combination, I'd love to hear it.

User avatar
apricotslice
Posts: 13737
Joined: Sun, 16. May 04, 13:01
x4

Post by apricotslice » Wed, 17. Nov 10, 00:41

Just insert it into an array and address each element of the array.

Not sure how you would do it in SE, but in other languages, you just describe the array as 10 elements long, then describe it as a string the same length. Copy string to array-string and then access via array elements.

No idea how to do that in SE though.

h2o.Ava
Posts: 317
Joined: Sun, 12. Oct 08, 04:04
x3tc

Post by h2o.Ava » Wed, 17. Nov 10, 01:28

Passing it via an array would be the easiest thing to do.
Although, I'd prefer that the scripter only has to type the key in one line, exactly like the $pageid=9876, instead of creating an array.

Looking at it now, it seems 10 stations is more than what would ever be needed.
Dropping it down to 6ships and 10stations: cships(0-5), the position of number, and 10cstations(0-9), the number in the position. Making the key 6 digits long and capable of using duplicate numbers (999999), totaling 1,000,000 unique MDs. Eventually I'll create a list of only the keys in use.

Question:
anyone know how MD handles strings and numbers?
if a string is all numbers, is it viewed as a string or number?
can it convert strings to numbers?

Thank you everyone for all the assistance you have thus far provided.

h2o.Ava
Posts: 317
Joined: Sun, 12. Oct 08, 04:04
x3tc

Post by h2o.Ava » Wed, 17. Nov 10, 21:44

Changed status from Proof of Concept to Development.

Cleaned up first posts a little.

Scripts are almost complete.

I will start on the MD once the foundational scripts are prepared.

Note to self: Is there the possibility of activating a MD via both MDC and standard conditionals? such as a nested check any in a check all?

h2o.Ava
Posts: 317
Joined: Sun, 12. Oct 08, 04:04
x3tc

Post by h2o.Ava » Tue, 23. Nov 10, 09:40

Updated to BETA.
It is fully functioning and can be implemented now.
The key handling and variable handling is implemented in SE and later versions most likely will not require external changes.

The only thing remaining is to finish variable handling.
I can currently pass strings and numbers from SE to MD.
However, I currently do not know MD well enough to handle the variables correctly in MD.
Once this hurdle is overcome we will have basic variable handling SE to MD and MD to SE.
For example, passing strings will be handled by the ship and station names and numbers by capital ships and energy cells.
True and False is 1 and 0.

User avatar
LV
Sith Lord
Posts: 6362
Joined: Wed, 6. Nov 02, 21:31
x3tc

Post by LV » Tue, 23. Nov 10, 11:43

h2o.AvA wrote: Time for a break.. just browsed through 16k lines of director.xsd..
come back when you have passed Image 1 million lines of SE code padwan :P

as a request if you keep are bare minimum template that pretty much just calls 'x' script it may temp lazy scriptors liker myself to delve into it.

you can then update another version as you go along as some of us may get off our backsides and help
LV's TC Scripts
Readme's For All My Scripts


I felt a great disturbance in the forum, Like millions of voices cried out in terror, then were silenced

si tacuisses, philosophus mansisses

h2o.Ava
Posts: 317
Joined: Sun, 12. Oct 08, 04:04
x3tc

Post by h2o.Ava » Tue, 23. Nov 10, 13:04

Coding a million lines is one thing.
Reading the director.xls is another...
One is fuuuuuun.
The other is "A Tale of Two Cities."
:)
But.. GEEZ 1 million lines of hobby code.
I bow before you. *bows*



I don't think I can shrink the MD template or the SE lines any more than they are, at least not until I start getting bug reports or some constructive feedback/tips.
Variables will be passed via two arrays.

SE:
$key = 123456
$var.str.array = array alloc: size=Max 16 (names of ships/stations)
$var.num.array = array alloc: size=Max 10 (# of ecells in the stations)

=<RefObj> call script 'md.control.key' : key=$key strings=$var.str.array numbers=$var.num.array
(strings and numbers are not implemented in the beta)

MD:
Paste your MD between the comment lines and replace all XXXXXX with your key and then break the key into the single Xs.

Code: Select all

  <cues>
    <!--Replace all XXXXXX with your Key. (for example: 987654)-->
    <cue name="MDControl_XXXXXX">
      <condition>
        <check_all>
          <!--Change X to the 1st number in your key. (for example: Key=987654 X=9)-->
          <object_is_docked object="MDControl.ControlShip0" dockobject="MDControl.ControlStationX"/>
          <!--Change X to the 2nd number in your key. (for example: Key=987654 X=8)-->
          <object_is_docked object="MDControl.ControlShip1" dockobject="MDControl.ControlStationX"/>
          <!--Change X to the 3rd number in your key. (for example: Key=987654 X=7)-->
          <object_is_docked object="MDControl.ControlShip2" dockobject="MDControl.ControlStationX"/>
          <!--Change X to the 4th number in your key. (for example: Key=987654 X=6)-->
          <object_is_docked object="MDControl.ControlShip3" dockobject="MDControl.ControlStationX"/>
          <!--Change X to the 5th number in your key. (for example: Key=987654 X=5)-->
          <object_is_docked object="MDControl.ControlShip4" dockobject="MDControl.ControlStationX"/>
          <!--Change X to the 6th number in your key. (for example: Key=987654 X=4)-->
          <object_is_docked object="MDControl.ControlShip5" dockobject="MDControl.ControlStationX"/>
        </check_all>
      </condition>
      <cues>
        <cue name="MDControl_XXXXXX_Resetships">
          <condition>
            <cue_is_complete cue='MDControl_XXXXXX'/>
          </condition>
          <action>
            <do_all>
              <run_script script="md.control.reset"/>
              <reset_cue cue="MDControl_XXXXXX"/>
            </do_all>
          </action>
          <!--Begin: Paste your MD below this comment-->
          <cues>
            <cue name="Your MD name">
              <condition>
                <check_all>
                  <cue_is_complete cue="MDControl_XXXXXX_Resetships"/>
                </check_all>
              </condition>
            </cue>
            <!--End: Paste your MD above this comment-->  
          </cues>
        </cue>
      </cues>
    </cue>
  </cues>

User avatar
Ketraar
Moderator (DevNet)
Moderator (DevNet)
Posts: 8993
Joined: Fri, 21. May 04, 17:15
x4

Post by Ketraar » Tue, 23. Nov 10, 13:10

<cue name="Your MD name"> Will never trigger since its a child cue of <cue name="MDControl_XXXXXX_Resetships"> and you have a reset in it, which will reset <cue name="MDControl_XXXXXX_Resetships"> and all its child cues.

MFG

Ketraar
Image

h2o.Ava
Posts: 317
Joined: Sun, 12. Oct 08, 04:04
x3tc

Post by h2o.Ava » Tue, 23. Nov 10, 13:26

Ketraar wrote:<cue name="Your MD name"> Will never trigger since its a child cue of <cue name="MDControl_XXXXXX_Resetships"> and you have a reset in it, which will reset <cue name="MDControl_XXXXXX_Resetships"> and all its child cues.
It's resetting the very top cue:
<cue name="MDControl_XXXXXX">

The example MD has:

Code: Select all

        <cue name="MDControl_987654_Reset">
          <condition>
            <cue_is_complete cue="MDControl_987654"/>
          </condition>
          <action>
            <do_all>
              <run_script script="md.control.reset"/>
              <reset_cue cue="MDControl_987654"/>
              <incoming_message popup="1" author="MDControl_987654_Reset" text="987654 - Reset"/>
            </do_all>
          </action>
          <!--Begin the 3rd party MD-->
          <cues>
            <cue name="MDControl_ALPHA_Test">
              <condition>
                <cue_is_complete cue="MDControl_987654_Reset"/>
              </condition>
              <action>
                <incoming_message popup="1" author="MDControl_ALPHA_Test" text="3rd Party MD - Running"/>
              </action>
            </cue>
          </cues>
          <!--End of the 3rd party MD-->
<incoming_message popup="1" author="MDControl_ALPHA_Test" text="3rd Party MD - Running"/>
When I run the example I receive that message. it seems like it is running the child cue, even after the top parent cue is reset.

User avatar
Ketraar
Moderator (DevNet)
Moderator (DevNet)
Posts: 8993
Joined: Fri, 21. May 04, 17:15
x4

Post by Ketraar » Tue, 23. Nov 10, 14:02

h2o.AvA wrote:When I run the example I receive that message. it seems like it is running the child cue, even after the top parent cue is reset.
the top cue name="MDControl_987654_Reset"

the reset command you use <reset_cue cue="MDControl_987654"/>

Nothing is getting reseted. ;-)

MFG

Ketraar
Image

h2o.Ava
Posts: 317
Joined: Sun, 12. Oct 08, 04:04
x3tc

Post by h2o.Ava » Tue, 23. Nov 10, 19:11

Uploaded BETA v0.81

MD template just got smaller.
I shrank it down to just the top cue.


After removing this line from the below example:
<reset_cue cue="MDControl_987654"/>

It activated once, then never again.

After placing it back in, it activates and displays the child cue's message every time I execute the script.

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<?xml-stylesheet href="director.xsl" type="text/xsl" ?>
<director name="template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="director.xsd">
  <documentation>
    <author name="h2o.AvA" alias="Ava" contact="PM me on forums.egosoft.com"/>
    <content reference="MD Control" name="MD Control BETA Test" description="Example: showing fully functional incoming Key activation"/>
    <version number="0.81" date="22-11-2010" status="testing"/>
  </documentation>
  <cues>
    <!-- cue name = MDControl_Key : Key = 987654 -->
    <cue name="MDControl_987654">
      <condition>
        <check_all>
          <object_is_docked object="MDControl.ControlShip0" dockobject="MDControl.ControlStation9"/>
          <object_is_docked object="MDControl.ControlShip1" dockobject="MDControl.ControlStation8"/>
          <object_is_docked object="MDControl.ControlShip2" dockobject="MDControl.ControlStation7"/>
          <object_is_docked object="MDControl.ControlShip3" dockobject="MDControl.ControlStation6"/>
          <object_is_docked object="MDControl.ControlShip4" dockobject="MDControl.ControlStation5"/>
          <object_is_docked object="MDControl.ControlShip5" dockobject="MDControl.ControlStation4"/>
        </check_all>
      </condition>
      <action>
        <do_all>
          <run_script script="md.control.reset"/>
          <incoming_message popup="1" author="MDControl_987654" text="987654 - Started"/>
          <reset_cue cue="MDControl_987654"/>
        </do_all>
      </action>
      <!--Begin the 3rd party MD-->
      <cues>
        <cue name="MDControl_BETA_Test">
          <condition>
            <cue_is_complete cue="MDControl_987654"/>
          </condition>
          <action>
            <incoming_message popup="1" author="MDControl_BETA_Test" text="3rd Party MD - Running"/>
          </action>
        </cue>
      </cues>
      <!--End of the 3rd party MD-->
    </cue>
  </cues>
</director>
Even after creating a child cue of a child cue of cue name"MDControl_BETA_Test" all the child cues sent their messages. Perhaps you are thinking of destroy_cue, complete_cue, or cancel_cue?
I have never tested those three.
However, reset_cue seems to only reset the specified cue, whether it is in the Doing cue or not, and allows the Doing cue's child cues to continue.

djrygar
Posts: 1750
Joined: Mon, 10. Aug 09, 02:09
x3ap

Post by djrygar » Thu, 25. Nov 10, 03:56

so, would it be posible to pass, for example, a ship ID to MD?

what I am thinking here is some kind of mission like 'protecting assault' for IR, so shipyard launching assault can give player a mission to protect it.

Jack08 was talking about missions like this done via script, yet, I really would like to see it as MD mission

h2o.Ava
Posts: 317
Joined: Sun, 12. Oct 08, 04:04
x3tc

Post by h2o.Ava » Thu, 25. Nov 10, 09:44

Not at this time.
However, you could have IR start the mission and have the MD create the ships 200km from anything and is near an IR created control object which IR scans its vicinity locking onto and integrating all the MD created ships into IR.

Might not be the best way, but it is one way I just thought of off the top of my head.

Summarized:
It is doable.
IR can start the MD, however the MD needs to create the ships. Have the SY create the ships first, then destroy those as it tells MD to create the ships, so that the SY doesn't get free ships.


edit:
I found an easier way. Have the SY create the ships then when IR is ready to start the mission, have the ships jump to a location 200km from anything. Then start the MD, the MD creates an object at that location then does "find_ship" and assigns all the ships an MD name which MD can then use. Destroy the created object and jump the ships back to the SY or whereever and begin the mission.

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”