% % Cargo Transfer `Macros' % % This script contains some small `macros' for cargo transfer. % See the source code for comments on how to use them. % Print "[cargo.q 10/Apr/2001]" % Unload ship. This equals the "U" key in standard cargo transfer: % unloads everything but neutronium, warheads (torps) and fighters. % Does nothing when this ship is not at a planet. Must be called % in ship context. Sub UnloadShip If Orbit Then CargoUnload CRemove(Cargo.Str, "nwf") EndSub % Unload all ships at this position (see `UnloadShip'). Can be % called from planet or ship. Does nothing when there is no planet % at this location. Sub UnloadAll Local xw = Loc.X, yw = Loc.Y ForEach Ship Do If Loc.X=xw And Loc.Y=yw Then Try UnloadShip EndSub % Unload all marked ships that orbit a planet. Sub UnloadMarked ForEach Ship Do If Marked Then Try UnloadShip EndSub % Upload fuel needed to reach waypoint. Must be called from ship. % Fails if there is not enough fuel, not at planet or tank too small. Sub GetFuel Do While Cargo.N < Move.Fuel % do this repeatedly to account for the fact that the ship gets % heavier by uploading fuel CargoUpload (Move.Fuel - Cargo.N) & "N" Loop EndSub