EnglishGermanFrenchRussianItalianSpanish
Log inRegister
 
[MD Tool] MD Control (Scripts can send vars to MD) v1.13a - 20Jan2010
Post new topic Reply to topic Goto page 1, 2, 3  Next
View previous topic :: View next topic
Author Message
h2o.Ava





Joined: 12 Oct 2008
Posts: 317 on topic
Location: USA
Thank you for registering your game
modified
PostPosted: Mon, 15. Nov 10, 03:30    Post subject: [MD Tool] MD Control (Scripts can send vars to MD) v1.13a - 20Jan2010 Reply with quote Print

Introduction
. . Currently Mission Director(MD) can start a script and pass arguments into the script while it is impossible for a Script Engine/Editor(SE) to directly start or pass arguments to MD. This means that MD to SE communication is a one way transaction.
. . However, MD does have the ability to monitor for changes in the game and some of those changes can be manipulated by SE. MD Control(MDC) has been created to allow you to use SE to manipulate: start, stop, and send variables, your MDs by simply passing a key and any variables to MDC.
. . MDC accomplishes this by creating a logic circuit consisting of control ships and stations in an isolated sector. The SE then utilizes the logic circuit to communicate with the MD. Game performance should not be affected, since there is very little processing required and the ships/stations race logic is turned off.


Downloads

Installation

