Jump to content

[1.3] kOS Scriptable Autopilot System v1.1.3.0


erendrake

Recommended Posts

I actually don't really care about the output. And I think I just accidentally stumbled over the beta feature as well.

I assume that "run program (400, 2) on 2." does not throw an error but instead caused the terminal of the second module to spit an exception is related to this :P

I guess the exception was because the parameters didn't make it. Going to try with a simple program without parameters next...

I wanted it more for simple programs with no output anyway. Like, I wrote a simple script that operated some infernal robotics stuff when the gear got lowered and moved stuff back when gear was being raised. I would not want to go around my craft on each launch and start up these kinds of trivial subsystems on a bunch of kOS cores so it would be good if I could have a startup program do it :)

Edit: While on the subject of IR and kOS... I need more action groups ahhhh... *dies* :confused:

Edit 2: *undies* without parameters works, pretty nifty. Tried to write a script that prints the id number of each core to its terminal, but that didn't work in a neat way because after "run ... on" variables don't seem to be supported. IE:


//works:
run program on 1.

//doesn't work:
set x to 1.
run program on x.

Anyways... probably ok for things that aren't yet there to not work in every possible regard :P

Edit 3: (getting ridiculous with the edits...) here's core ident code in not neat way:


run temp on 1.
delete temp.
log "clearscreen. print 2." to temp.
run temp on 2.
delete temp.
log "clearscreen. print 3." to temp.
run temp on 3.
delete temp.
log "clearscreen. print 4." to temp.
run temp on 4.
delete temp.
log "clearscreen. print 5." to temp.
run temp on 5.
delete temp.

// neat but doesn't work :(
// SET X to 1.
// UNTIL X > 10 {
// log "clearscreen. print " + x + "." to temp.
// run temp on x.
// delete temp.
// set x to x + 1.
// }.
   log "clearscreen. print 1." to temp.

Edited by the_bT
Link to comment
Share on other sites

I just started trying to use kOS, but I'm having a problem.

Every time I type ANYTHING in the terminal screen, I get the same response:

Syntax error at line 1

followed by whatever it was I typed

Does anyone know what I might be doing wrong?

Link to comment
Share on other sites

I just started trying to use kOS, but I'm having a problem.

Every time I type ANYTHING in the terminal screen, I get the same response:

Syntax error at line 1

followed by whatever it was I typed

Does anyone know what I might be doing wrong?

Can you post a few examples of what you've tried typing?

Link to comment
Share on other sites

@the_bT

- Running a program with parameters in another core is not yet supported, but I have it in my TODO list.

- There's another feature in the works to add multi threading to the cores, so you can have several programs running at once on the same core (although I haven't work on that for a while).

- Using variables as file/volume names is not yet supported but it will be eventually.

Link to comment
Share on other sites

@Camacha yes it works perfectly by now:


log "my concatenated datastring with variables in the middle" to logfile.

Very useful for debugging OR load other scripts dynamically with this trick:


// loads a script based on the name given
declare parameter scriptName.
log "copy " + scriptName + " from archive." to tmpcmd.
log "run " + scriptName + "." to tmpcmd.
log "delete " + scriptName + " from 1." to tmpcmd.
run tmpcmd.
delete tmpcmd.

Link to comment
Share on other sites

I am not sure if there's something broken but I can't edit a program. On entering "EDIT prog1." in the console all I get is a line break. Though I can toggle action groups and perform basic things like "stage." and "lock throttle". But I miss-typed throttle once and there was no error showing.

I use 0.23.5 vanilla.

Link to comment
Share on other sites

I am not sure if there's something broken but I can't edit a program. On entering "EDIT prog1." in the console all I get is a line break. Though I can toggle action groups and perform basic things like "stage." and "lock throttle". But I miss-typed throttle once and there was no error showing.

I use 0.23.5 vanilla.

The current stable version (12.1) has edit disabled, you can either create/edit .txt files with notepad or equivalent in "\KSP_win\Plugins\PluginData\Archive" and then use "copy myfile from 0." to get them into your kOS module or download the latest pre-release version which has the edit command fixed.

@MrOnak:

I played around with log in combination with run yesterday. One thing you have to be careful about is, log will append to a file if it already exists. So you might want to make sure that it doesn't by doing:

