Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

Actually, I think I tracked it down from the source on github. RemoteTech appears to have changed assembly names to "RemoteTech" from "RemoteTech2". So your check in RemoteTechHook.cs returns a null instead of loading the new assembly. If you don't have anything funny in your build configuration, I'll compile it myself tonight (probably late) to see if changing the assembly name fixes things.

Link to comment
Share on other sites

Just compiled with the revised assembly name for RemoteTech, seems to work without issue for me. I forked and submitted a pull request on the master branch. (Tell me if there is an issue with the pull request, it's my first try).

Link to comment
Share on other sites

By the way, how (un)stable is this at this time? :)

Also, any good community resources on using it? The documentation is often quite terse. ("These coordinates are difficult to explain" lol.)

Other stuff. :)

Back at the start of the thread there was talk about waiting on multiple events. I think that event-driven operation out of the box would be a little unstylish. However, adding the ability to wire up interrupts would be something else entirely! ;) Some of the kids out there might actually learn something about how computers work, besides all the rocket science.

Edited by S1gmoid
Link to comment
Share on other sites

First of I love your mod!

I would request one small change though. Could you please make it so that the mod will read .kos files as well as .txt files in the archive that would make it so that I can write a plugin for sublime that will automatically recognize any .kos file as a KerboScript file.

-Eforen

Link to comment
Share on other sites

From my use it is fairly stable. As with anything, I've run into a few quirks, but nothing I couldn't work around.

The event-driven operation is very limited, and doesn't function the way most people expect it to in today's multi-threaded environments. It's essentially just like a hardware interrupt on most micro processors: it truly interrupts the running code, and nothing else is executed until the completion of the operation. So even if some "kids" focus too heavily on the events, they'll find out real fast that it's a bad idea to include more than some simple logic in the event loop. The "run" command throws an exception if you try to execute it from inside the loop, and in my experience an exception gets thrown if you do too many operations.

It's not the most up to date, but I used this resource to get started: http://kos.wikia.com/wiki/Tutorials_and_Example_Scripts

Some of the scripts use depreciated variables, but they give a good foundation on how to implement some of the math.

Link to comment
Share on other sites

Playing around with kOS and IR to build some ornithopters, I have come up with a very quick list of stuff I would love to see kOS do with IR:

- Set IR group speed value (Allow faster or slower movement)

- Set IR part target max/min position values (Allow moving a IR part to certain values)

- Address IR parts directly (not only via action groups)

- Read the position values of a part

- If parts have addressable IDs (like engines, or IR parts) it would be great if kOS would add the ID value to the rightclick menu in the SPH/VAB and while in flight

One unrelated thing:

- Get the throttle value (to allow using the throttle to control stuff)

Link to comment
Share on other sites

Neat-o!

I have probably been sleeping, but has the boot script function been removed?

You know what, I have never used the boot feature after i got the PR for it. I should have a test craft for it :P if it is no longer working I am sorry and ill get it back in. Care to fill me in on how you expect it to work?

Link to comment
Share on other sites

Playing around with kOS and IR to build some ornithopters, I have come up with a very quick list of stuff I would love to see kOS do with IR:

1 Set IR group speed value (Allow faster or slower movement)

2 Set IR part target max/min position values (Allow moving a IR part to certain values)

3 Address IR parts directly (not only via action groups)

I want all 3 of these as well. The reason this next update will only do some of it is that we have been adding a lot of backend code for new language features :)

- Read the position values of a part

I want to make sure i understand what you want here. I imagine you are talking about wanting the position and the rotation relative to the root part of the vessel?

- If parts have addressable IDs (like engines, or IR parts) it would be great if kOS would add the ID value to the rightclick menu in the SPH/VAB and while in flight

we have had a lot of discussion about this and the lame part is adding a part module to every part in the game. This is a no-no for good reason but we havent come up with a better solution :P

One unrelated thing:

- Get the throttle value (to allow using the throttle to control stuff)

there are ways to do that now. Making it easier would be good.

First of I love your mod!

I would request one small change though. Could you please make it so that the mod will read .kos files as well as .txt files in the archive that would make it so that I can write a plugin for sublime that will automatically recognize any .kos file as a KerboScript file.

-Eforen

part of the next release should include different file extensions :)

Link to comment
Share on other sites

You know what, I have never used the boot feature after i got the PR for it. I should have a test craft for it :P if it is no longer working I am sorry and ill get it back in. Care to fill me in on how you expect it to work?

Apparently I am an idiot, as I forgot that you need to add a boot.txt to the Archive to see the relevant options. I even explained this to someone in this thread when the feature was introduced :confused: I remember that there were some issues when going back and forth between VAB/SPH and launch, I will fiddle a bit with it to see whether that is still the case.

I want to make sure i understand what you want here. I imagine you are talking about wanting the position and the rotation relative to the root part of the vessel?

I think I proposed this a while back for engines - it might make VTOL related scripts a lot easier if you have some way of finding out how the thrust vector of an engine related to the CoM and other relevant values. I am not sure I am comfortable with just giving people the CoM though, as this is something that is not that easy in real life either. The engine values are less of a problem, as sensors on the engine could provide all the data you need.

