by alex2069
Install
- SPK (recommended)
[ external image ] GameFront (.spk)
To install, use Cycrow's Plugin Manager. - ZIP
[ external image ] GameFront (.zip)
To install, extract to your X3TC directory, or more specifically, open the zip file, files in the scripts folder go in scripts folder, t in the t folder.
If it asks to overwrite any files, do so (will just be an older/same versions or my library files from some of my other scripts).
- I figure I might as well post my libraries for peoples to use. Some of them are probably not very "library-like" and are a bit application specific, but I'm sure there are some that would be very helpful to some people out there.
- Script a2069.lib.array.merge
Description: Returns a new merged array
Arguments:
* 1: arg.ar1 , Value , 'array1'
* 2: arg.ar2 , Value , 'array2'
I got sick of constantly doing the whole get sizes, add them together, create new array, copy first, copy second, etc. So I made it into a script for laziness, lol.
Usage is simple: i.e.It will return a new array. However if either of the arguments are null, it'll return the array that isn't. Otherwise if both null; it'll return null.Code: Select all
009 @ $shipyards = [THIS] -> call script 'a2069.lib.array.merge' : array1=$shipyards1 array2=$shipyards2
- Script a2069.lib.array.sort
Description: Returns a sorted array
Arguments:
* 1: arg.ar , Value , 'array'
* 2: arg.sortBy , Value , 'sort by'
This is probably the most useful of them all. I was previously using a bubble sort by X-Freak Cartman, but with X3TC there is a new (at least I think it's new to X3TC) array sort function that allows sorting an array based on an array of values. With this, it is MUCH faster.
sort by:
Can be a string or an array.
If it's a string, it will be turned into an array of strings (tokenised by ',').
However if you need to supply extra sort arguments, you'll need to supply it an array. i.e.
For my Universal locator it is used as follows:Currently the only "sort by" arguments are:Code: Select all
032 if $arg.isbb 033 |$sortAr = create new array, arguments='ware.price', $arg.ware, 'ware.quantity/d', $arg.ware, 'jumps' 034 @ |$stations = [THIS] -> call script 'a2069.lib.array.sort' : array=$stations sort by=$sortAr 035 else 036 |$sortAr = create new array, arguments='ware.price/d', $arg.ware, 'jumps', null, null 037 @ |$stations = [THIS] -> call script 'a2069.lib.array.sort' : array=$stations sort by=$sortAr 038 end
ware.price - requires a ware
ware.quantity - requires a ware
jumps - can have a sector, if it's not supplied assumes [SECTOR] (current ship/object running the script).
Do not that even though the sort by options are limited at the moment, since the sort script itself is done, and it sorts based on an array of values, it is very trivial to add other sort arguments (ask and it shall be done).
To order in descending order, add '/d' to the string (like X-Freak Cartman's script). - Script a2069.lib.interface.confirmbox
Description: Easy confirmation box script (returns [TRUE] for OK, otherwise [FALSE])
Arguments:
* 1: arg.title , Var/String , 'title'
* 2: arg.desc , Var/String , 'description'
* 3: arg.question , Var/String , 'question'
* 4: arg.heading , Var/String , 'heading (op)'
* 5: arg.sel1 , Var/String , 'selection1 (op)'
* 6: arg.sel2 , Var/String , 'selection2 (op)'
* 7: arg.wide , Var/Boolean , 'wide (op)'
Simple confirmation box. I was beginning to want it a couple of times throughout my scripts and decided it'd make a nice lib script.
The first 3 arguments are self explanatory. As for the rest:
4 - Heading: Defaults to "Confirmation" (the little heading above the "Ok" and "Cancel"
5 - Selection1: Defaults to "Ok"
6 - Selection2: Defaults to "Cancel"
7 - Wide: Defaults to [FALSE] - The pictured is the wide version (info menu), the "normal" version is just a standard menu.
[ external image ]
From my auto shop script:Code: Select all
042 if ! $this.transporter AND ! $deliveryTarget.transporter 043 |if not $deliveryTarget -> is docking possible of [THIS] 044 ||$question = sprintf: pageid=$pageId textid=300, [THIS], $this.idcode, $deliveryTarget, $deliveryTarget.idcode, null 045 @ ||skip if [THIS] -> call script 'a2069.lib.interface.confirmbox' : title='Automated Shopper' description='Confirm' question=$question heading (op)=null selection1 (op)=null selection2 (op)=null wide (op)=[TRUE] 046 |||return null 047 |end 048 end
- Script a2069.lib.string.fill
Description: Returns a string with spaces to a specified width to simulate columns
Arguments:
* 1: arg.string , Var/String , 'string'
* 2: arg.fillPos , Var/Number , 'position (l: -1, m: 0, r:1)'
* 3: arg.width , Var/Number , 'width'
Another very useful script. Using this will enable you to give your outputs neat "columns". It does this by "filling" the string with spaces up to a specified pixel count.
I was previously using the function from chem's string library, but it's slow and for some reason didn't work with info menus. I wrote my own version which is MUCH faster, and more accurate (not to mention simpler to use).
It hasn't had extensive testing yet, so if it produces weird outputs please let me know so I can get it stable.
Argument Details:
string: the string, lol
position: (anything less than -1 = -1, greater than 1 = 1)
-1 = add spaces to the left of the text
0 = add on both sides - 1/2 on the left, 1/2 on the right (very little testing)
1 = add spaces to the right of the text
width: (this is in PIXELS)
Most characters are 5 pixels with 1 pixel following, a space = 2 pixels + 1 following. (see the t file for character sizes if you really want).
Note however that since a space is 3 pixels, it can never be pixel perfect. There may (most likely) be an offset of +/- 1 pixel (nothing I can do about it).
Example output:
[ external image ]
Example using it (from my universal locator):Code: Select all
065 |$output.credits = convert number $station.ware.price to string 066 @ |$output.credits = [THIS] -> call script 'a2069.lib.string.fill' : string=$output.credits position (l: -1, m: 0, r:1)=-1 width=83 067 | 068 |$output.jumpCount = convert number $station.jumpCount to string 069 @ |$output.jumpCount = [THIS] -> call script 'a2069.lib.string.fill' : string=$output.jumpCount position (l: -1, m: 0, r:1)=-1 width=71 070 | 071 |$line = sprintf: fmt=$message.wareText, $station, $station.ware.count, $output.credits, $output.jumpCount, null
- Script a2069.lib.string.tokenize
Description: Returns an array of strings based on the string and the token string
Arguments:
* 1: arg.string , Var/String , 'string'
* 2: arg.tokens , Var/String , 'tokens (default: ',')'
After ditching chems string library (which was cumbersome and slow to use), I needed my own string split/tokenizer.
Simple to use, and mostly self explanatory:Code: Select all
005 @ |$arg.sortBy = [THIS] -> call script 'a2069.lib.string.tokenize' : string=$arg.sortBy tokens (default: ',')=null
- Script a2069.lib.waremenu
Version: 210
for Script Engine Version: 42
Description: Creates an organised ware menu
Arguments:
* 1: arg.title , Var/String , 'Title'
* 2: arg.desc , Var/String , 'Desc'
* 3: arg.onlyTraded , Var/Boolean , 'Only Traded?'
* 4: arg.includeNatural , Var/Boolean , 'Include Natural type?'
* 5: arg.ship , Var/Ship , 'Ship (op)'
A handy script for when you want the user to select a ware.
Argument Details:
Title: The title of the menu (pictured = "Universal Locator")
Desc: The description (pictured = "Select a Ware")
Only Traded?: If [TRUE] will only display wares that can be bought and sold over the universe.
Include Natural type?: The "Natural" ware type doesn't have anything that can be bought or sold (at least not from my experience), so I figured there's no point having it unless you actually want it.
Ship (op): If you wish you can specify a ship for the menu to obtain the usable lasers/missiles/shield sub-menu details from. If null, it will revert to [THIS].
Also note that this menu uses a "caching" scheme... Sort of thing...
The menu is only generated one (upon using), and is then saved allowing instant use for next time. The most noticeable is selecting "All Wares" which gives a 2-3 second lag on first use, and is instant there-after.
This "cache" is reset each game load so that any changes/additions to the game wont be missed.
The main menu:
[ external image ]
Usable Lasers sub-section:
[ external image ]
Usage is very simple: (from my Universal Locator)Code: Select all
001 @ $ware = $null -> call script 'a2069.lib.waremenu' : Title='Universal Locator' Desc='Select a Ware' Only Traded?=[TRUE] Include Natural type?=[FALSE] Ship (op)=[THIS]
- There are a few others in there that aren't really worth mentioning, but I just kept them all in there since it was easy (and a couple of the mentioned scripts use them).
The only other one slightly worth mentioning one is: a2069.lib.debug.dump.array
Give it an array, pageId, etc (self explanatory really), and it dumps it. I plan on adding more detail to what's in the array (ware details/station detail/ship detail, etc) and likely will as I want it (if someone really wants more added ask). It will also dump multidimensional arrays (there is a fail-safe recursion check).
- I make no guarantees of their functionality or usefulness, lol.
I wouldn't be surprised at all if there were easier ways to do some of the above things, and if there is, please do tell me.
I am by no means an expert at scripting, and am constantly learning how to do things in different (read: correct, lol) ways, so if something isn't working correctly, or there is something you'd like added/changed, ask away and I'll see what I can do.
- Uninstall via. the script package.
- -Uses Text File and Text Page 2068.
- v1.01 - 2008.12.06 - Fixed null ware menu bug + The ware menu can now accept a ship as an argument.
- v1.00 - 2008.12.05 - Initial release.