[SCRIPT] Command Queuing V1.21 : 26/05/2009

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

Post Reply
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 21334
Joined: Mon, 15. Nov 04, 00:26

[SCRIPT] Command Queuing V1.21 : 26/05/2009

Post by Cycrow » Tue, 14. Oct 08, 12:55

Script Name: Command Queueing
Released: 26/05/2009
Version: V1.21

These set of scripts allow you to command your ships to do multiple commands at once. The queues can be saved and recalled many times or ones can be created for a single use.

It also uses a plugin system allowing other users and scripters to add thier own commands without needing to edit the original scripts.

SPK: Image

:arrow: Installing

To install the zip, simply download and extract into your X3 Terran Conflict Directory.
Or use the spk file with the Plugin Manager to install automatically

When in game, make sure the script editor is loaded and you have saved and reloaded your game.

:arrow: Getting Started

To create a command queue, you need to open up the command queue creation menu. This is done via the hotkey which you can assign in the controls menu. Once assigned, simply pressing the hotkey when in space will open the menu.


There are 2 types of queues, one with arguments and one without.

All available commands have a set or arguments that are used with that command, ie the Dock at command will ask the station to dock at.

If you create a queue with arguments then each command you select you wil also select the arguments for them, and those will be saved into the queue, ie using Dock At, and selecting a station, every time you run this queue on a ship, they will always dock at the same station.

Without arguments you just select the command, then each time you run the queue, you will be asked to fill in the arguments. Ie, you just select the Dock At command, then when you run it, you will be asked to choose the station.

:arrow: Queue Creation

Which ever option you choose, you will be shown the same menu, the only difference is if you will be asked to select the arguments or not


The top section will list your current queue, the order of the commands you've added and where your next command is added. The -- Next Command -- option will be where your next command is added to. This allows you to insert commands between others.

The 2nd section is the available creation command, like insert, or delete entries, changing arguments and saving the queue "Finished"

Finally the 3rd section is the list of command you can add (scripters can add new commands)

To create the queue, simply select each command in order and they will be added to the list.

:arrow: Setting Arguments

If you create a queue with arguments, when selecting the command to add, it will be followed with the arguments, the number and type of arguments depend on the command you select, and they will follow one after the other. Pressing Esc to quit during the arguments will set the argument to "ASKMODE". This means that when running the command queue, the user will be prompted for these arguments, ie how a queue without any arguments works, but only for the arguments that have been set like this.


The above examples adds the same command switch, the first selects the argument, the 2nd does not.

You can change the arguments selected for any command with the option "Change Arguments". This will ask which command to change, then repeat the argument selection as before.

:arrow: Inserting and Deleting Commands

Deleting an existing command is straight forward, if theres any commands added, there will be the option "Delete Entry" select this then chose the command entry to delete and it will be removed.

To insert, it requires 2 stages. First, select the option "Insert Entry". This will display the currently added commands, select the command and then the "Next Command" marker will appear above.


Then you just add the command as normal and it will be insert at the position the "Next Command" marker is at. Ie, in the above example, insert it as the first command in the queue.

:arrow: Available Commands

The are various commands available and more will be added later, as well as custom commands can be added by scripters as well.

Some commands are straight forward, however, some of them have some special properties.

The Buy/Sell ware commands are making use of another unique feature, the plugin custom menus. This allows it to display wares in a better way than the normal ware inputs.

But it does something special as well, it can display wares at the station, but it will backtrack your commands list and take the last command that docked at a station, and use that stations wares if available. Basically if you add a dockat command then a buy ware command, then the list of wares available will be any ware that you can buy from the previous station in the dock at command.

:arrow: Running Queues

Once you have created some queues and saved them, you can run them on any ship.

The option to run a queue is found in the command console (Custom Menu)

Select the option to run a command queue and you will be shown a list of available queues as well as the option to create a new one on the fly.

