Nivekk / KOS

Fully programmable autopilot mod for KSP.
Other
80 stars 30 forks source link

(enhancement request) Array variable type, and then tie it to LIST. #176

Open Dunbaratu opened 10 years ago

Dunbaratu commented 10 years ago

This is really three requests tied together: And it's a pretty big ask, so I would expect it to be a future feature not a thing to address immediately.

1 - Add support for creating some sort of array variable. i.e. syntax like:

 myVar[ i ].

and

 myVar:SIZE or perhaps something like size(myVar) or length(myVar).

2 - Add a new variable type to KOSscript, a variable of type "Part". A KOSscript variable of type "Part" is a generic reference to any single part on the vessel (it maps directly into the KSP's API handle for a vessel part). The following methods would be exposed to the KOSscript user as a first starting point, and more could be added later:

(asume someP is a variable of type "Part").
someP:NAME   ( string name of part, i.e. "Mk25 Parachute".)
someP:MASS   ( mass of part ).
someP:DRAG   ( 0.2 for most parts, more for chutes - should be obtainable from the API).
someP:TYPE   ( a string name of the category of part, i.e. "chute", "engine", etc ).
... etc ... (whatever other generic properties tend to be on all parts).

3 - Provide a way to return the result of a LIST command into such an array variable rather than to the screen, like this for example:

LIST VOLUMES INTO myVar. LIST PARTS INTO myVar. etc.

The "list parts" would be really handy. Instead of returning strings it would return variables of type Part (hence part 2 of this request). The ability to query what's on the vessel helps in all sorts of calculations. It would let you know whether a "stage" instruction caused anything to fall off or not (by the length of the parts list). It would let you know how many parachutes there are, and of what type, so you can properly calculate drag for atmospheric landings, and so on.