[WIP] MSCI Hand Book Update - Give your Input and Help.

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

mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

[WIP] MSCI Hand Book Update - Give your Input and Help.

Post by mark_a_condren »

We all know the MSCI Hand Book Needs Updating.

Give your help to make it Happen.

Some time ago i started to make notes for myself while trying the learn the script engine. This resulted in bits and pieces everywhere, so i was compiling them into my own MSCI updated version for personal use.

Over time people have asked to use it and i have provided them with a copy of what i had.

This work is by far a long way from complete as i don't know the correct info, DO YOU ? If you do, then why not help. After some failed attemps at getting assistance privatly im going public.

Do you have some snipets of info you have gleaned from your expeiriences while scripting? They don't have to be formatted or layed out all neat, just send it in so it can be added the the info already on hand.

Info can be sent in via any means you like, upload and provide a link, send via email (my email address is at the bottom of the post next to my PM link). Post a link here or send me a PM, however you want to do it i don't care, just do it. Strap it to a pigions butt feathers and give it my address and send it, i'll feed the pigion when it gets here and send it back.

This is a link to the Open Office Document i have so far, download, look through it add some info, correct some you think is incorrect, just send back the edited page(s) or the whole doc with a note as to what you edited (so i can find it).

Download latest Version
Open Office Document:
Version 1

http://code.google.com/p/x3tcscripts/do ... t&can=2&q=


PDF Document:
Version 1

http://code.google.com/p/x3tcscripts/do ... f&can=2&q=


Oh, the Disclaimer;
I will make all submitted work and info Publically available to all.
Don't send info with a note "I found this little secret, but keep it to yourself". Cos i won't, i'll spread it like a rash at a swingers party.

Please, come on people lets get some updated info out there for new and experienced users alike to use.

I'll be doing some more work on it soon so if i can get some added info before then, great, more to work with.

As i do updates to the Doc i'll post them here so you can get the latest info we have for you to add to.

Bag me if you like for trying this, your loss, show how much smarter you are by providing some info we don't have. I Dare You!

MarCon
Last edited by mark_a_condren on Mon, 23. Aug 10, 14:51, edited 1 time in total.
ThisIsHarsh
Posts: 1135
Joined: Sun, 19. Oct 08, 18:46
x3tc

Post by ThisIsHarsh »

I'll try to help if I can, but a couple of points first:

What about updating moggy2's Xai Corp MSCI reference? I can understand an offline reference would be handy, but it may be better to update the online reference, then create an offline version from it.

Also, if you are intent on pursuing an odt file, bear in mind the Edit->Changes menu, where you can track changes to the file - useful for co-authoring.
There are 10 types of people in the S&M forums - those who understand binary, and those who don't.

Black holes are where God divided by zero.
mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren »

The updating of the online reference would be good i admit, but i have to start somewhere and i chose here like this. If someone wants to update the online reference from it, by all means do so.

I chose .odt because i don't have the facilities to creat a PDF as don't most other people. Open Office people can get for free if they dont have an office suite already, or they can open and edit it with a microsoft product if they so wish. i had to choose something so i chose .odf.

However for the finished document i'm looking at a colabaration to create a PDF document with another scripters work. I'm doing more along the lines of the script commands and there functions descriptions, while the other works will be more towards how to compose and assemble the commands to achieve a desired result in your script.

Thus any and all info in regards to either area is most welcome, be it the commands themselves or how to used and apply them in practice.

MarCon
dillpickle
Posts: 1159
Joined: Mon, 3. Nov 08, 14:25
x3tc

Post by dillpickle »

mark_a_condren wrote:I chose .odt because i don't have the facilities to creat a PDF as don't most other people....
Open Office can convert to PDF - File -> Export as PDF.
mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren »

Open Office can convert to PDF - File -> Export as PDF.
Yes i know, but thanks for the pointer anyway.

just trying to keep it simple and in one format.

However OP will now has PDF version as well.

MarCon
mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren »

Ok,

So after 138 downloads of the doc, no one has anything to add to it?

So far for all the dl's i have had 'zero' info returned on any of the commands.

Would anyone like to be the first?


MarCon
User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz »

Tags for typical special characters that can be used in TFiles:

Code: Select all

Cop ©
ä ä  ä
ö ö  ö
ü ü  ü
Ä Ã„  Ä
Ö Ã–  Ö
Ü Ãœ  Ü
ß ÃŸ  ß
¼ ü
» »
« «
<  <   (WORKS in TFiles but annihilates scripts
>  >   if entered directly in the script file)
() \( \)
% \%


Colours:  (TC log book messages are displayed blank if any colours are in message or ship name)
\33X default grey
\33Y
\33B
\33R
\33G
\33C Cyan
\33M magenta / purple
\33A grey
\33W WHT
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Have you considered doing something like a google document, so everyone can edit it online (and so there are negligible concurrency issues?)


It has some cool features like headings automatically add to the table of contents, bookmarking. (And it has 6 "headings" so you can have up to 5 nested levels + the base)

Some things that are a bit odd thou is, it has a "page size" but that only affects the width, it is one continuous document


And no BBC code!!! (which drives me crazy >:S)
mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren »

s9ilent

Actually, no i hadn't considered Google Docs, i'll have a look into it as soon as i get a chance. I've never used or looked into it before. Thanks for the suggestion.
And no BBC code!!! (which drives me crazy > :S )

Now that's something i can relate to :cry:


MarCon
User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz »

Litcube wrote:$Numbers = sort array $Numbers
write to player logbook $Numbers
Output: ARRAY(1, 12, 2, 24, 4, 6)

$Numbers = sort array: data=$Numbers sort values=$Numbers
That works fine, however.
sort array apparently sorts by string values only. (these were integers)
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.
mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren »

Gazz wrote:
Litcube wrote:$Numbers = sort array $Numbers
write to player logbook $Numbers
Output: ARRAY(1, 12, 2, 24, 4, 6)

$Numbers = sort array: data=$Numbers sort values=$Numbers
That works fine, however.
sort array apparently sorts by string values only. (these were integers)
Ok, just did quick test. Added some strings and 'Integers' to an array,

Code: Select all

001   
002   $test.array =  array alloc: size=0
003   append 'A' to array $test.array
004   append 'D' to array $test.array
005   append 'C' to array $test.array
006   append 'B' to array $test.array
007   append 2 to array $test.array
008   append 1 to array $test.array
009   append 3 to array $test.array
010   
011   
012   $ret =  open custom menu: title='Info' description=null option array=$test.array
013   
014   $test.array =  sort array $test.array
015   
016   $ret =  open custom menu: title='Info' description=null option array=$test.array
017   
018   
019   return null
020   
First menu, as you would expect, in the order added,
[ external image ]

Second array, after 'sort array' command, seems to be sorted to me?
[ external image ]


Where did you get Litcube's quote from Gazz ?

EDIT:

Ok, desided to do some more tests with 'Just Integers' in the array. Used Litcube's numbers as shown in quote, and it did sort them, but not as expected. It sorted them buy the 'first' didget then buy the second and so on.

Here is example, with 2 more numbers added to the bottom for demonstration purposes.

Code: Select all

002   $test.array =  array alloc: size=0
010   
011   append 1 to array $test.array
012   append 12 to array $test.array
013   append 2 to array $test.array
014   append 24 to array $test.array
015   append 4 to array $test.array
016   append 6 to array $test.array
017   append 35 to array $test.array
018   append 31 to array $test.array
019   
020   
021   
022   $ret =  open custom menu: title='Info' description=null option array=$test.array
023   
024   $test.array =  sort array $test.array
025   
026   $ret =  open custom menu: title='Info' description=null option array=$test.array
027   
028   
029   return null
First menu as you would expect, in added order,
[ external image ]

But look at the second 'sorted' menu
[ external image ]

Now that is strange!! See how its done a 'primary' sort by the first didget, and then a 'secondary' sort by the second didget. That is a very 'old' way for a computer to sort numbers.

MarCon
Last edited by mark_a_condren on Sat, 20. Nov 10, 14:27, edited 1 time in total.
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Where did you get Litcube's quote from Gazz ?
From here.
Second array, after 'sort array' command, seems to be sorted to me?
Yes, it seems to be some kind of lexicographical sorting instead of "real" sorting. But since you can use the " = sort array: data=... sort values=..." - command, this isn't much of a problem.