Selecting the create option does the same as the creation, but run the queue on the ship instead of saving it for later. This allows you to define a one time set of instructions for your ship.

Otherwise select one of your saved queues. Any arguments that havn't been set will have to be done when you run the queue, you will be asked for each of these before it starts.

Then the ship will go about its job and follow each command until it gets to the end.

:arrow: Deleting and Editing Queues

Once you have saved any queues, you can delete or edit them via the command queue hotkey. These options are not available if you dont have any saved queues.

:arrow: Scripters: Adding new commands

As said, scripters can use the plugin system to add any number of commands they want.

:arrow: Scripters: Custom Menus

Instead of using a number input, it get sector, get ship, etc. You can create a custom menu that returns any argument you wish. The buy/sell ware commands use this for an example.

Scripters: Using Backtrack varibles

You can set up a serious of varibles that will be stores through the use of a queue, there is currently one varible availble "DOCKEDAT" which stores the current station you are docked at. Ie, seleting the dock at command will adjust to varible to the current argument. The buy/sell ware commands use this varible to display the list of wares available at the "DOCKEDAT" station.

You can also add other varibles to use for your own commands and custom menus.
Last edited by Cycrow on Tue, 26. May 09, 19:40, edited 3 times in total.

Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 21334
Joined: Mon, 15. Nov 04, 00:26

Post by Cycrow » Tue, 21. Oct 08, 20:02

Spk version has now been included

Posts: 115
Joined: Tue, 10. Feb 04, 13:44


Post by mufflink » Tue, 21. Oct 08, 20:31

Hmmm, just wondering if we could create a crude CAG with this???

Something along the lines of:

Station: 1mj factory
Resources needs, cahoona, e-cells, ore
Ships needed: 2

Ship 1
buy ware at best price: e-cells
dock at home
buy ware best price: cahoona
dock at home
buy ware best price: ore
dock at home

Ship 2
sell ware best price: 1mj
dock at home
wait 50000ms

Any way we could have these commands loop so the ships just keep replaying the commands over and over and over.........

Just an idea probably a completely wrong and bad 1!!!!

When in doubt.......cheat.

Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 21334
Joined: Mon, 15. Nov 04, 00:26

Post by Cycrow » Tue, 21. Oct 08, 20:44

well, it might be possible to do something like that, i could look at adding some kind of loop command.

and perhaps a command to call another queue

Posts: 833
Joined: Fri, 5. Mar 04, 18:23

Post by paulms1980 » Thu, 23. Oct 08, 09:48

this will make X3 like that old space strategy game Stars! where u could que a repaeating order
cycrow does this mean i can setup a repeating manual trade route?
Buy X amount of good A then sell then X amout n repeat?

Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 21334
Joined: Mon, 15. Nov 04, 00:26

Post by Cycrow » Thu, 23. Oct 08, 11:57

not yet. You can set up the the que to do that, but it wont repeat so u'll have to keep applying it.

however, in the next version i will add a repeat option so you can do that

User avatar
Posts: 1033
Joined: Tue, 13. Apr 04, 23:08

Post by Malakie » Fri, 24. Oct 08, 01:36

Most awesome script! Another staple to always use! Great job.
Take it light.....



User avatar
Posts: 2012
Joined: Wed, 29. Jun 05, 01:45

Post by s9ilent » Sat, 25. Oct 08, 09:46

Hey Cycrow :)

In Lieu of not actually owning the game yet ( :< Australia fails hard :<), I'm forced to randomly go around the forum reading up stuff.

Any way, I had this idea, you all remember Rainbow 6, where you plan meticulously and the guys move oh the phrase "alpha/bravo/charlie/delta go!"

Well if you made an attachment to this script you could essentially do just that. Make a script that just checks every 5 seconds or so, for a global variable to be TRUE, then it runs the command.

So currently you might que
fly here (rally)
kill target
fly there (retreat)

Instead you might:
fly here (wait at rally point)
*on delta-go kill target
fly there (retreat)

