[Discussion] Generic X3TC S&M questions II

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

User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

I tried that first, I've already got all the calcs up now, with just 2 remaining questions. (and a statement)

1. M6M? :wink:

2. Is it the Phoenix?

3. My computer is refusing to let me access the XML for the script, so I'm afraid it'll be a picture of the code on Photobucket, as I can't be bothered to upload.

(Unless someone says I definitely should)
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Texty script is always better then pictures IHMO (As x3 has tiny text and picture compression looses quality). (Are you sure you have the x2script.xls schema in the folder your trying to view the script from?)
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Allright, got the x2 script out of the piles of scripts.

Now,

here goes. (note, comments at the end are unfinished, I'm explaining things to you as best as I know)


The question is, if all the data went in correctly, would this work, or should I just go mad now. (I know what the next reply is going to be;
'Quote: *My script*. <- You see, you just can't do that! The next line's, wrong... mistake on the one after that... wrong variable there...' :oops:


EDIT: Oops, explanation would do well!

It's a bounty system upon ship death. A reasonable worth of the ship and frieght is transferred to the killer, and it builds up until the player kills them, and if they're an enemy of the race th eplayer is working for military wise, they get paid out.

And, I forgot to mention the ship worth calcs aren't right because, well, M6M etc...



EDIT2: Seeing it line dup nicely like that makes mistakes a bit more obvious. I need an End after line 11

Code: Select all

001   * Basic stats...
002   $arr =  get warearray for [THIS]
003   $mil = get global variable: name='ej.player.which.military'
004   
005   $att = [THIS] -> get attacker
006   $race = [THIS] -> get owner race
007   skip if $att == Player
008   |$attrace = $att -> get owner race
009   $bounty = [THIS] -> get local variable: name='ej.bounty'
010   if $bounty == null
011   |$bounty = 0
012   |send incoming message 'Step1. Stats' to player: display it=[TRUE]
013   |
014   * Multipliers for attackers.
015   |
016   * All races x2 for X,K,Y and Enemy Race
017   * All races x2 for their Enemy
018   * All races x2 for Pirates except Teladi (x1)
019   * All races x0 for any other kills. You dont get paid for friendly fire!
020   |
021   * If the players military, or the race of the attacker is...
022   |
023   |if $mil OR $attrace == Argon
024   ||if $race == Paranid OR Pirates
025   |||$multiplier = 2
026   ||else
027   |||$multiplier = 0
028   ||end
029   ||
030   |else if $mil OR $attrace == Boron
031   ||if $race == Split OR Pirates
032   |||$multiplier = 2
033   ||else
034   |||$multiplier = 0
035   ||end
036   ||
037   |else if $mil OR $attrace == Split
038   ||if $race == Boron OR Pirates
039   |||$multiplier = 2
040   ||else
041   |||$multiplier = 0
042   ||end
043   ||
044   |else if $mil OR $attrace == Paranid
045   ||if $race == Argon OR Pirates
046   |||$multiplier = 2
047   ||else
048   |||$multiplier = 0
049   ||end
050   ||
051   |else if $mil OR $attrace == Teladi
052   ||if $race == Pirates
053   |||$multiplier = 1
054   ||else
055   |||$multiplier = 0
056   ||end
057   ||
058   * If the the race of the attacker is... (player cant join mil. for these races)
059   ||
060   |else if $attrace == Yaki
061   ||$multiplier = 2
062   ||
063   |else if $attrace == Terran
064   ||$multiplier = 0
065   ||
066   |else if $attrace == ATF
067   ||$multiplier = 0
068   ||
069   |else if $attrace == Pirates
070   ||if $race == Teladi
071   |||$multiplier = 1
072   ||else
073   |||$multiplier = 2
074   ||end
075   ||
076   |else if $attrace == Enemy Race
077   ||$multiplier = 2
078   ||
079   |else if $attrace == Kha'ak
080   ||$multiplier = 2
081   ||
082   |else if $attrace == Xenon
083   ||$multiplier = 2
084   ||
085   |end
086   |
087   * If the killed ship is X,K,Y or ER, it x2 to the killer to overide x0s above!
088   |
089   |if $race == Xenon OR Kha'ak OR Yaki OR Enemy Race
090   ||$multiplier = 2
091   |end
092   |
093   |send incoming message 'Step2. Multis' to player: display it=[TRUE]
094   * Works out worth of ship.
095   |
096   |$waretype = [THIS] -> get ware type code of object
097   |$relval =  get relvalue of $waretype
098   |if [THIS] == M7
099   ||$shipbase = ( $relval * 65555784 ) / 1000000
100   |else if [THIS] == Colossus
101   ||$shipbase = ( $relval * 49892 ) / 1000
102   |else if [THIS] == Phoenix OR Titan
103   ||$shipbase = ( $relval * 50299 ) / 1000
104   |else
105   ||$shipbase = ( $relval * 807212 ) / 10000
106   |end
107   end
108   send incoming message 'Step3. Values' to player: display it=[TRUE]
109   
110   * Works out worth of ships items as minimal
111   $count =  size of array $arr
112   while $count
113   |dec $count = 
114   |$item = $arr[$count]
115   |$itemworth = get min price of ware $item
116   |$worth = $worth + $itemworth
117   |send incoming message 'Counting through the ships wares...' to player: display it=[TRUE]
118   end
119   
120   * Works out worth of ships items plus the base ship cost
121   $finalworth = $worth + $shipbase
122   
123   * Player is killer - recieves previous bounties plus worth, affected by a Xplier.
124   if $att == Player
125   |$finalpayout = ( $bounty + $finalworth ) * $multiplier
126   |add money to player: $finalpayout
127   |send incoming message 'You just recieved...' to player: display it=[TRUE]
128   |
129   * Player isnt killer - killer gets worth added to its bounty, which is now found.
130   else if $att != Player
131   |$bounty = $att -> get local variable: name='ej.bounty'
132   |if $bounty == null
133   ||$bounty = 0
134   ||$bounty = ( $bounty + $finalworth ) * $multiplier
135   ||$att -> set local variable: name='ej.bounty' value=$bounty
136   |end
137   end
138   
139   * Notes
140   
141   * Killed ships belonging to player pass the item & ship worth on when killed.
142   * As you, the pilot, is not dead, theres no bounty.
143   
144   * Bounties betweem race doesnt matter.
145   * EG. Pirate kills Xenon, Player as Argon mil. kills Pirate.
146   * Bounty passed on contains a Xenon kill by the pirate.
147   * Surely thats good for the military!? No. Reasoning as such:
148   * Pirate survives Xenon attack, is obviously skilled & a threat therefore.
149   * Pirate -> Xenon bounty is passed on to the player.
150   * Lets say the multiplier has made it huge, Pirates killing Boron.
151   return null
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Heh, I made like everyone of the mistakes you made on my first attempt of a script :P
(p.s I copied and pasted everything into exscriptor so for indentation, so my line numbers are probably wrong when compared to yours) Ok from the top!


Line 6 -Handy tip
$race = [THIS] -> get owner race
You can use [OWNER], which is identicaly equal to [THIS]->get owner race

Line 23+ -Handy tip
First huge block of If's and else if's
You should probably have an else in there (just a flat else) to catch unwanted outcomes (it will help in debugging). An error handler here will save much frustration in the future
e.g. else write to player log book, error unexpected race/military + $mil + attrace


line 99 Possible bug/limitation
$shipbase = ( $relval * 65555784 ) / 1000000
will almost certainly cause overflow errors :(
i.e. The max number is... 2 billion ((2^31) -1) The maths is done from left to right, so if $relval * 65555784 > 2^31 it will overflow. So check to make sure that it is under this limit, other wise change it to something like
( $relval * 6555578 ) / 100000
Or better yet, take out some common factors of both numbers. Hmm... open office is telling me its exactly 6555578 ) / 100000 =65 + 5/9 thou you may want to check, it may be rounding
8194473 125000 is a simple /2 factorisation of the two numbers (div 8)


Line 97 Bug
if [THIS] == M7
else if [THIS] == Colossus
else if [THIS] == Phoenix OR Titan
else if [THIS] == Phoenix OR Titan
1. [THIS] is a specific OBJECT, Colossus is a waretype argon_m1_1 (or similar). So the two are not comparable. What you need to do is
$waretype == colossus (where $waretype = [THIS] -> get ware type code of object)
2. else if [THIS] == Phoenix OR Titan is not a valid statement. You can not go if a == b or c. You must go if a == b or a == c

Line 111 -pretentious/cautious tip
while $count
dec $count =
This works fine, but I always use while $count > 0, for extra safety (in case I do something tricky mid loop and minus 2 from count, going to minus 1, thus causing and infinite loop)

Line 111 still -Script purpose?
$count =  size of array $arr
while $count
dec $count =
$item = $arr[$count]
$itemworth = get min price of ware $item
$worth = $worth + $itemworth
send incoming message 'Counting through the ships wares...' to player: display it=[TRUE]
end
Don't you need to count how many of each ware there is to get a true measure of value? (e.g. 2x shields => 2x shield value) (Use Get amount not get free/max/true))


Line 130 Bug?
if $att == Player
$finalpayout = ( $bounty + $finalworth ) * $multiplier
add money to player: $finalpayout
send incoming message 'You just recieved...' to player: display it=[TRUE]

* Player isnt killer - killer gets worth added to its bounty, which is now found.
else if $att != Player
Once again, a variable type mismatch. $att is the attacker from the top of the script. Player is a race. I think you mean to use [PLAYERSHIP]
Last edited by s9ilent on Wed, 7. Apr 10, 10:27, edited 3 times in total.
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Just because me and Mark beat you for that last one? :wink:

Anyway, if people were so eager I'd be glad!
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Ok Jon, above post edited
:P
Oh btw, other script advice
1. Exscriptor is awesome
2. Using custom x2script.xls (e.g I took someones and modified it link will allow you to do awesome copying and pasting with colour tags (thou... this only seems to work with fire fox... and also this scheema isn't mine, it is someone else but I don't remember who the original person was... "may" have been uni trader)

Example copy and paste


008 while [TRUE]
009 |$victim = null
010 |
011 |
012 * Should the turrets be active
013 |if [THIS] -> is docked
014 ||set script command target: null
015 ||@ = wait randomly from 60000 to 80000 ms
016 |else if not [THIS] -> get max laser strength in turret $turretid
017 ||set script command target: null
018 ||@ = wait randomly from 10000 to 15000 ms
Last edited by s9ilent on Wed, 7. Apr 10, 10:26, edited 1 time in total.
TwilightWalker
Posts: 35
Joined: Sun, 23. Sep 07, 09:35
x4

Post by TwilightWalker »

SS_SH_T_M2 is indeed the ID for the Phoenix

M6Ms seem to appear in the ship IDs to designate the 'Heavy' Corvettes.

For example...

Osprey: SS_SH_T_M6
Heavy Osprey: SS_SH_T_M6M

This is just from digging around in the X3 Editor 2, looking at the TShips file.

Can someone answer a question of my own? What value determines how many marines a ship can carry? Making a few special ships of mien carry 30 marines like that OTAS frigate would be nice. I've tried looking myself, but I can't seem to find it.
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Heh, I made like everyone of the mistakes you made on my first attempt of a script
(p.s I copied and pasted everything into exscriptor so for indentation, so my line numbers are probably wrong when compared to yours) Ok from the top!


Line 6 -Handy tip
$race = [THIS] -> get owner race
You can use [OWNER], which is identicaly equal to [THIS]->get owner race
Thanks
Line 23+ -Handy tip
First huge block of If's and else if's
You should probably have an else in there (just a flat else) to catch unwanted outcomes (it will help in debugging). An error handler here will save much frustration in the future
e.g. else write to player log book, error unexpected race/military + $mil + attrace
Thanks


line 99 Possible bug/limitation
$shipbase = ( $relval * 65555784 ) / 1000000
will almost certainly cause overflow errors
i.e. The max number is... 2 billion ((2^31) -1) The maths is done from left to right, so if $relval * 65555784 > 2^31 it will overflow. So check to make sure that it is under this limit, other wise change it to something like
( $relval * 6555578 ) / 100000
Or better yet, take out some common factors of both numbers. Hmm... open office is telling me its exactly 6555578 ) / 100000 =65 + 5/9 thou you may want to check, it may be rounding
8194473 125000 is a simple /2 factorisation of the two numbers (div 8)


Gulp?

Line 97 Bug
if [THIS] == M7
else if [THIS] == Colossus
else if [THIS] == Phoenix OR Titan
else if [THIS] == Phoenix OR Titan
1. [THIS] is a specific OBJECT, Colossus is a waretype argon_m1_1 (or similar). So the two are not comparable. What you need to do is
$waretype == colossus (where $waretype = [THIS] -> get ware type code of object)
2. else if [THIS] == Phoenix OR Titan is not a valid statement. You can not go if a == b or c. You must go if a == b or a == c
1. But then it's an object class or a waretype. Still incompatible?
2. I'm sure that works... :?
Line 111 -pretentious/cautious tip
while $count
dec $count =
This works fine, but I always use while $count > 0, for extra safety (in case I do something trick mid loop and minus 2 from count, going to minus 1, thus causing and infinite loop
Line 111 still -Script purpose?
$count = size of array $arr
while $count
dec $count =
$item = $arr[$count]
$itemworth = get min price of ware $item
$worth = $worth + $itemworth
send incoming message 'Counting through the ships wares...' to player: display it=[TRUE]
end
Don't you need to count how many of each ware there is to get a true measure of value? (e.g. 2x shields => 2x shield value) (Use Get amount not get free/max/true))
Didn't think of that!
Line 130 Bug?
if $att == Player
$finalpayout = ( $bounty + $finalworth ) * $multiplier
add money to player: $finalpayout
send incoming message 'You just recieved...' to player: display it=[TRUE]

* Player isnt killer - killer gets worth added to its bounty, which is now found.
else if $att != Player
Once again, a variable type mismatch. $att is the attacker from the top of the script. Player is a race. I think you mean to use [PLAYERSHIP]
No, it's if it's any player craft, not just the playership. I'm right there... :wink: [/quote]
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Wow.

Ok, just looked through it, fixed some problems.

1. Are you sure I can't say or this or this or this.

I've got a feeling you can't but I've got a feeling it worked in the past too. :oops:

2. With the RelVal, would it be easier to:

10000thR = Relval/10000
10000thCode = 807212/10000

then times them together, or is my maths off again?

3. So I need to get all M7Ms and Heavy corvettes!? :evil: Are M7Ms classed also as M7? As they have no class I'll guess so. That leaves M6M. Is there a way to check:

Does ship have Heavy in it's object name?
Is it an M6?


I'll wait for a few answers, give everything my best shot, then repost. :oops:
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Just to clear up some definition
An "in game object" is a real live thing that exist in game which does exist, and can be destroyed.

A type of object, is a "waretype". (This is analogous to ship type, as ships-types are wares too)

An "object class" is a grouping of several different types of objects. The object class is defined in the tfiles (i.e. by the waretype), and also by the object class it self. i.e. In tships, there is an argon nova which is an M3. M3's are an object class (called M3), which are also object classes Fighters, Little Ships, Movable ships, Ship, Object. (See Anex A.5 in the MSCI) (Although, do not get this object confused with my above reference to an object)

And from this point onwards, when I say object, I am refering to an In Game Object. (Because the object class object is like never ever used)


@ 1. But then it's an object class or a waretype. Still incompatible?
[THIS] will only ever be either an object, or null.
"Colossus" represents waretype colossus.
So the two are never equal, in much the same way Integer 1 is not equal to String "1"


@ 2. I'm sure that works... Confused
else if [THIS] == Phoenix OR Titan
When the game sees this statement it will always return [TRue]

It does the following:
i) [This]== Phoenix
=> [FALSE]
Because of the above reason, the data types are different (object is not equal to ware type/ship type) so the result is false
ii) [FALSE] OR Titan
=> [TRUE]
Because Titan is not null, so it counts as [TRUE]. So the statement effectively becomes [FALSE] OR [TRUE]. And that becomes [TRUE]






@ No, it's if it's any player craft, not just the playership. I'm right there..
if $att == Player
In which case, your once again equating and different variables so the result is always false
object $att
race Player

You need to do $att.race = $att-> get owner
(or get true owner, thou I don't know of too many scripts that use true owner, everyone just tends to use owner unless they SPECIFICALLY use the true/fake owner stuff)
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

You need to do $att.race = $att-> get owner
My bad, that was meant to be the race.

I'll go through an tunr all the ors to or this equals... will take a while...

I've also done the waretypes, so now it says else if $waretype = Colossus, not THIS = Colossus, correct?
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Not solved any of the above about the ships or how to avoid the overflow easier... (Bad at maths...)

It works so far, but seems to run twice. (Signals often trigger a script twice is what I've heard, a bug)

The problem is, I've set it to get a global variable, and if it isn't TRUE set it to true carry on. So the second time it should see that it's true, and end.

Problem is... it runs twice. Still.

:?
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

I'm going to be out for the rest of the week, so everyone else, feel free to step in

1. "Not solved any of the above about the ships" Which bit of code is this referring to?

2. The way to avoid overflow is to reduce accuracy. Firstly, *8194473 /125000 is the smallest factorization that I'm aware of that looses no accuracy. So after this you have to start loosing accuracy and use numbers like
817447 /12500 or even 81745/1250
Just keep dropping digits until maxrelval * 817xxxx is less then 2^31 (2.2~bilion)

3. Running twice. Sometimes signals fire twice, I think Gazz knows the most about it. Try using a local variable instead. This way you don't have the globalization problem.
if [THIS] get local var xxx
* is already running
-return null
-end
*else is not running so
[THIS] set local var xxx to [TRUE]
(And you should never need to set it to false again)
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

1. I meant the working out if it's a 'M6M' problem.

2. But could you do it my way, that I suggested, instead of multiplying them together then dividing to get the correct decimal, divide them first then multiply them together...?

3. :evil: I didn't realise I was using a Global until you told me that I should use a local. Then I thought 'But I am... no wait, I'm using a Global... why did I do that!?' :lol:
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
Argonaught.
Posts: 1827
Joined: Wed, 6. Nov 02, 20:31
x4

Post by Argonaught. »

noob MD question time again :S

In the director.htm, player - Variables relating to the player

How would i use this:
{player.sector.name}

Do i add a name where it says .name? or do I add in an @ like this:
{player.sector.name@sector} sector being replaced with whatever the sector name is?

If I can understand how to use variables like that I think I can begin to get to grips with bigger code than I can use already.

Thaniks in Advance.
[MOD]X3TC No Fog / [MOD]X3AP No Fog / [MD]X3TC Menagerie Shipyard / [MD]X3AP Menagerie Shipyard
<==<<Argonaught>>==>

XBTF>XT>X2TT>X3R>X3TC>X3AP>X4F

I lurk alot for the most part now
:thumb_up:
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

{player.sector.name@sector} sector being replaced with whatever the sector name is?
There is only one player sector, which is the sector the player currently flies in. Thus you don't need the "@".
This is true for all player commands.

If you're using the normal {player.sector.name@sector} you need to replace the second "sector" with a sector of your choice, e.g. as given in the director.htm {player.sector.name@argonprime}.
However normally you would not type "argonprime" yourself, but you'd use a <find_sector> command instead.

Greetings,
ScRaT
User avatar
Argonaught.
Posts: 1827
Joined: Wed, 6. Nov 02, 20:31
x4

Post by Argonaught. »

What i'm actually trying to understand is how those variables are used.

How would I use that variable if I wanted to send a message to the player if he was in a certain sector.

Lets say the sector is Argon Prime and when he enters he gets a message?

The <Do_if> bit would suggest to me that there would be a way of checking everything, in the file and game, but the the do_if code options don't list player code.

Is the MD missing a ton of stuff that should be in it but wasn't implemented?

If you could provide a bit of code for it's use and where it belongs it'd help abit hopefully.

Some of this stuff still goes way over my head :(

Argo.
[MOD]X3TC No Fog / [MOD]X3AP No Fog / [MD]X3TC Menagerie Shipyard / [MD]X3AP Menagerie Shipyard
<==<<Argonaught>>==>

XBTF>XT>X2TT>X3R>X3TC>X3AP>X4F

I lurk alot for the most part now
:thumb_up:
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Have a look at the X3: Mission Director Support Files, especially at the XMDGuide, which explains very much.
Is the MD missing a ton of stuff that should be in it but wasn't implemented?
No, that's not the case. Almost all commands are usable correctly.
How would I use that variable if I wanted to send a message to the player if he was in a certain sector.

Lets say the sector is Argon Prime and when he enters he gets a message?

Code: Select all

<cue name="SendMessage">
  <condition>
    <check_value value="{player.sector}" exact="{sector@argonprime}"/>
  </condition>
  <action>
    <incoming_message author="Argonaught." text="You're in Argon Prime"/>
  </action>
</cue>
Something like that. I didn't test it though, so there might be errors - and the MD is very picky about errors...

Greetings,
ScRaT
User avatar
Ketraar
EGOSOFT
EGOSOFT
Posts: 12099
Joined: Fri, 21. May 04, 17:15
x4

Post by Ketraar »

As pointed out player.* variables refer usually to unique stuff, like player.sector being always! the current sector the player is in, or player.ship being the player's current ship, etc...

player.sector.name would result in the sector name of the current player sector, sounds complicated but its easy once you get used to this sort of thinking. An easy way to understand is to read it backwards.
Example:
{player.sector.name} -> The name of the sector of the player

The player variables are just "short-cuts" to the regular object.* variables, where one could use {object.sector.name@player.ship} giving the exact same result. Get used to MD having multiple ways to address an issue.

Note that to handle objects, sectors, etc other than player.stuff, you have to reference them, as in set to tracking for the MD to "know" them. You do that by "naming" them using the the name="" attribute in either the find_* or the create_* actions. Once referenced objects and stuff can be used in variables.
Small example:

Code: Select all

  <cues>
    <cue name="Testcue_top">
      <condition>
        <check_all>
          <check_value value="{player.name}" exact="whatever"/>
        </check_all>
      </condition>
      <action>
        <do_all>
          <find_sector name="Testcue_top.sector1" x="8" y="8" min="0" max="10" comment="min/max sets the amount of jumps the search radius will be, a random sector within that radius will be found"/>
          <find_station name="Testcue_top.Station1" class="station" race="{sector.race@Testcue_top.sector1}">
            <sector sector="Testcue_top.sector1" comment="there is no need for brackets here since it asks for a sector already"/>
            <jumps exact="0"/>
          </find_station>
          <create_ship name="Testcue_top.Ship1" typename="SS_SH_A_M4" race="{sector.race@Testcue_top.sector1}" racelogic="0" comment="racelogic is default 1, but I set it to 0 as I want it not to wander about just like that">
            <position object="Testcue_top.Station1" comment="again no need for brackets here since it asks for a object" min="20km" max="50km"/>
            <sector sector="Testcue_top.sector1"/>
            <equipment loadout="maximum" loadoutmask="all"/>
            <command command="dock" commandobject="Testcue_top.Station1"/>
          </create_ship>
          <incoming_message author="debug" text="Sector: {sector.name@Testcue_top.sector1}/nStation: {object.name@Testcue_top.Station1}/nShip: {object.name@estcue_top.Ship1}"/>
        </do_all>
      </action>
    </cue>
  </cues>
Open the director.htm in IE for more variables, including a small description of its use.

The do_if and do_choose (with the sub node do_when) only use variables as checks. This basically does an action based on conditions which need to be meat. Basically you check a value set in a variable, and see if its a match to the conditions

Code: Select all

<do_if value="{player.age}" min="1m">
  <incoming_message author="debug" text="its true"/>
</do_if>
The do_if works like a "drive by", as it only allows one choice, either its true or it gets skipped. Although you can have (almost) endless do_ifs within do_if, but still once the checks don't fit, the action in it will just get ignored.

This is where you'll find that do_choose is one of the most powerful tools in MD. Multiple choice ftw :-D
You can have many do_when within do_choose, which like do_if checks two values, and one do_otherwise which has no value checks as it will do should none of the do_when be true.
Unlike do_if, in do_choose one can set several conditions to be checked, one in each do_when, the MD then will check from top to bottom every do_when until one is true, should none be true the do_otherwise triggers and the action in it will be parsed, should you have used it, if there is no do_otherwise and none of the do_when are true, no action will be parsed and all in do_choose will get ignored. Note that you can have many do_choose within do_choose.
Example:

Code: Select all

<do_choose>
  <do_when value="1" exact="0">
    <cancel_cue/>
  </do_when>
  <do_when value="2" exact="3">
    <set_target/>
  </do_when>
  <do_otherwise>
    <do_choose>
      <do_when value="7" exact="5">
        <abandon_ship/>
      </do_when>
      <do_otherwise>
        <eject_cargo/>
      </do_otherwise>
    </do_choose>
  </do_otherwise>
</do_choose>
An then there are do_any, do_all etpp... but that will have to wait for another time.

MFG

Ketraar

PS.: Feel free to link this in the MD Q/A thingy :-P
Last edited by Ketraar on Thu, 8. Apr 10, 11:25, edited 1 time in total.
Image
User avatar
Argonaught.
Posts: 1827
Joined: Wed, 6. Nov 02, 20:31
x4

Post by Argonaught. »

ScRaT_GER wrote:the MD is very picky about errors...
I've discovered that alot :S

@ Ketraar, I'll link it and study the code :)

Variables are killing me and giving me nightmares :(

I'm determined to get understanding of them though.

Thanks for the info guys :)

Argo.
[MOD]X3TC No Fog / [MOD]X3AP No Fog / [MD]X3TC Menagerie Shipyard / [MD]X3AP Menagerie Shipyard
<==<<Argonaught>>==>

XBTF>XT>X2TT>X3R>X3TC>X3AP>X4F

I lurk alot for the most part now
:thumb_up:

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