XP API for Add-on Mods
Since version 1.0.5, a different mod can give GalaxyTrader XP, levels, and ranks to its own pilots. The ship does not need a GalaxyTrader order.
What GalaxyTrader does¶
Your mod registers the pilot. Your mod sends the XP. GalaxyTrader calculates the result.
GalaxyTrader applies these rules:
- The player XP multiplier
- The level limit
- The skill values
- The level-up notice
- The commander bonus
GalaxyTrader does not give orders to the ship. GalaxyTrader does not change the ship name. GalaxyTrader does not add the (T:n) tag. Pilot Exchange does not move these pilots. The Trading Academy does not train these pilots.
Read global.$GT_API_Version before you send a signal. The value must be 2. If the value is not set, GalaxyTrader is not available.
Send each signal to player.galaxy. param is the signal name. param2 is a table. $Source is the id of your mod. Use the same $Source in each call. $Source must not be empty.
<signal_objects object="player.galaxy" param="'GT_API_AddPilotXP'" param2="table[$Pilot = $pilot, $Amount = 50, $Source = 'my_addon']"/>
Use this condition to receive a signal:
<event_object_signalled object="player.galaxy" param="'GT_API_PilotLevelUp'"/>
The levels and the ranks are the same as in XP Progression. If the player sets Use vanilla XP only to on, GalaxyTrader refuses new XP and completed training.
Signals that you send¶
GT_API_RegisterPilot¶
This signal makes the pilot an add-on pilot. The pilot must belong to the player. The pilot must be the pilot of the ship.
If GalaxyTrader already knows the pilot, the pilot keeps the XP and the level. You can register the same $Source again to change the training mode.
GalaxyTrader refuses the call if the ship already has a GalaxyTrader order. GalaxyTrader also refuses the call if the ship uses Mimic under a GalaxyTrader commander.
| Field | Required | Meaning |
|---|---|---|
| $Pilot | Yes | The pilot. |
| $Source | Yes | The id of your mod. |
| $Ship | No | The ship of the pilot. If you omit this field, GalaxyTrader uses the ship that the pilot flies. |
| $TrainingMode | No | none or external. If you omit this field, the mode is none. |
GT_API_UnregisterPilot¶
This signal gives the pilot back to GalaxyTrader. The XP and the level stay the same. $Source must be the mod that registered the pilot. $Pilot is required.
GT_API_AddPilotXP¶
This signal gives XP to a pilot that GalaxyTrader knows. The pilot can be an add-on pilot or a GalaxyTrader pilot. Register the pilot before you send XP. GalaxyTrader refuses an unknown pilot.
$Amount must be from 1 to 1000000. This value is the amount before the player XP multiplier. $Pilot and $Source are required. $Ship is optional. If you omit $Ship, GalaxyTrader uses the ship in the pilot record.
GT_API_CompleteTraining¶
Send this signal when your mod completes the training that GalaxyTrader requested. The pilot must be your pilot. The training mode must be external. The pilot must be blocked at $Level.
$Level must be the $RequiredLevel from GT_API_TrainingNeeded. The permitted range is 2 to 15. GalaxyTrader then increases the level. GalaxyTrader also returns the XP that it held during the block.
$Pilot, $Source, and $Level are required. $Ship is optional.
Signals that GalaxyTrader sends¶
GT_API_PilotXPGained¶
GalaxyTrader sends this signal for each GalaxyTrader pilot and each add-on pilot when the XP value changes. GalaxyTrader does not send this signal when the award is blocked. GalaxyTrader does not send this signal when the pilot is already at the level limit.
| Field | Meaning |
|---|---|
| $Pilot | The pilot. |
| $Ship | The ship that earned the XP. |
| $Amount | The XP that GalaxyTrader added, after the multiplier and the level limit. |
| $TotalXP | The XP of the pilot after the award. |
| $Level | The GalaxyTrader level of the pilot after the award. |
| $Activity | trade, mining, ware_exchange, commander_bonus, or api. |
| $Source | The id of your mod when $Activity is api. Otherwise the value is gt. |
| $External | True when the pilot is an add-on pilot. |
GT_API_PilotLevelUp¶
GalaxyTrader sends this signal when the GalaxyTrader level increases. The cause can be XP or completed training.
The fields are $Pilot, $Ship, $OldLevel, $NewLevel, $External, and $Source. $Source is the id of your mod, or gt.
GT_API_TrainingNeeded¶
GalaxyTrader sends this signal when your pilot in mode external reaches a training level. GalaxyTrader does not send the ship to a training station. GalaxyTrader does not show a training notice.
The fields are $Pilot, $Ship, $RequiredLevel, $CurrentLevel, $BlockedXP, $TotalXP, and $Source. $CurrentLevel is the level that the pilot keeps until you complete the training. $BlockedXP is the XP that GalaxyTrader holds. GalaxyTrader returns that XP when you complete the training.
GT_API_PilotReleased¶
GalaxyTrader sends this signal when the player gives the ship a GalaxyTrader order. This includes Mimic under a GalaxyTrader commander. GalaxyTrader then controls the pilot and keeps the XP.
$Reason is gt_order. $Source is the mod that registered the pilot. The other fields are $Pilot and $Ship.
GT_API_PilotXPRejected¶
GalaxyTrader sends this signal when it refuses one of your signals. $Request is the name of that signal. $Pilot is null when the table has no pilot. $Reason is one of these values:
| Reason | Meaning |
|---|---|
| bad_payload | param2 is not a table, or a required field is missing or not valid. This includes a missing ship, a pilot who is not the pilot of the ship, a ship that the player does not own, an unknown training mode, an $Amount outside 1 to 1000000, or a $Level outside 2 to 15. |
| not_player_owned | The pilot does not belong to the player. |
| already_native | RegisterPilot only. The ship already has a GalaxyTrader order. |
| not_external_owner | A different mod owns the pilot. Or UnregisterPilot or CompleteTraining did not come from the mod that registered the pilot. |
| not_registered | The pilot has no GalaxyTrader record. |
| not_blocked | CompleteTraining only. The training mode is not external, or the pilot is not blocked at that level. |
| vanilla_xp_only | The player uses vanilla XP only. This reason applies to AddPilotXP and CompleteTraining. |
Training modes¶
none is the default. The pilot can increase in level. The pilot does not need training.
external stops the pilot at the same training levels as a GalaxyTrader pilot. GalaxyTrader does not do the training. You receive GT_API_TrainingNeeded. You answer with GT_API_CompleteTraining.
Limits¶
- When training is complete, GalaxyTrader returns the held XP. That return does not send
GT_API_PilotXPGained. The next XP award or the level-up signal shows the new total. - A level change from a cheat, a settings resync, or the Trading Academy does not send
GT_API_PilotLevelUp.