LIST Command¶
A List is a type of Structure that stores a list of variables in it. The LIST command either prints or crates a List object containing items queried from the game. For more information, see the page about the List structure.
FOR Loop¶
Lists need to be iterated over sometimes, to help with this we have the FOR loop, explained on the flow control page. The LIST Command comes in 4 forms:
LIST.When no parameters are given, the LIST command is exactly equivalent to the command:
LIST FILES.
LIST ListKeyword.This variant prints items to the termianl sceen. Depending on the ListKeyword used (see below), different values are printed.
LIST ListKeyword FROM SomeVessel IN YourVariable.This variant is just like variant (3), except that it gives a list of the items that exist on some other vessel that might not necessarily be the current CPU_vessel.
Available Listable Keywords¶
The ListKeyword in the above command variants can be any of the following:
Universal Lists¶
These generate lists that are not dependent on which Vessel:
BodiesListofCelestial BodiesTargetsListof possible targetVessels
Vessel Lists¶
File System Lists¶
These generate lists about the files in the system:
Note
LIST FILES. is the default if you give the LIST command no parameters.
Examples:
LIST. // Prints the list of files on current volume.
LIST FILES. // Does the same exact thing, but more explicitly.
LIST VOLUMES. // which volumes can be seen by this CPU?
LIST FILES IN fileList. // fileList is now a LIST() containing file structures.
The file structures returned by LIST FILES IN fileList. are documented on a separate page.
Here are some more examples:
// Prints the list of all
// Celestial bodies in the system.
LIST BODIES.
// Puts the list of bodies into a variable.
LIST BODIES IN bodList.
// Iterate over everything in the list:
SET totMass to 0.
FOR bod in bodList {
SET totMass to totMass + bod:MASS.
}.
PRINT "The mass of the whole solar system is " + totMass.
// Adds variable foo that contains a list of
// resources for my currently target vessel
LIST RESOURCES FROM TARGET IN foo.
FOR res IN foo {
PRINT res:NAME. // Will print the name of every
// resource in the vessel
}.