[Utility Scripts] MarCon utility files and Demo's

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

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

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

[Utility Scripts] MarCon utility files and Demo's

Post by mark_a_condren »

It seems i'm getting posts to links to some of my Utility Scripts and Demo files spread all through the forum threads. So to counter this and make any updates to them a whole lot easier, i'm going to post them in this thread and provide links to them from here.

Well it sounds good in theory anyway.


Demo Script :

Add value selection to menu :
This script is a bit of a demo on how you can use the 'add value selection' command in a menu.

This is especially useful for Option and Settings menus. Download it and have a look at how i did it and use any parts / ideas that you find useful.

The script is heavily commented to help.

Disclaimer:
This is only how i have found how to use it and in no way indicates the Best or Only way it can be used.

Download 'script' and 't' files from google code:
Add value selection to Menu Demo v1 Zip

Screenshot:
[ external image ]


An excellent tutorial on 'Add value selection' to menus by ScRaT_GER
can be found here.



Utility Script :

Clone Station or Shipyard v3
This script is useful if you need to clone a Station or Shipyard due to an installed Mod giving you trouble or any other reason and you need to create a replacement.

You may even just wish to boost the economy in your game or create specific station layouts in your game. This will help make it a lot easier.

This script can also be called by other scripts to perform the same funtion by supplying the script call arguments provided.

Also very useful for testing scripts and mods.

- Hotkey settable in controls menu.
- Target station and use hotkey.
- Follow the menu prompts.

NOTE:
This script will NOT work on Player owned Complexes !! (but it will clone NPC multi product factories :wink: )

Download 'script' files from google code:
SPK:
MarCon Clone Station v3 Spk

ZIP:
MarCon Clone Station v3 Zip




MINI Scripts :

Emergency Brake v1

Sets 2 hotkeys, one works on Player Ship and the other on the player tracking aim if it is a ship and owned by the Player.

Simple script code,
PlayerShip,
[ external image ]

Tracking Aim,
[ external image ]

Downloads,
SPK:
E Brake v1 Spk.

ZIP:
E Brake v1 Zip.

(All we need now is for someone to come up with a Mod for Airbags in TC)



Library Scripts :

Get All Sectors by Race v1.

Call this script and set the argument for the race you want and it will return an array of all the sectors in the universe belonging to that race. If you set the race to 'null', it will return an array of All the sectors in the universe.

If you use it, i would suggest a name change in case someone else uses it and mods the script.

This script is available for Download, see below.

Code: Select all

Version: 1
for Script Engine Version: 44

Description
Returns array of all sectors in Universe, race selectable.
Arguments
1: Race , Var/Race , 'Race, null = All :' 
Source Text

001   * --------------------------------------------------------------------------------
002   * Author : mark_a_condren   a.k.a   MarCon
003   * --------------------------------------------------------------------------------
004   * Created : May - 2010
005   * --------------------------------------------------------------------------------
006   
007   *$Testing = [TRUE]
008   $Testing = [FALSE]
009   
010   $max.x = get max sectors in x direction
011   $max.y = get max sectors in y direction
012   
013   $x = 0
014   $y = 0
015   
016   $sectors.array =  array alloc: size=0
017   
018   while $x <= $max.x AND $y <= $max.y
019   |$sector = get sector from universe index: x=$x, y=$y
020   |if $sector -> exists
021   ||if not $Race == null
022   |||$sector.owner = $sector -> get owner race
023   |||if $sector.owner == $Race
024   ||||append $sector to array $sectors.array
025   |||end
026   ||else
027   |||append $sector to array $sectors.array
028   ||end
029   |end
030   |if $y == $max.y
031   ||$y = 0
032   ||inc $x = 
033   |else
034   ||inc $y = 
035   |end
036   end
037   
038   if $Testing
039   |$Sectors.count =  size of array $sectors.array
040   |$desc = sprintf: fmt='%s', $Sectors.count, null, null, null, null
041   |$ret =  open custom menu: title='Sectors :' description=$desc option array=$sectors.array
042   |$sect = $sectors.array[$ret]
043   |$sect = sprintf: fmt='%s', $sect, null, null, null, null
044   |display subtitle text: text=$sect duration=3000 ms
045   end
046   
047   return $sectors.array
Download 'script' files from google code:

ZIP:
lib_All_sectors_array_by_race_xml Zip.



Get All Sectors by Race ARRAY v1.
Same as above, but it takes an array of races to return all sectors beloging to any race you put into the array.

Just create the array of the races you want to get the sectors for, in any manner you wish, then past the array as an argument to the script when you call it.

If you use it, i would suggest a name change in case someone else uses it and mods the script.

Code: Select all

Version: 1
for Script Engine Version: 44

Description
Lib - Get all sectors from universe, by race array.
Arguments
1: race.array , Value , 'Inc Races Array, Null = All:' 
Source Text

