Jump to content

kOS Scriptable Autopilot System 0.9


KevinLaity

Recommended Posts

Maybe not, but the post I was responding to WAS about English and whether the English meaning of a semicolon fits into a programming language.

They comply to C-like structures when I have absolutely no choice. If you read my blog, you know that implementing braces was a last resort for me.

As a programmer who works regularly with 5 different languages and has worked in the past with at least 10 others, I feel that it only helps you grow as a programmer to be confronted with new syntaxes and push yourself out of your comfort zone. If nothing else, it encourages you to do more thinking and less knee-jerk reacting.

I admire you're spirit, and to some extent I'd accept that on sight as a reason. It's not as fun for everyone, though. I don't find learning coding languages easy or fun most of the time. I'm not a natural or a trained coder, I taught myself PHP and moved out from there. In this age of everyone having access to stuff like this I'd bank there are a lot more people like me around than there used to be :)

That said, okay. I concede you have good reasons and aren't just being awkward ;) IF it keeps the project fun and interesting for you then that way you are much more likely to keep going so that's a decent reason to not worry about it.

If I were to switch the terminator to be more C-like, well there would always be "just one more" C-like thing people would want it switched to as well. Eventually my mod would be pointless, because KSP already has a 100% C-like way to program it: writing your own mod.

Part of the fun of developing kOS is being able to throw out convention and try new unexpected things.

What I absolutely do not want is to create rage wars of people trying to share code and yelling at each other for not using the "one true terminator." And frankly, from my point of view, we've already passed the point where I would even consider doing a hard-change to semicolon for everyone.

Wasn't trying to create a rage war of any kind, I've been around the Internet too long to even have any delusions of that kinda crap being a fun idea any-more. I also didn't take into account the fact that you can write mods in C# for KSP, that's a good point ^_^ (altohugh I think C# technically is a bastardisation, rather than an implementation of C, but that's just my FOSS developer head talking ;) )

I definitely want to give mod developers a way to join in, in ways that each mod doesn't require the other, but that they can optionally work together. I've been in some talks with the creator of infernal robotics about this. I did notice in one of my DLL fishing expeditions something about messaging for parts. This might hold the key.

That's good and I like it but it's really only half what I meant. I was referring to people writing importable script libraries with complex pre-written functions to save the lazy and less able time writing functions and bug testing them when someone already did it. It'd also allow those that want to use the tools extensively on a wide range of vehicles to write reusable libraries that they can use simply and quickly on each new vehicle. Just a though.

What I'd like is for mod developers to be able to register their own bindings and maybe even commands with kOS. And/or let kOS send strings to a part that have commands in them. Like TELL kethaneDrill TO "Deploy Drill".

I like that idea too. Very much.

I did bring this idea up before, I think it's a cool idea and the kOS terminal already functions in a way that (I think) should be pretty compatible with telnet. But I don't have the time to work on this at the moment.

It's a 'maybe later' one for sure. Basic functionality is much more important, I agree.

Thank you, and I hope you and others find the unique quirks of KerboScript more endearing than annoying!

I'll persevere, but if I end up throwing my PC out of the window it's your fault! ;)

One other point, why is the mod content in the ZIP not in a folder structure I can throw into my GameData folder? i.e.:

/kOS/Plugins

/kOS/Parts

Just a thunk, as it seems to be convention to make stuff either a one-drop in to GameData or unzip-to-KSP-root compatible.

Edited by MDBenson
Link to comment
Share on other sites

I haven't tried that. All my experimentation has been in orbit. Idea: is there any architectural reason you can't pipe unhandled exceptions onto the console? It makes sense in-universe, it is a computer after all. For bug tracking purposes: I'm using the latest Steam version of KSP, on Windows 8 64-bit. The only mod running alongside this was Kerbal Engineer Redux, dunno what version. Also, you know what would be really nice? Functions. Or at least the ability for programs to return values to the program that called it.

Currently it'll automatically trap any kOSException and show it in the terminal. This is where your in-game error messages come from. Anything else falls through.

This seems to work well enough for my purposes because if there ever is an exception that's the result of a bug in my code, the terminal will stop working and I'll know to check the output file. I'm better off with the output file because the terminal has limited space. I guess I could show a "Flagrant error, computer over!" error message and then rethrow the Exception to still get the output.

Link to comment
Share on other sites

I guess I could show a "Flagrant error, computer over!" error message and then rethrow the Exception to still get the output.
Better still, play a little animation of the terminal catching fire.
Link to comment
Share on other sites

So for us who have no programming experience would you not recommend this mod? Id love to automate my launchs and just not worry about the craft at all until orbit. I like taking cinematic shots, but its very difficult if I have to control the craft at the same time. So this sounds like the perfect tool.

Now I can follow what you did in the video, but just copying what you typed is no way to learn. And I build large, complex craft so id imagine the program would have to be more complex as well. I've gone through over 20 pages of this topic and everyone seems to be a programmer of sorts. So I said screw it after I saw there was 20 more pages to look through. So I'm sorry if I over looked it, but do you have a "kOS for Dummies" guide anywhere by chance?

And I don't want mechjeb. Yes it can do all this, but I only want this for launches ( for now ). And I fear I will succumb to mechjebs other automation features and I do not want that.

Link to comment
Share on other sites

So for us who have no programming experience would you not recommend this mod? Id love to automate my launchs and just not worry about the craft at all until orbit. I like taking cinematic shots, but its very difficult if I have to control the craft at the same time. So this sounds like the perfect tool.