Everyone:
  • Change the directory name from "director Vanilla" or "director XTC" to "director" based on which map you are using Vanilla or XTC.
  • Reinit script cache, then follow the instruction messages.
    v1.13a (zip)
    Contents:
    MD_Control_Sector.xml -- (MD: Control sector/ships/stations creator)
    MD_variable.xml -- (MD: MDC's Variable handler)
    setup.md.control.xml -- (SE: MDC Setup)
    md.control.create.xml -- (SE: Initial setup of stations/ships)
    md.control.key.xml -- (SE: processes your key and sends it to main)
    md.control.main.xml -- (SE: activates MD)
    md.control.reset.xml -- (SE: resets ships and stations)
    9876-L044.xml -- (T: Contains control sector's name: MD Control)



    Developers:
    Note: The sector MD Control only appears on flat maps. If you are using the vanilla map style, then press 'm' until it is displayed in the description box, typically two times.

    dev1.11a (7z)
    Contents:
    MD_template.xml -- (MD: Template to follow to use MDC)
    MD_Example_Test.xml -- (MD: Example/Test MD)
    md.control.example.test.xml -- (SE: Used to activate MD_Example_Test




      Example v1.1 - Testing Procedure
    [list=1]
  • Place all files in respective folders (MD in /director, SE in /scripts, T in /t)
  • Load a save or create a new game
  • Wait for pause and two messages:
    1. MDC-SE: script delay
    2. MDC-MD: control sector creation
  • Reinit script cache
  • Wait for pause and message, MDC-SE: Ready
  • Open script editor
  • Run: -md.control.example.test-


    _________________


    -|Organic Notoriety|- -|Dynamic Colored Sector Names|-


    Last edited by h2o.Ava on Fri, 21. Jan 11, 02:30; edited 29 times in total
  • Back to top
    View user's profile Send private message
    h2o.Ava





    Joined: 12 Oct 2008
    Posts: 317 on topic
    Location: USA
    Thank you for registering your game
    modified
    PostPosted: Mon, 15. Nov 10, 03:30    Post subject: Reply with quote Print

    What does MDC allow you to do?

    MDs conditionals are not flexible.
    SE is extremely flexible.
    Using SE you can determine exactly when and why a MD is run.
    Use a script to change backgrounds, add suns, give rewards, start missions.
    (If you have more ideas on how this can work. Please post them.)



    How MDC works

    ---Activation---
    -Script Engine-
    After assigning each of your MDs a unique 6 digit key. Have your script send that key to MD Control, which will activate the MD assigned to that key.
    Code:
    Example:
    If your MD is assigned the key 123456, then when you want your script to activate that MD, you send the key 123456 to MD Control.

    $key = 123456
    = [THIS]->call script 'md.control.key' : key=$key



    -Mission Director-
    The first condition for each MD needs to use the following format:
    Code:
    (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>

    (key = 999000)
        <cue name="MDControl_999000">
          <condition>
            <check_all>
              <object_is_docked object="MDControl.ControlShip0" dockobject="MDControl.ControlStation9"/>
              <object_is_docked object="MDControl.ControlShip1" dockobject="MDControl.ControlStation9"/>
              <object_is_docked object="MDControl.ControlShip2" dockobject="MDControl.ControlStation9"/>
              <object_is_docked object="MDControl.ControlShip3" dockobject="MDControl.ControlStation0"/>
              <object_is_docked object="MDControl.ControlShip4" dockobject="MDControl.ControlStation0"/>
              <object_is_docked object="MDControl.ControlShip5" dockobject="MDControl.ControlStation0"/>
            </check_all>
          </condition>



    ---Passing Variables---
    Numbers from 0 to 25000 can be passed from SE to MD.
    SE: Vars[0] becomes MD: MDC_variable.0
    SE: Vars[9] becomes MD: MDC_variable.9


    ---FYI and other ramblings---
    - Currently 900,000 unique MDs are supported (100000 to 999999)
    - MD Control will allow only one script to use it at a time and needs to reset itself after each use. Your script will be queued and the MDs will run first come first serve.
    - Passing variables from SE to MD should be done through a secondary MD and not directly sent into the scripter's core MD. The secondary MD receives the variable from its respective ship's/station's name, chosen by the scripter, and assigns it to cuename.variable which can then be read by other MDs when needed.


    _________________


    -|Organic Notoriety|- -|Dynamic Colored Sector Names|-


    Last edited by h2o.Ava on Sat, 11. Dec 10, 04:33; edited 9 times in total
    Back to top
    View user's profile Send private message
    h2o.Ava





    Joined: 12 Oct 2008
    Posts: 317 on topic
    Location: USA
    Thank you for registering your game
    modified
    PostPosted: Mon, 15. Nov 10, 03:31    Post subject: Reply with quote Print

    Todo for MD Control - 1.2
    (25% done)

    Script:
    10% - Pass complex variables to MD
    -- 25% - Strings
    -- 25% - Complex Variables
    -- 25% - Negative Numbers
    (doesn't seem like we can pass anything but strings and numbers)
    (An object library might need to be created in MD so SE can pass MD a number and MD will translate it into classes and types)


    MD:
    10% - Receive strings from SE and convert them to numbers/classes/types



    -----------------------------
    Tutorial/Instructions:
    50% - Standardization
    50% - Example


    _________________


    -|Organic Notoriety|- -|Dynamic Colored Sector Names|-


    Last edited by h2o.Ava on Sat, 11. Dec 10, 04:30; edited 17 times in total
    Back to top
    View user's profile Send private message
    apricotslice





    Joined: 16 May 2004
    Posts: 13629 on topic
    Location: In the Hunter Legacy Universe
    Thank you for registering your game
    PostPosted: Mon, 15. Nov 10, 08:27    Post subject: Reply with quote Print

    What your doing is less important here than how your doing it.

    So please explain the object of the exercise, and then how each part of it interacts with each other.

    The object as I see it here, is to explain to us step by step, how to get MD and script to interact. So the what is just a means to an end to explain the how.

    So far you have simply demonstrated that creating in MD can be used by a script. Its the interaction and the mechanism for doing so, back and forth, that needs detailed explaining.

    Its encouraging to see you get this far, but so far, I'm not really sure how, or if the method is reproducable for varying situations.


    _________________
    Apricot Mapping Services HQ
    CLICK HERE for X3 Handbook; TC and AP Guides, Mods, Scripts & Downloads
    Back to top
    View user's profile Send private message Send e-mail Visit poster's website
    enenra





    Joined: 08 Apr 2005
    Posts: 6152 on topic

    Thank you for registering your game
    PostPosted: Mon, 15. Nov 10, 09:41    Post subject: Reply with quote Print

    I'm not exactly sure what you're trying to do, h2o.AvA. Oops

    MD and scripts can communicate, it just isn't as easy as forwarding a variable for the SE to MD side. But MD and SE can work together and they have been used in conjunction before - see for example the New Home Plot (the Sudoku Part).


    _________________
    Back to top
    View user's profile Send private message
    h2o.Ava





    Joined: 12 Oct 2008
    Posts: 317 on topic
    Location: USA
    Thank you for registering your game
    PostPosted: Mon, 15. Nov 10, 10:05    Post subject: Reply with quote Print

    Do you mean that I can already start a MD from a script?
    What is the name of New Home's director file?

    edit: CSV, I'll read those and see.

    Back to top
    View user's profile Send private message
    enenra





    Joined: 08 Apr 2005
    Posts: 6152 on topic

    Thank you for registering your game
    PostPosted: Mon, 15. Nov 10, 10:13    Post subject: Reply with quote Print

    h2o.AvA wrote:
    Do you mean that I can already start a MD from a script?
    What is the name of New Home's director file?

    edit: CSV, I'll read those and see.


    It's not directly possible to start MD code from a script. But as both can read and change existing objects, it's relatively easy to pass information to the MD which has been done in the New Home Plot.


    _________________
    Back to top
    View user's profile Send private message
    apricotslice





    Joined: 16 May 2004
    Posts: 13629 on topic
    Location: In the Hunter Legacy Universe
    Thank you for registering your game
    PostPosted: Mon, 15. Nov 10, 10:14    Post subject: Reply with quote Print

    Actually enenra, what we really need is the ability to start an MD from a script and the ability for an MD to call a script.

    There are things which both do better than the other and it would be good to be able to start or stop the other from the other, and run each other from the other.

    For example, missions that trigger from the variables in a script. You only want the mission to trigger becoming available when the script has determined it should.

    Likewise, during a mission, an MD could call a specific script to allow for specific ship movements to happen. The MD can create the ships, but a script can make them do things.

    The situation with game starts where too big a start file conflicts with too many setup scripts. We get around it by setting a gloabl variable so that the setup scripts get run only on the second game load, but it would be very useful for modding for that same script to also call an MD to delay the start or to remove a complicate start into its own MD file, so keeping start.xml simple. The code for my AMS start almost doubles the size of start.xml for example, and it would be useful if that code could be executed out of a script after the second game load when the rest of the mod is set up.

    Edit :
    I see direct interaction between script and MD as a major oversight in the creation of the MD.


    _________________
    Apricot Mapping Services HQ
    CLICK HERE for X3 Handbook; TC and AP Guides, Mods, Scripts & Downloads
    Back to top
    View user's profile Send private message Send e-mail Visit poster's website
    enenra





    Joined: 08 Apr 2005
    Posts: 6152 on topic

    Thank you for registering your game
    PostPosted: Mon, 15. Nov 10, 10:25    Post subject: Reply with quote Print

    There is a command to run a script in the MD.

    Code:
              <run_script>
                <scriptargs>
                  <scriptvalue datatype="ship" datavalue="{player.ship}">
                    <scriptarray>
                      <scriptvalue datatype="string" datavalue="yadda"/>
                      <scriptvalue datatype="string" datavalue="yadda2"/>
                    </scriptarray>
                  </scriptvalue>
                </scriptargs>
              </run_script>


    As for the SE to MD side, see the New Home Plot.


    _________________
    Back to top
    View user's profile Send private message
    apricotslice





    Joined: 16 May 2004
    Posts: 13629 on topic
    Location: In the Hunter Legacy Universe
    Thank you for registering your game
    PostPosted: Mon, 15. Nov 10, 10:30    Post subject: Reply with quote Print

    When is the MD going to get some decent documentation ?

    Seems like it has many things no one knows anything about.

    And besides, that example made no sense whatsoever.

    Not being critical, but it just makes no sense to someone who only has a basic understanding of MD.

    Theres a lot the MD does that makes no sense to me at all.

    And even though I can read the code, without a decent manual for using the MD, I cant write it.


    _________________
    Apricot Mapping Services HQ
    CLICK HERE for X3 Handbook; TC and AP Guides, Mods, Scripts & Downloads
    Back to top
    View user's profile Send private message Send e-mail Visit poster's website
    h2o.Ava





    Joined: 12 Oct 2008
    Posts: 317 on topic
    Location: USA
    Thank you for registering your game
    PostPosted: Mon, 15. Nov 10, 10:34    Post subject: Reply with quote Print

    Code:
    <run_script script="csv.hacking.init">
         <scriptargs>
              <scriptvalue datatype="string" datavalue="init"/>
              <scriptvalue datatype="object" datavalue="{object@CSV_toplevel.CafeCPU}"/>
         </scriptargs>
    </run_script>

    <condition>
         <object_exists object="{actor@CSV_Chapter6_vorFirewall.actor123}" negate="1"/>
    </condition>


    This runs the script csv.hacking.init and passes the arguments str.mode and obj.cafe into the script. MD passes "string" and "object" so the script needs an argument starting with "str." and "obj." each of their respective Var/Types.
    The MD then monitors for the destruction of the passenger "actor123", the script will destroy the passenger at some point.


    I'm trying to create a process where we can start MDs directly with scripts.
    Passing variables will come later, but I think it is doable.
    The variables would need to be simple, but we could do more than just [TRUE] and [FALSE]. With one more ship we could do 10 variable outcomes per MD. The scriptor could write multiple MDs so he's not limited to just 10.
    Such as, a scriptor could write an MD with all the variables he wants to pass to his core MD, then he'd send MDC the combination to activate his variable MD with a variableShip (would need to be created inaddition to controlShips) the variable MD would then "pass" the variable to the scriptors core MD, via the core MD monitoring for that variable.

    edit: improved analysis of passing args to script and added how New Home receives information back from the script

    Back to top
    View user's profile Send private message
    Ketraar
    Moderator (PortuguÍs)
    Moderator (PortuguÍs)

    MEDALMEDAL

    Joined: 21 May 2004
    Posts: 8470 on topic
    Location: Guimar„es (Portugal)
    Thank you for registering your game
    PostPosted: Mon, 15. Nov 10, 12:31    Post subject: Reply with quote Print

    apricotslice wrote:
    When is the MD going to get some decent documentation ?

    You mean besides the existing info? My guess is the day you start will be the first one. Razz

    Anyway, there is rarely any need to have info from SE to MD. Also starting scripts from MD is something I'd avoid if possible.
    Having said that, its not rocket science, have a TL with empty cargo far away or in a non existing sector, monitor it for e-cell count in MD. Add e-cell with SE to trigger MD, simple, just need to think of it, sure there are tons of other ways.

    MFG

    Ketraar

    Back to top
    View user's profile Send private message Send e-mail
    h2o.Ava





    Joined: 12 Oct 2008
    Posts: 317 on topic
    Location: USA
    Thank you for registering your game
    PostPosted: Mon, 15. Nov 10, 12:43    Post subject: Reply with quote Print

    Now that's a good idea.
    Use the ships stats and cargo to pass information.
    Can MD pull exact data off an object and store it in a variable?
    Like if it has 512 ecells, its hull is at 1000035, anything else that might be able to pass information?

    Back to top
    View user's profile Send private message
    Ketraar
    Moderator (PortuguÍs)
    Moderator (PortuguÍs)

    MEDALMEDAL

    Joined: 21 May 2004
    Posts: 8470 on topic
    Location: Guimar„es (Portugal)
    Thank you for registering your game
    PostPosted: Mon, 15. Nov 10, 12:45    Post subject: Reply with quote Print

    Pretty much anything, yes.

    Look at the {object.* variables in the MD html (pretty much at the bottom) you should find lots that read info from objects, being it internal (cargo) or external values.

    MFG

    Ketraar

    Back to top
    View user's profile Send private message Send e-mail
    enenra





    Joined: 08 Apr 2005
    Posts: 6152 on topic

    Thank you for registering your game
    PostPosted: Mon, 15. Nov 10, 13:35    Post subject: Reply with quote Print

    @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. Razz

    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. Smile


    _________________
    Back to top
    View user's profile Send private message
    Display posts from previous:   
    Post new topic Reply to topic Goto page 1, 2, 3  Next
     
    You cannot post new topics in this forum
    You cannot reply to topics in this forum
    You cannot edit your posts in this forum
    You cannot delete your posts in this forum
    You cannot vote in polls in this forum
    You cannot attach files in this forum
    You cannot download files in this forum
    Control Panel
    Login Data
    The time now is Tue, 12. Dec 17, 04:44

    All times are GMT + 2 Hours


    Board Security

    Copyright © EGOSOFT 1989-2017
    Powered by phpBB © 2001, 2005 phpBB Group
    Template created by Avatar & BurnIt!
    Debug: page generation = 0.12259 seconds, sql queries = 29