CargoTransfer amount:Cargo, target:Int, [flags:Any]

Transfers cargo to a ship. target specifies the target ship Id, cargo is the amount and type to transfer, as a cargo set. It may contain negative values to beam cargo back from the target if rules allow.

The optional third parameter, options, is a string containing some options:

  • "O": permit overloading the ships.
  • "S": sell supplies on-the-fly (not possible for the ship/ship version of this command).
  • "N": don't generate an error when the cargo can not completely be transferred. Instead, sets the variable Cargo.Remainder accordingly.

When called from a planet, the third parameter can also contain the Id of a ship to use as a proxy. That proxy ship must be owned by you. If the target ship is not owned by you, the cargo will first be transferred to the proxy; then to the target, using the ship/ship transporter.

For example,

 CargoTransfer 10, "300n"

transfers 300 kt Neutronium to ship 10. It will fail with an error if the current ship doesn't have that much, or there is not enough space in ship 10's fuel tank. If you use

 CargoTransfer 10, "300n", "n"

PCC will transfer as much as possible. Assuming that the current ship only has 20 kt fuel (and ship 10 has enough space), this will set Cargo.Remainder to "280N", because that's the amount that was not transferred. To test for a successful transfer, you can then use

 If Not Cargo.Remainder Then Print "Successful."

Though you seem to be able to call this command beam cargo off foreign ships, this can only be used to cancel pending transfer orders. That is, if ship 355 is a foreign one and ship 10 is yours: for

 With Ship(355) Do CargoTransfer 10, "10n"

to succeed, you must have transferred 10 kt Neutronium there using the ship/enemy-ship transporter, e.g. with the command

 With Ship(10) Do CargoTransfer 355, "10n"

The game rules do not allow asking foreign ships for stuff; the other ship must explicitly send it.

@change PCC2 Web currently does not support proxy transfers. The proxy parameter is ignored; if the transfer cannot be made directly, it fails.

Version Differences: The "proxy" ability is present in PCC 1.0.10, and PCC2 2.40.3 (PCC2ng), but not in PCC2.

See also: CargoUnload, CargoUpload, Planet Commands, Ship Commands