log "0" to tempcmd.
delete tempcmd.

It's a nice workaround to use variables in place of volume numbers until that gets proper support, like so:

set x to 2. 
log "switch to " + x + "." to temp1.
run temp1.

One could call that a nasty hack maybe. I don't know :P

Edited by the_bT
Link to comment
Share on other sites

@Camacha yes it works perfectly by now:


log "my concatenated datastring with variables in the middle" to logfile.

I think what Camcha was asking for was the ability to name the file with a variable, like so:


set filename_string to "logfile1".
set print_string to "this is some text in the file".
log print_string to filename_string.

And the reason you can't do that is that the filename string is read as a bare word right now, so it would make a file called "filename_string.txt" if you did that.

Unfortunately the only way to fix this breaks backward compatibility a bit. In order to treat the bare word filename as an identifier variable name to look up, you have to distinguish it from the bare word string filename literal used now. And that would mean changing it to put quotes around it when it's a literal, like so:


log "some text" to "literal_filename".
log" other text" to variable_filename.

Although you *could* do the self-modifying code workaround, it's really confusing since the self modifying code is itself also a LOG command.

Link to comment
Share on other sites

Steven Mading: What if file was a structure?

roughly like this:


//explicit
set logfile to FILE("newfile2").
set logfile:name to "newfile1". //equivalent to rename or is that a bad idea?
log "text" to logfile.

//keeping compatibility like this:
log "text" to newfile. //newfile:name is implicitly set to "newfile"

//this would also be nice to have:
print newfile:size.

Just brainstorming though, I have absolute no idea what I'm doing here...

Link to comment
Share on other sites

The current stable version (12.1) has edit disabled, you can either create/edit .txt files [...] or download the latest pre-release version which has the edit command fixed.

Thanks. It's working now.

Is there a place where the old versions are held to download?

Just FYI:

When I crash my test rocket on the launchpad and revert the flight to the launchpad, the only thing showing up is the kOS module floating in mid-air. All other part are gone and staging doesn't work. Even with kOS 12.12 this bug is present. And even when I don't crash the rocket. Revert to launchpad is enough to cause this.

After switching to the VAB and re-launching the rocket I get ... strange things. A burning rocket, attached to it's launch clamp with an eternal running engine. Switching back to the space center doesn't solve the problem. It's gone, just the menu bar with the time accelerator appears. The "return to main menu" button doesn't function. Restarting KSP solved it until the next rocket crash.

The ModuleManager shows me 7 errors in MM_Stock_Processor.cfg during the loading screen.

Edited by Crown
Found another bug
Link to comment
Share on other sites

I think what Camcha was asking for was the ability to name the file with a variable

That is exactly what I meant :) When working on a craft it can be a bit of a pain when the thing overwrites its log every time you launch.

Although you *could* do the self-modifying code workaround, it's really confusing since the self modifying code is itself also a LOG command.

I will look into that when I have some free time.

Link to comment
Share on other sites

I think what Camcha was asking for was the ability to name the file with a variable, like so:


set filename_string to "logfile1".
set print_string to "this is some text in the file".
log print_string to filename_string.

And the reason you can't do that is that the filename string is read as a bare word right now, so it would make a file called "filename_string.txt" if you did that.

Unfortunately the only way to fix this breaks backward compatibility a bit. In order to treat the bare word filename as an identifier variable name to look up, you have to distinguish it from the bare word string filename literal used now. And that would mean changing it to put quotes around it when it's a literal, like so:


log "some text" to "literal_filename".
log" other text" to variable_filename.

Although you *could* do the self-modifying code workaround, it's really confusing since the self modifying code is itself also a LOG command.

How about sh-style backticks?


log "some text" to filename. // logs to the file called filename
log "some text" to `filename`. // logs to the content of the variable "filename"

[edit]Yeah, I know, in sh backticks actually do something different. But it might be a non-breaking addition to kOS nonetheless. ...and its useful for other situations where I want to combine the contents of a variable with other commands.[/edit]

Edited by MrOnak
Link to comment
Share on other sites

Is there a place where the old versions are held to download?

That's actually a really good question. Given that it's nearly impossible to make some types of improvements without at least breaking backward compatibility a little bit, it could be nice to proved a backlog of old versions. I don't think Curse supports this but github might.

