[X3:LU] How do I create custom navigation console commands?

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
User avatar
Zaitsev
Posts: 2007
Joined: Tue, 2. Dec 08, 01:00
x4

[X3:LU] How do I create custom navigation console commands?

Post by Zaitsev » Sat, 26. Mar 22, 07:35

So, I've been working on a script that will send my Tp to hire a crew for my ship, kind of like a poor man's Military Transport script. I've gotten it working for the most part, but I wanted to add an activation command to the navigation console so I don't have to mess around with hotkeys or having to run the script through the script editor.

After a lot of googling and searching for examples I came up with the following, but for some reason it doesn't work and I can't figure out why.

t-file I use:

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="true"?>
<!-- Generated using X-Studio -->
-<language id="44">

-<page title="Script Cmd Names" id="2008" voice="no" desc="">
<t id="830">A_HIRE_CREW</t>
</page>

-<page title="Script Cmd Names" id="2010" voice="no" desc="">
<t id="830">Hire Ship Crew</t>
</page>

-<page title="Script Cmd Shorts" id="2011" voice="no" desc="">
<t id="830">HirShiCre</t>
</page>

-<page title="Script User Help" id="2022" voice="no" desc="">
<t id="830">Command this ship to fly to the nearest friendly station and hire a crew for your ships. You can specify whether you want to hire a complete crew or a skeleton crew, as well as choosing which races to include.</t>
</page>

</language>
The code I made, after finding some, admittedly old, references:

Code: Select all

load text: id=9977
$ware = {Cargo Lifesupport System}
add ship custom command: id=830
set script command upgrade: command=[A_HIRE_CREW]  upgrade=[TRUE]
set script command upgrade: command=[A_HIRE_CREW]  upgrade=$ware
global script map: set: key=[A_HIRE_CREW], class=[TP], race=[Player], script='z.String.Input', prio=0
return null
I've spent the better part of the day trying to get it to work, but no matter what I do it won't show up in the navigation console. Any help would be greatly appreciated.
I'm sorry, I can't hear you over the sound of how awesome I am :D

DiDs:
Eye of the storm Completed
Eye of the storm - book 2 Inactive
Black Sun - Completed
Endgame - Completed

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22227
Joined: Sun, 14. Nov 04, 23:26
x4

Re: [X3:LU] How do I create custom navigation console commands?

Post by Cycrow » Sat, 26. Mar 22, 09:37

What is the name of script you are using to register the commands, is it a setup script?

does the script, "z.String.Input" exist?

A few issues:
the id 830 already exists, so you dont need to use the add ship custom command. This is for adding a new id that doesn't exist (and this doesn't work for ids lower than 1300 anyways)
The set script command upgrade command is used once per command, so the first one is redundant, as its overwritten by the 2nd one.

i assume you are checking the command console of a TP ship?
it should appear in the "General" sub menu if its working

User avatar
Zaitsev
Posts: 2007
Joined: Tue, 2. Dec 08, 01:00
x4

Re: [X3:LU] How do I create custom navigation console commands?

Post by Zaitsev » Sat, 26. Mar 22, 23:06

Cycrow wrote:
Sat, 26. Mar 22, 09:37
What is the name of script you are using to register the commands, is it a setup script?

does the script, "z.String.Input" exist?

A few issues:
the id 830 already exists, so you dont need to use the add ship custom command. This is for adding a new id that doesn't exist (and this doesn't work for ids lower than 1300 anyways)
The set script command upgrade command is used once per command, so the first one is redundant, as its overwritten by the 2nd one.

i assume you are checking the command console of a TP ship?
it should appear in the "General" sub menu if its working
Welp ... PEBKAC of the day is that I checked everything ... Except to see if I had included it in my startup script, so my command would actually be loaded when I started the game. It works as intended now, and my ears are still ringing from that brainfart. Oh well ...

Followup question - Does this command only need to be set once at the start of a new game, or is it something that need to be set every time you load a save? Based on what little I know of X3 scripts I would assume it's a one-and-done thing, but I'm asking anyway just to be sure.
I'm sorry, I can't hear you over the sound of how awesome I am :D

DiDs:
Eye of the storm Completed
Eye of the storm - book 2 Inactive
Black Sun - Completed
Endgame - Completed

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22227
Joined: Sun, 14. Nov 04, 23:26
x4

Re: [X3:LU] How do I create custom navigation console commands?

Post by Cycrow » Sun, 27. Mar 22, 10:07

They need to be set each time the game loads, and the script cache is reinitialised after each load. Also, if you refresh the script cache from the script editor then the command mappings will also be cleared.

this means you dont need to uninstall your command slots if you remove your script

User avatar
Zaitsev
Posts: 2007
Joined: Tue, 2. Dec 08, 01:00
x4

Re: [X3:LU] How do I create custom navigation console commands?

Post by Zaitsev » Mon, 28. Mar 22, 05:40

Cycrow wrote:
Sun, 27. Mar 22, 10:07
They need to be set each time the game loads, and the script cache is reinitialised after each load. Also, if you refresh the script cache from the script editor then the command mappings will also be cleared.

this means you dont need to uninstall your command slots if you remove your script
All right, I think I got it nailed dow. Thanks for the help. Much appreciated :thumb_up:
I'm sorry, I can't hear you over the sound of how awesome I am :D

DiDs:
Eye of the storm Completed
Eye of the storm - book 2 Inactive
Black Sun - Completed
Endgame - Completed

Post Reply

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