Greetings,
ScRaT
mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren »

Thanks ScRaT_GER

I did some more testing and edited my post above before seeing you had posted here.

Interesting results none the less. Yes as you can use the other sort command it is not such an issue.

lexicographical ... ??? ... ok, going to find me a dictionary ....


MarCon
User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz »

In layman's terms it's simply doing a string sort (on integers) where "12" naturally comes before "2"
because "1" comes before "2".
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

I'm fairly certain it is actually doing a string sort for the first one and the second one (with the 2 arguments) is doing a numeric sort. Although it would be interesting to see what happens when you provide non numeric input in the second case.
mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren »

s9ilent wrote:Although it would be interesting to see what happens when you provide non numeric input in the second case.
Let's find out shall we?

Code: Select all

001   
002   $test.array =  array alloc: size=0
019   
020   append 'def' to array $test.array
021   append 'ghi' to array $test.array
022   append 'lmn' to array $test.array
023   append 'abc' to array $test.array
024   append 'quv' to array $test.array
025   append 'opq' to array $test.array
026   append 'rst' to array $test.array
027   append 'jkl' to array $test.array
028   append 'uvw' to array $test.array
029   append 'yrh' to array $test.array
030   append 'rss' to array $test.array
031   
032   
033   $ret =  open custom menu: title='Info' description=null option array=$test.array
034   
035
036   $test.array =  sort array: data=$test.array sort values=$test.array
037   
038   $ret =  open custom menu: title='Info' description=null option array=$test.array
039   
040   
041   return null
and the results are,
[ external image ]

and
[ external image ]

Seems to work ok.

MarCon
A.Persyn
Posts: 121
Joined: Sun, 14. Mar 10, 13:14
x3tc

Post by A.Persyn »

Actually, that command is even more powerful.

[ external image ]