Now I can follow what you did in the video, but just copying what you typed is no way to learn. And I build large, complex craft so id imagine the program would have to be more complex as well. I've gone through over 20 pages of this topic and everyone seems to be a programmer of sorts. So I said screw it after I saw there was 20 more pages to look through. So I'm sorry if I over looked it, but do you have a "kOS for Dummies" guide anywhere by chance?

And I don't want mechjeb. Yes it can do all this, but I only want this for launches ( for now ). And I fear I will succumb to mechjebs other automation features and I do not want that.

There is a WIKI in the making that might help, but no there is currently no "for Dummies" resource. Maybe there should be!

I am VERY interested to see how far a non-programmer is able to get with this.

For now I would say, go ahead and try building bigger craft using the same program. See what happens. If something goes wrong, see if you can figure out by looking at the program what went wrong, and why. And then see if you can come up with a way to fix it.

Link to comment
Share on other sites

I've figured out the problem. Apparently the keyword "steering" is case sensitive, it needs to be all lowercase. This is not the case for other keywords, such as LoCk or Prograde. The line terminator put me in a COBOL frame of mind, I guess, because I was typing my commands in all-caps. I think inconsistent case-sensitivity is a considerable usability issue, might even be a bug.

Link to comment
Share on other sites

Why is this happening?

chkwNy1.jpg

The files are in the appropriate folder, too:

C:\Users\rpayne88\Downloads\ksp-win-0-21-1\KSP_win\PluginData\kOS

Edit: never mind, I figured it out.

How am I supposed to used this if the space bar also stages the rocket while I'm entering a program and backspace triggers the abort sequence?

Edited by rpayne88
Link to comment
Share on other sites

Just a thunk, as it seems to be convention to make stuff either a one-drop in to GameData or unzip-to-KSP-root compatible.

This is something that needs to be fixed soon. I think when I started building it the convention was as I have it now. When it switched, I didn't get the memo!

Also apparently, support for the folder structure I currently have may go away.

Edit: To clarify, I started building this in KSP 0.18 which was quite some time ago

Edited by KevinLaity
Link to comment
Share on other sites

How am I supposed to used this if the space bar also stages the rocket while I'm entering a program and backspace triggers the abort sequence?

Those things SHOULD be locked out whenever the window is focussed, but there have been reports of conflicts with other mods that nullify that.

Link to comment
Share on other sites

You're right that in my video it's the amount of fuel left in the rocket, but that's only because I don't have any fuel tanks that are not connected to an active engine.

Looking back at your original post, it sounds like you've got a tank lying dormant. Perhaps connected to an engine but an engine isn't activated yet. That woun't count toward your stage:liquidfuel calculation.

EDIT: In debugging these things, it might be good to try a manual launch, but then when you reach the point you're expecting it to stage at, do a PRINT stage:LiquidFuel. You can bind that to an action group if good timing is needed.

Well, I've tried what you recommended. I've been trying for a while now every possible number of liquid fuel left to stage at, so it must be some other problem.

Here's a picture of my rocket and program:

q77vSeN.jpg

Is there anything you can pick out form this that's wrong?

Link to comment
Share on other sites

Kevin, I've been looking into this pretty deep because I REALLY REALLY want it to work with infernal robotics.

TLDR; Version:

Create two things in your code:

KOS-Vars(key,value)

adds or updates the key value pair in your variables collection

alias the script processor "tell" command to unityengine.sendmessage(methodname,message,value)

You're done.

We're definitely on the right track with this. But I want to have a part-registration model where parts register themselves with kOS.

I think there's a few benefits to that:

- LIST PARTS can be made list only the kOS compatible parts

- I can then easily address individual parts

- The mod developer can decide exactly what messages to get

- We can potentially offer bindings that work with SET, PRINT etc

- We can potentially give mod developers the ability to come up with their own commands.

Link to comment
Share on other sites

liquid fuel is a total figure, not just the amount in the lower tank. You'd need to set it to a figure greater than the amount in the T400 in the upper stage (180? I forget) to get it to trigger.

Except he's not using <liquidfuel>, he's using stage:liquidfuel, which should work.

Panichio:

Try:

wait until stage:liquidfuel < 0.01.

Link to comment
Share on other sites

How exactly does WHEN work? Polling or interrupt? Fire once or repeatedly? Does it expire when exiting a curly brace scope?

This caused KSP to freeze completely:

lock steering to up + r(0,-90,-90).
when eta:apoapsis < 15 then lock throttle to 1.
when (eta:periapsis < 30) OR ((eta:apoapsis > 30) AND (eta:apoapsis < eta:periapsis)) then lock throttle to 0.
wait until periapsis > 70000.

Link to comment
Share on other sites

How exactly does WHEN work? Polling or interrupt? Fire once or repeatedly? Does it expire when exiting a curly brace scope?

This caused KSP to freeze completely:

lock steering to up + r(0,-90,-90).
when eta:apoapsis < 15 then lock throttle to 1.
when (eta:periapsis < 30) OR ((eta:apoapsis > 30) AND (eta:apoapsis < eta:periapsis)) then lock throttle to 0.
wait until periapsis > 70000.

It uses polling, fires once, and does not expire when leaving curly brace scope.

I'll take a look at that code

Link to comment
Share on other sites

Well I just figured out that programs can be launched from within another program, but I forgot why I wanted to do that.

You can, but I was having problems with it.

http://forum.kerbalspaceprogram.com/showthread.php/47399-kOS-Scriptable-Autopilot-System-0-45?p=633912&viewfull=1#post633912

Program runs fine on it's own, but steering and throttle commands have no result when run from another program.

Link to comment
Share on other sites

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