001   * --------------------------------------------------------------------------------
002   * Author : mark_a_condren   a.k.a   MarCon
003   * --------------------------------------------------------------------------------
004   * Created : May - 2010
005   * --------------------------------------------------------------------------------
006   
007   $Testing = [TRUE]
008   *$Testing = [FALSE]
009   
010   $max.x = get max sectors in x direction
011   $max.y = get max sectors in y direction
012   
013   $x = 0
014   $y = 0
015   
016   $sectors.array =  array alloc: size=0
017   
018   while $x <= $max.x AND $y <= $max.y
019   |$sector = get sector from universe index: x=$x, y=$y
020   |if $sector -> exists
021   ||if $race.array
022   |||$race = $sector -> get owner race
023   |||if  find $race in array: $race.array
024   ||||append $sector to array $sectors.array
025   |||end
026   ||else
027   |||append $sector to array $sectors.array
028   ||end
029   |end
030   |if $y == $max.y
031   ||$y = 0
032   ||inc $x = 
033   |else
034   ||inc $y = 
035   |end
036   end
037   
038   if $Testing
039   |$Sectors.count =  size of array $sectors.array
040   |$desc = sprintf: fmt='%s', $Sectors.count, null, null, null, null
041   |$ret =  open custom menu: title='All Sectors :' description=$desc option array=$sectors.array
042   end
043   
044   return $sectors.array

Download 'script' files from google code:
ZIP:
lib_All_sectors_array_ByRaceArra_xml



Script Code Snipets :

Get Ship Current Action Text :
001 $ship.current.action = $ship -> get current action
002 $ship.current.action.t.id = $ship.current.action + 350 ...
003 $ship.current.action.txt = read text: page= 14 id= $ship.current.action.t.id

Get Ship Command Text :
001 $ship.cmd = $ship -> get command
002 $ship.cmd.sub = get subtype of ware $ship.cmd
003 $ship.cmd.txt = read text: page= 2010 id= $ship.cmd.sub

Get the Ware Transport Class Abreviation : ('Extra Large Containers XL' becomes 'XL')
001 $t.class = get transport class of ware $ware
002 $t.class.abrev = read text: page = 1999 id= $t.class
(page 1999 is a stock Egosoft page file)


I will be adding quite a few more files here over time.

MarCon


Permissions :
You have my permission to use these Script Packages / Files / Demo's or part thereof in your your own work if you so wish. Please give credit if you do.

You can find an Unedited Permissions Statement Here :
Last edited by mark_a_condren on Tue, 28. Dec 10, 02:12, edited 11 times in total.
mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren »

Font Information :

Font colors available :

Using the \033... format, the following letters represent available colors. These color codes must be read in from a text file and will not work if entered directly into the script.

B = Blue
C = Cyan
G = Green (Lime)
K = Black
M = Magenta (Violet)
O = Orange
R = Red
W = White
Y = Yellow
Z = Grey

X = Turns color off

Using all letters from the alphabet, a test script was run to produce the following results,
[ external image ]

Other font Information :
Further font information is displayed below, this information was also script generated to get as accurate information as possible actually using the script engine.
[ external image ]
[ external image ]
[ external image ]
[ external image ]
[ external image ]
[ external image ]

Note, the information above says character '1' is size 7, while all other numbers are size 8, however, the comparison displayed shows no apparent difference in its size.
[ external image ]
[ external image ]
Last edited by mark_a_condren on Sat, 11. Dec 10, 17:29, edited 2 times in total.
mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren »

MINI Scripts section Added

The first one is 'E Brake'
It adds 2 hotkeys for the player to use. 1 works on the playership and the other on the player tracking aim.

Hit the hotkey and you or your target (if it belongs to you) will come to a rapid stop. See OP for download links.

MarCon
User avatar
Serial Kicked
Posts: 3823
Joined: Fri, 12. Aug 05, 20:46
x3tc

Post by Serial Kicked »

Thanks for this demo :)

i had some difficulties finding my way around these functions, it will look great in ADS.
X3:TC/AP Pirate Guild 3 - Yaki Armada 2 - Anarkis Defense System

Anarkis Gaming HQ
Independent Game Development
X3 Scripting and Modding Station
mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren »

LIBRARY Scripts section Added

The first one is 'Get All Sectors by Race v1.'

Call this script and set the argument for the race you want and it will return an array of all the sectors in the universe belonging to that race. If you set the race to 'null', it will return an array of All the sectors in the universe.




The second one is 'Get All Sectors by Race ARRAY v1.'
Same as above, but it takes an array of races to return all sectors beloging to any race you put into the array.

Just create the array of the races you want to get the sectors for, in any manner you wish, then past the array as an argument to the script when you call it.



If you use either of these scripts, i would suggest a name change in case someone else uses it and mods the script.


See the OP to view the code and for download links.

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

Post by mark_a_condren »

Font information added.

This can be found in the second post.

I hope it helps someone.


MarCon
Post Reply

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