Copy and paste into Exscriptor (it's easier to read there), save and run it in X3TC.

Code: Select all

* Allocate the parent array with a size of zero since the child arrays will be appended to it

$twoD.array = array alloc: size=0
 
* For this example, Brennan's Triumph was used because it only has five stations,
* so that all the sorted stations could be seen in the screenshot.
 
* Create an array of all the stations in the sector

$stations.array = [SECTOR]->get station array from sector
 
* Get the size of $stations.array (in this case, five).

$stn.count = size of array $stations.array
 
while $stn.count > 0 
  dec $stn.count =
   
  * Step through each element in the array decrementing from five to one

  $stn = $stations.array[$stn.count]
   
  * The value of $dist will vary depending on where you are in the sector

  $dist = get distance between $stn and [THIS]
   
  * This is where each child array is created and each one will have two elements (0,1)

  $stn.dist.array = create new array, arguments=$dist, $stn, null, null, null
   
  * Each while loop will add another child to the parent array
  * When complete, the parent array will have five child arrays (0,1,2,3,4)

  append $stn.dist.array to array $twoD.array
   
  = wait 10 ms
end
 
* Allocate the reference arrays that will be used for sorting

$stn.array = array alloc: size=0
$dist.array = array alloc: size=0
 
$menu = create custom menu array
 
* **********************************************************************
$title = 'Unsorted Stations' 
add custom menu heading to array $menu: title=$title
 
$size = size of array $twoD.array
 
while $size 
  dec $size =
   
  * To extract each child array from the parent array, $twoD.array will be read backwards
  * and then decremented during the while loop until all the indexes have been read

  $oneD = $twoD.array[$size]
   
  * The first element of $oneD is the distance (index zero)
  * The second element of $oneD is the station(index one)
  * ex: array(distance, station)

  $dist = $oneD[0]
  $stn = $oneD[1]
   
  * $stn.array and $dist.array will be used as references for the actual sorting

  append $stn to array $stn.array
  append $dist to array $dist.array
   
  $text = create text for custom menu, left=$stn, right=$dist
   
  add custom menu item to array $menu: text=$text returnvalue=null
end
 
* $stn.array and $dist.array are now in the opposite order from $twoD.array (4,3,2,1,0) vs (0,1,2,3,4)
* $twoD.array also needs to be reversed so it lines up correctly with them before the sorting

$twoD.array = reverse array $twoD.array
 
* **********************************************************************
$title = 'Stations Sorted by Name' 
add custom menu heading to array $menu: title=$title
 
* $stn.array will be the array that gets sorted but the indexes of $twoD.array will be re-order to match.
* $twoD.array is not the array that is being sorted, in fact the contents of $twoD.array are irrelevant.
* The only things that matter are that the arrays are the same size and the indexes are in the same order (4,3,2,1,0)
* The relationship between the two arrays is by index and not by the contents of that index (0 to 0, 1 to 1, etc.).
* After sorting, the index order of $stn.array becomes (0,4,1,2,3) and $twoD.array's indexes will be re-ordered to match it
* $sorted.array gets the contents for each index from $twoD.array and the index order from the sorted $stn.array.
* Neither $stn.array nor $twoD.array will actually change.

$sorted.array = sort array: data=$twoD.array sort values=$stn.array
 
* $sorted.array is in alphabetical order but since it will be read backwards into the menu,
* it needs to be reversed first so the menu list will appear correctly (A to Z).

$sorted.array = reverse array $sorted.array
 
$size = size of array $sorted.array
while $size 
  dec $size =
  $oneD = $sorted.array[$size]
  $dist = $oneD[0]
  $stn = $oneD[1]
   
  $text = create text for custom menu, left=$stn, right=$dist
   
  add custom menu item to array $menu: text=$text returnvalue=null
   
end
 
* **********************************************************************
$title = 'Stations Sorted by Distance' 
add custom menu heading to array $menu: title=$title
 
* After sorting, the index order from $dist.array will be (4,2,0,3,1) and it wiil be applied to $sorted.array
* with the content from $twoD.array.
* Take note that in both sorts, the sorting was done using $twoD.array for the 'data=' entry. $sorted.array is only
* used for displaying the data in the chosen order for the menu. If the previous sorting had been written as:
* $twoD.array = sort array: data=$twoD.array sort values=$stn.array
* then $twoD.array, at this point in the script, would now be out of order and could not be accurately sorted a second time.

$sorted.array = sort array: data=$twoD.array sort values=$dist.array
 
* $sorted.array is now in numerical order from lowest to highest but since it will be read backwards
* into the menu, it needs to be reversed first so the menu list will be in ascending order.

$sorted.array = reverse array $sorted.array
 
$size = size of array $sorted.array
while $size 
  dec $size =
  $oneD = $sorted.array[$size]
  $dist = $oneD[0]
  $stn = $oneD[1]
   
  $text = create text for custom menu, left=$stn, right=$dist
   
  add custom menu item to array $menu: text=$text returnvalue=null
   
end
* **********************************************************************
$menu.title = 'Sorting 2-Dimensional Arrays' 
$menu.desc = 'Fun with 2D Arrays' 
= open custom menu: title=$menu.title description=$menu.desc option array=$menu
 
return null
 
 

A.Persyn
User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube »

As Gazz stated, the sort array command is simply a text sort. Numbers are all converted to text before the sort takes place. Pretty s!@#ty implementation.

The new sort data by values works fine, however, and no string conversion takes place.
User avatar
Lordaeron
Posts: 501
Joined: Tue, 17. Jul 07, 16:51
x4

Post by Lordaeron »

I figured out something interesting yesterday, that should be added.

Code: Select all

<RefObj> set local variable: name = <Var/String> value = <Value>
<RefObj> can also be a Marine or Passenger, which seems to be new.


EDIT:

same with...

Code: Select all

<RetVar> = <RefObj> get ID code
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

@Lordaeron

RefObject can be ANY "in game" object. (I use the phrase "in game" because to between object (object orientated programing), and a physical object in the game)

These include:
passengers/ship/station/floating ware/flying missile/astronaut/space fly/asteroid/gate

In game objects with funky rules to them:
debris

Some things which I am not sure about include :
planets
suns
sectors
~other misc junk, e.g. the xenon hub's dyson sphere, the asteroid you fly down in X3R, Aldrin

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