I'm writing a kOS script to launch and land a booster, and I'm currently working on the display. I ran the command print steer(pitch) at(0, 3).

"steer" is the variable used to store target direction, using many functions in the form of set steer to heading(90, 90).

When I tried to print out the target pitch of my craft, I received the error:

Attempted to make a function call on a non-invokable object: steer.



I'm pretty sure you simply have a syntax error. A direction like your steer is a structure, not a function. To access its pitch property, you need to write steer:pitch, not steer(pitch).

Also note that, as far as I can tell, the name steer has no special significance in kOS; it's just an arbitrary variable name. There is a special bound variable named steering (not steer) that is used for "cooked" flight control with the command:

lock steering to <expression>

where <expression> is any vector or direction. However, it seems that quite a few kOS scripts will first assign the desired direction to a normal user variable (which might be named e.g. steer) and then lock steeringto that variable.

I'm not 100% sure why they do that, but I suspect it may be a performance optimization: when you lock a variable to an expression, kOS will recalculate the value of that expression every time the value of the variable is read. And kOS internally reads the value of steering many times every second. Thus, if you only want to lock the steering to a constant direction, it's probably faster to first calculate that direction and assign it to a normal variable, and then lock steering to that variable.

Anyway, the point of all this is that a command like print steer:pitch will only print the pitch component of whatever direction you've assigned to the variable steer. This may or may not actually have anything to do with the pitch that kOS is currently trying to steer your ship towards; that depends on whether you've locked steering to steer or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.