Link to comment
Share on other sites

I will look into that when I have some free time.

The ugly thing about the self modifying code workaround is that kOS has no means of protecting quote marks inside quote marks. You can't do something like:

print "\"Hello\", He said.".

And that makes it hard to use self-modifying code to write a log command using a log command. You have to store all the strings in variable names.

Link to comment
Share on other sites

Could we have a button with blizzy78's toolbar to open the terminal? I hide the part away in a compartment.

The problem with that would be if you have multiple modules on the same ship. Which one should it open a terminal to? Almost all of my ships have at least two kOS modules on them, one on the launcher upper stage and one on the payload, that way my launch script can run on my upper stage and deorbit it after releasing the payload.

To solve your accessibility-for-right-clicking problem, I'd suggest setting an action group for it.

Link to comment
Share on other sites

The problem with that would be if you have multiple modules on the same ship. Which one should it open a terminal to? Almost all of my ships have at least two kOS modules on them, one on the launcher upper stage and one on the payload, that way my launch script can run on my upper stage and deorbit it after releasing the payload.

To solve your accessibility-for-right-clicking problem, I'd suggest setting an action group for it.

I think the path to implementing it would be in two steps:

step 1: Make the terminal window capable of showing more than 1 CPU's output, via clickable tabs.

step 2: Once you have that, then you can open the terminal globally with the toolbar.

Link to comment
Share on other sites

Just FYI:

When I crash my test rocket on the launchpad and revert the flight to the launchpad, the only thing showing up is the kOS module floating in mid-air. All other part are gone and staging doesn't work. Even with kOS 12.12 this bug is present. And even when I don't crash the rocket. Revert to launchpad is enough to cause this.

After switching to the VAB and re-launching the rocket I get ... strange things. A burning rocket, attached to it's launch clamp with an eternal running engine. Switching back to the space center doesn't solve the problem. It's gone, just the menu bar with the time accelerator appears. The "return to main menu" button doesn't function. Restarting KSP solved it until the next rocket crash.

The ModuleManager shows me 7 errors in MM_Stock_Processor.cfg during the loading screen.

This problem has one solution - kOS must be alone in the part (command pods i.e.), because it's interfere with other part modules, like MJ.

Link to comment
Share on other sites

When trying to clear a list with the FOO:CLEAR. command, I seem to get a syntax error. Any suggestions what is going on there. I am testing with an actual list called foo, of course.

Could we have a button with blizzy78's toolbar to open the terminal? I hide the part away in a compartment.

This is done a lot easier with an Action Group. I always attach the number one key to the console for easy access. This should solve all your problems :)

Edited by Camacha
Link to comment
Share on other sites

Can anyone explain in a little more detail how you are supposed to use structure references? The information in the documentation is just a little to sparse to get workable results. How do I utilize things like these?

Also, in the changelog I see some are also setters. Is this documentation incomplete or is it something else?

Edited by Camacha
Link to comment
Share on other sites

Can anyone explain in a little more detail how you are supposed to use structure references? The information in the documentation is just a little to sparse to get workable results. How do I utilize things like these?

Those are suffixes that use the colon.

So for example:


LIST ENGINES IN FOO.
SET FIRSTENGINE TO FOO[0].
PRINT "First engine's ISP is: " + FIRSTENGINE:ISP.

Also, in the changelog I see some are also setters. Is this documentation incomplete or is it something else?

The documentation is a bit frozen because it only updates on full releases, not prereleases. It's been a lot longer since the last full release than it usually is.

Link to comment
Share on other sites

Do ship:facing and ship:facing:vector work differently, as the second always is (0,0,0)? Or am I overlooking something about the mechanism (possibly the weird rotational frame thing)? I am plunging back into the code and I feel things are not working as they did half a year ago. The somewhat sparse explanations in the documentation makes it a little challenging too :)

Those are suffixes that use the colon.

So for example:


LIST ENGINES IN FOO.
SET FIRSTENGINE TO FOO[0].
PRINT "First engine's ISP is: " + FIRSTENGINE:ISP.

Ah, so you have to go through a list - you can't do it directly? That is where I went wrong. Thanks for the example, I have Googled and tried a lot of things, but a pointer like that makes all the difference.

Edited by Camacha
Link to comment
Share on other sites

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