Edited by Camacha
Link to comment
Share on other sites

Is it possible to make the part facing give this? The direction it currently gives is 90deg from the direction of thrust (for the engines I tested), but as rotation is done about the vessel facing i can't think of a way to get it in line.

quick test script, identifies an engine in stage 2 and draws its facing.


SET vec TO vecdraw().
UNTIL 1 > 2 {
List engines in foo.
for eng in foo {
IF eng:STAGE = 2 {
SET dir to eng:facing.
}.
}.
SET vec:VEC TO dir:vector.
SET vec:SCALE TO 5.
SET vec:SHOW TO true.
}.

Edit: oops code was wrong, forgot to loop the list engines.

Edited by TDW
Link to comment
Share on other sites

* extended button lockout to include the full throttle button (default z)

Can you also add it for "c"? Generally, craft that use kOS won't have internal spaces but with the Probe Control Room mod being so awesome I generally have it for use with all my probe craft.

Link to comment
Share on other sites

Can you also add it for "c"? Generally, craft that use kOS won't have internal spaces but with the Probe Control Room mod being so awesome I generally have it for use with all my probe craft.

It works by suppressing the control called "THROTTLE_FULL" (look in your KSP settings.cfg file), regardless of what the keypress it's assigned to actually is. The default is 'z' but if you change it in the settings panel, then whatever you set it to will be affected by what kOS did.

We didn't like having to implement the lockout of the throttle cutoff (default 'x') and throttle full (default 'z') keys in this very crude, rude way, but SQUAD annoyingly left those controls out of the control lockout system they expected mods to use. Even if you tell KSP to lock out ALL controls entirely, the throttle cutoff still leaks through (and we assumed the new 'z' was the same way).

Link to comment
Share on other sites

Is it possible to make the part facing give this? The direction it currently gives is 90deg from the direction of thrust (for the engines I tested), but as rotation is done about the vessel facing i can't think of a way to get it in line.

quick test script, identifies an engine in stage 2 and draws its facing.


SET vec TO vecdraw().
UNTIL 1 > 2 {
List engines in foo.
for eng in foo {
IF eng:STAGE = 2 {
SET dir to eng:facing.
}.
}.
SET vec:VEC TO dir:vector.
SET vec:SCALE TO 5.
SET vec:SHOW TO true.
}.

Edit: oops code was wrong, forgot to loop the list engines.

Can you include a screenshot image of what that vecdraw is looking like when you run this code?

Link to comment
Share on other sites

It works by suppressing the control called "THROTTLE_FULL" (look in your KSP settings.cfg file), regardless of what the keypress it's assigned to actually is. The default is 'z' but if you change it in the settings panel, then whatever you set it to will be affected by what kOS did.

I probably should have explained better. Not talking about a key remap but a different control. "c" by default will switch you into the ship's IVA. If I have Probe Control Room installed, every time I type "c" into the kOS window I'm toggled into and out of the IVA. For now I just have the mod folder out of my /GameData when I plan to do heavy typing in a kOS console

Link to comment
Share on other sites

I probably should have explained better. Not talking about a key remap but a different control. "c" by default will switch you into the ship's IVA. If I have Probe Control Room installed, every time I type "c" into the kOS window I'm toggled into and out of the IVA. For now I just have the mod folder out of my /GameData when I plan to do heavy typing in a kOS console

Then Probe Control Room must be doing something wrong, because that same problem does NOT happen with the "C" key in Stock, where it is also the key for going to the cockpit, and yet kOS lets you type 'c' into the window in stock without going to the cockpit. The Probe Control Room mod must be mapping the 'c' key in some way that is rudely overriding the usual input processing order of things.

The difficulty of trying to stop that the way we stopped the "X" and "Z" keys is that we *didn't* stop the X and Z keys explicitly. We stopped the input action "THROTTLE_CUTOFF" and "THROTTLE_FULL", without ever mentioning the actual keypress they are mapped to. To do this for Probe Control Room's "C" key the same way, Probe Control Room would need a similar input event name like THROTTLE_CUTOFF that we could hook into.

Edited by Steven Mading
Link to comment
Share on other sites

I want to make sure i understand what you want here. I imagine you are talking about wanting the position and the rotation relative to the root part of the vessel?

No, actually just the current position of the moving parts, that might be rotation or travellength, depending on the part.

Link to comment
Share on other sites

Question:

I'm trying to do some exception handling if the script is run without the required parameter. Here's what I tried to use:

 declare parameter talt.   
set me to ship.
set bod to me:obt:body.
if (not talt or talt < bod:atm:height) {set talt to bod:atm:height * 1.2.}.

but what I get back is:

Object reference not set to an instance of an object.

Am I missing something, or is this not an option?

X-post from r/kOS

Link to comment
Share on other sites

Why after ending a program throttle goes back to 0.5? Or I have missed something?

When a program releases throttle, by ending or by UNLOCK THROTTLE, it goes back to whatever was set before the program took control. This will be 50% if you started the program on the launch pad without first resetting throttle.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...