It could be added to the UI by adding a "on next command, on alpha, beta, g, d etc.), like a "filter" sort of option

The actual script would be like

Arg: script name, script_args

$old = get global cy.plug.whatever.alpha
$var = old
while var <= old
wait 5s
$var = get global cy.plug.whatever.alpha
end while
call script with name

And you have a alpha-go/b/c/d/etc. hotkey that increments the global variables.

Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 21334
Joined: Mon, 15. Nov 04, 00:26

Post by Cycrow » Sat, 25. Oct 08, 13:43

if u needed to do something like that, it would be very easy for you to make an addon for it.

it has a plugin system that allows you to create commands yourself.

rather than me making some very specific commands i tyed just to make the generic ones, then anyone who wants to use the system for a specific task can simply add the addition commands.

you could add a command "wait for alpha" or something

Code: Select all

= call script 'plugin.cmdqueue.register' id='waitalpha' text='Wait For Alpha' arguments=null, script='my.script.waitalpha'
then create my.script.waitalpha

Code: Select all

while not get global varible 'wait.alpha'
 = wait 1000ms
then just add that into the queue, and when selected it will run your script which will wait for the varible to be set

Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 21334
Joined: Mon, 15. Nov 04, 00:26

New Update: 1.10

Post by Cycrow » Fri, 31. Oct 08, 01:33

New update available: V1.10

Added the Loop command so queues can be looped multiple times
Fixed a problem with running newly created queues on ships (ie not saved ones)

Posts: 819
Joined: Fri, 13. Jun 08, 13:14

Post by Coruskane » Sun, 2. Nov 08, 03:56

yippe, an adequate CAG (when a few 'get ware space' scripts are called for the variables) for my purposes :) (simply getting a freighter to load up with multiple products from a super complex (42 weapons/shields facilities in a closed-loop :)) then depositing them into my distribution network.

Posts: 243
Joined: Thu, 23. Oct 08, 22:01

Post by amirite » Sun, 2. Nov 08, 16:49

So how hard would it be to make all/most stock commands available for use with this?

Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 21334
Joined: Mon, 15. Nov 04, 00:26

Post by Cycrow » Sun, 2. Nov 08, 17:06

i will add some more commands eventually.

however, adding your own is easy, especially if you know scripting.

basically adding a new command requires making an argument array and calling the register script.

for example, an attack target comman could be made by doing this

Code: Select all

$arguments = create array, arguents = Var/Ship, "select ship to attack", null, null, null
= [THIS] call script 'plugin.cmdqueue.register', nameid='attacktarget', display text = 'Attack Target' Arguments = $arguments, script = '!fight.attack.object'
this would add a command called "Attack Target" and when you select it, you will be asked to select a ship as a target.

then it will run the script !fight.attack.object, which is the standard one for attacking a single ship

Posts: 219
Joined: Mon, 11. Sep 06, 23:05

Post by fintoozler » Sat, 22. Nov 08, 06:14

Any chance of a loop back to... command?

It would be good for setting up ships and starting em off, you could have them go to a string of stations to get their gear then start a trading loop or patrol.
When it reaches the end of the queue it could loop back to the start of its patrol without the need to go through all the setup stations again.

Regardless, awesome script, yet another feature that should be in any game of this type.

Posts: 13
Joined: Thu, 22. Feb 07, 21:32

Post by letherial » Thu, 27. Nov 08, 10:18

This seems handy so i started..

I think i followed instructions...

Installed with plugin manager, yes its enabled
Loaded my game, Loaded the script editor (go and press in global commands and then select script editor right?)
Saved my game with script editor still open
Loaded the game....dont have the ability to setup a hotkey to start the thing.

I have looked everywhere, but i assume it would be under interface then extensions (right?)

I do have other scripts installed, i disabled a few of them, but hotkeys are there for FCC and MARS, o ya and wing command. not sure what im doing wrong.

Post Reply

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