Jump to content

[KSP 1.12.x] kOS v1.4.0.0: kOS Scriptable Autopilot System


Dunbaratu

Recommended Posts

Hello kOS team (especially @Dunbaratu),

first off, let me thank you for a most excellent mod - I can't image playing KSP without it anymore.

And on that note, now that the KSP2 release date has been announced: Do you have any plans to carry kOS over to KSP2? 

The reason I am asking ist that I have an idea for a kOS-like mod for KSP2 that I want to implement (because I can't imagine playing KSP2 without something similar either, nothing like it seems to be on the official roadmap, and I need something to tide me over the sandbox only phase of early access - and what could be better to pass that time than writing a mod?), but don't want to step on anyones toes by implementing a "competing" mod.

 

Edited by RKunze
Link to comment
Share on other sites

On 10/23/2022 at 8:15 PM, RKunze said:

Hello kOS team (especially @Dunbaratu),

first off, let me thank you for a most excellent mod - I can't image playing KSP without it anymore.

And on that note, now that the KSP2 release date has been announced: Do you have any plans to carry kOS over to KSP2? 

The reason I am asking ist that I have an idea for a kOS-like mod for KSP2 that I want to implement (because I can't imagine playing KSP2 without something similar either, nothing like it seems to be on the official roadmap, and I need something to tide me over the sandbox only phase of early access - and what could be better to pass that time than writing a mod?), but don't want to step on anyones toes by implementing a "competing" mod.

 

Why would you do that before KSP 2 is out? Maybe there is a built-in scripting engine?

Link to comment
Share on other sites

4 minutes ago, infinite_monkey said:

Why would you do that before KSP 2 is out? Maybe there is a built-in scripting engine?

I won't do it before it is out (would be a bit difficult to write a mod for an unknown target).

But I will do it once KSP2 is in EA, because then I have a scripting engine when career mode (or whatever replaces it in KSP2) comes out and I'll start playing (I don't like pure sandbox).

As for a builtin scripting engine: If there is one, great. But it hasn't been mentioned anywhere, it's kind of niche even among the hardcore fans here, so it's a good bet it won't be in the official game.

And it is kind of low hanging fruit for a mod (at least for me - I can code because that what I do for a living, but I'm abysmal at art and modelling, so you won't see me do any part mods or planet packs)

Link to comment
Share on other sites

10 minutes ago, RKunze said:

I won't do it before it is out (would be a bit difficult to write a mod for an unknown target).

But I will do it once KSP2 is in EA, because then I have a scripting engine when career mode (or whatever replaces it in KSP2) comes out and I'll start playing (I don't like pure sandbox).

As for a builtin scripting engine: If there is one, great. But it hasn't been mentioned anywhere, it's kind of niche even among the hardcore fans here, so it's a good bet it won't be in the official game.

And it is kind of low hanging fruit for a mod (at least for me - I can code because that what I do for a living, but I'm abysmal at art and modelling, so you won't see me do any part mods or planet packs)

I see. Do you plan something compatible with the kOS language? Or your own, or an existing one, like Lua?

Link to comment
Share on other sites

9 minutes ago, infinite_monkey said:

I see. Do you plan something compatible with the kOS language? Or your own, or an existing one, like Lua?

Not quite sure yet. Probably something based on blockly for a start, maybe with a kerboscript frontend later on. Part of it will very likely be a REST (or WS) API to the ship controls, so it could work kind of like kRPC too (i.e. you can hook up any programming environment to it which can do HTTP and JSON).

If you want to discuss the idea further, we should move it to a different thread though and not clutter up the kOS thread.

Link to comment
Share on other sites

  • 4 weeks later...

Hiyya, for some reason the Scriptable Control System isn't in game, but the kOS control bar buttons and pop ups are?
Im on version 1:1.3.2.0 and installed using ckan

Nevermind, it was just renamed to SCS, not Scriptable Control System

Edited by ComputerErika
Found out what I did wrong
Link to comment
Share on other sites

  • 2 months later...

Update: kOS 1.4.0.0 - Catch-up for over a year of little things

for KSP v1.12.4 Downloads this release

It's been 2 years since the last kOS release, and a lot of
small changes have trickled in. None were big enough on
their own for a full release but there's been enough of
them and it's been long enough that a release has been
needed for a while now. Since KSP 2 is about to start
hitting early access, it seemed right to get all these little
things out for kOS for KSP 1 just before that happens.

This will also make it so people won't have to keep
overriding the complaints of CKAN for trying to use
kOS on KSP 1.11.x or KSP 1.12.x. (Which it worked for
but CKAN didn't know that. Now it should know that.)

BREAKING CHANGES

  • The bugfix to prevent a local variable from clobbering a
    builtin name could make existing scripts have to rename
    a variable or two.

    Previously if you tried to create a variable that matches
    the name of a built-in variable, it would let you but then
    the built-in variable would be permanently masked and
    unreachable.

    Now by default it won't let you. BUT you can get the old
    behavior back again if you use the @CLOBBERBUILTINS directive,
    if you really want to let yourself do that.
    pull request

NEW FEATURES

  • kOS parts are now findable by typing "kos" into the
    VAB's part search bar.
    pull request

  • kOS parts can be placed inside the KSP cargo inventory system.
    pull request

  • Comma-separated list of LOCAL or SET declarations can
    now be parsed. Example:

    old: local a is 3. local b is 5. local c is 10.
    can now be: local a is 3, b is 5, c is 10.

    This is similar to how it works with PARAMETER.
    pull request

  • Added VESSEL:THRUST, VESSEL:ENGINES, VESSEL:RCS.

    VESSEL:THRUST is the sum of the engine:THRUST of all
    the engines.

    VESSEL:ENGINES is the same list returned by LIST ENGINES,
    but using a somewhat nicer syntax.

    VESSEL:RCS is the list of all the RCS parts on the vessel.
    pull request

  • Added OPCODESLEFT bound variable. This bound variable
    returns the number of instructions yet to execute (how
    much of CONFIG:IPU's instructions there are to go in
    this fixedupdate). Intended to help decide if a WAIT 0.
    would be prudent before entering a critical section of
    code.
    pull request

  • Better integration with RP-1's avionics tech progression.
    (No longer have to buy into the tech from the R&D building
    to cause the kOS cores in avionics parts to get the upgrade.)
    pull request

  • Better integration with RP-1's avionics lockouts when the
    avionics doesn't support the mass. (Previously kOS couldn't
    use ANY of the controls when avionics were insufficient, even
    ones RP-1 meant to still work with insuficient avionics,
    like RCS fore and aft.)
    pull request

  • kOS parts are now findable by typing "kos" into the
    VAB's part search bar.
    pull request

  • Can now read a binary file as a LIST of numeric values (one
    per byte).
    pull request

BUG FIXES

  • Documentation: Many small one-line documentation fixes that are
    too numerous to mention all of them one by one.
    pull request
    pull request
    pull request
    pull request
    pull request
    pull request

  • A change to make it backward compatible with a call
    kOSPropMonitor was doing.
    pull request

  • Cause the mod RocketSoundEnhancement to stop muffling
    kOS's sounds. (By explicitly telling Unity those
    sounds don't emit from the kOS Part's "location" and
    instead are ambient.)
    pull request

  • Make PART:DECOUPLER behave more consistently with what the
    documentation says about docking ports.
    pull request

  • Reduce excessive repeats of GUI ONCONFIRM calls being triggered
    when they werent' supposed to be triggered.
    pull request

  • Remove legacy old version of kOS's computer from the parts
    definition file so it can't appear by accident in the parts bin.
    This is no longer needed for backward compatibility like it
    was before because this version of kOS cannot run on the
    very old versions of KSP that part was for anyway.
    pull request

  • When reporting the terrainheight of a geoposition, it no
    longer returns false results caused by seeing certain
    stock parts that put trigger colliders on the "terrain layer".
    pull request

  • Fix SteeringManager believing RCS blocks were capable of
    more thrust than they were (causing steering to be tuned
    wrong when steering via RCS). Problem was caused when stock
    parts now have multiple alternate RCS nozzle arrangements,
    and kOS was summing up all the thrust all the nozzle variants
    can do even though only a subset of those nozzles actually
    exist in any given variant.
    pull request
    pull request

  • When setting the volume name for a disk drive by copying the
    vessel's name to the volume's name, it now strips out
    characters that are not allowed in volume names (but are
    in vessel names, thus the bug).
    pull request

  • BOUNDS now does a better job of calculating based on
    part's colliders rather than their visual meshes which
    don't always agree with the colliders.
    pull request

  • No longer bogs down as much when someone creates the same
    LOCK expression repeatedly in a loop. (Still not a good idea,
    but kOS tolerates it better now.)
    pull request

  • Performance: No longer pays the cost of tracking a stopwatch
    when the user doesn't even have profiling turned on so they're
    not looking at the timings anyway.
    pull request

  • A VOICE's volume is now persisting properly after playing a
    NOTE. Previously playing the NOTE caused the VOICE volume
    setting to get clobbered by the NOTE's volume.
    pull request

  • Make it so kOS's ModuleCargoPart settings don't break in
    older KSP 1.10.x (which doesn't have ModuleCargoPart).
    pull request

  • Fix a bug when a thing that is locked is used as the
    left side of a suffix when setting the suffix.
    pull request

  • Prevent a local variable from clobbering a builtin name
    pull request

  • Allow kOS code to "see" a change to a manuever node's ETA
    made outside the script, after having obtained the node
    in a variable.
    pull request

  • Fix Compiler exceptions not showing the filename correctly.
    pull request

  • Fix ALT:RADAR sometimes wrong when high above ground.
    pull request

  • Fix race condition that caused terminal to spam the log
    on scene changes and sometimes spam the log enough to
    lag the game for some people.
    pull request

  • Fix throwing exception when setting SASMODE while the
    navball is hidden.
    pull request

  • Made the doc generation scripts work on python 3.x
    pull request

Edited by Dunbaratu
Link to comment
Share on other sites

15 hours ago, Dunbaratu said:

Update: kOS 1.4.0.0 - Catch-up for over a year of little things

Hi, thank you very much for the update and all your work on this awesome, must-have mod!

I have noticed it comes with Module Manager 4.1.4 bundled; I assume it should work OK with the latest version of Module Manager (4.2.2), right?
I also noticed that there are a number of Thumbs.db files in several of the included subfolders... I'm assuming all those just sneaked in, and it is safe to delete them?

Thanks again! Cheers to one of the (if not THE) best mod for KSP!

Link to comment
Share on other sites

50 minutes ago, alartor said:

Hi, thank you very much for the update and all your work on this awesome, must-have mod!

I have noticed it comes with Module Manager 4.1.4 bundled; I assume it should work OK with the latest version of Module Manager (4.2.2), right?
I also noticed that there are a number of Thumbs.db files in several of the included subfolders... I'm assuming all those just sneaked in, and it is safe to delete them?

Thanks again! Cheers to one of the (if not THE) best mod for KSP!

It should be okay to remove them.

And the newer modulemanager should work fine.

Link to comment
Share on other sites

  • 3 weeks later...

Can you bake code into parts? Let's say I want to make a primitive avionics unit for an early sounding rocket that, rather than allowing direct control via the arrow keys, allows you to enter a pitch over angle and a throttle cutoff altitude or something. So that you set those parameters, and then press launch and wait. Is that something that could be done?

Link to comment
Share on other sites

11 minutes ago, Nnimrod said:

Is that something that could be done?

Yes, there are a few ways. For instance through assigning the kOS name of the part and parsing the name in your script, or through an input terminal after launch, or by editing an external script file.

Link to comment
Share on other sites

3 hours ago, kojot said:

I would love that, but similarly as MechJeb dev mentioned, I believe KSP2 is not yet in state where it is worth to invest time for writing mods.

yes i did mean later in the development of KSP 2 
as the only mods i can image being usefull right now are ones that allow people to recover from bugs

also in KSP 2s current state there are almost to many bugs where a KOS code would defonatly never do anywhere near the same thing over and over
and idk how well KOS in general would deal with bugs (it wouldnt)

(Sorry for bad spelling)

Edited by callmecapy
pointing out how i cant spell if my life depended on it
Link to comment
Share on other sites

  • 2 weeks later...

Hello,

I would like to run Baker's kOS script:

I put the Baker2.2.0.ks in my /Ships/Script folder and rename it simply baker.ks.

Then I Iaunch KSP, make a test vessel with one cockpit and one kOS computer (with enough disk space to handle baker.ks).

I launch it and type in kOS terminal:

Quote

SWITCH TO 0.

COPYPATH("0:/baker.ks","1:/baker.ks").

SWITCH TO 1.

LIST FILES.

Baker.ks shows up as expected.

RUN BAKER.

Then I choose to run program 66: atmosphere autopilot. At this moment, it doesn't work as expected and I get a bunch of messages like:

Called from 1:/baker, line 10572

        menuanswer().

                                    ^

Did I do something wrong installing/launching this script? I'm a begginer with kOS and it's my first time using a heavy .ks like this.

Thanks in advance for your help!

Link to comment
Share on other sites

On 3/14/2023 at 2:19 PM, Hippodingo said:

Hello,

I would like to run Baker's kOS script:

I put the Baker2.2.0.ks in my /Ships/Script folder and rename it simply baker.ks.

Then I Iaunch KSP, make a test vessel with one cockpit and one kOS computer (with enough disk space to handle baker.ks).

I launch it and type in kOS terminal:

Did I do something wrong installing/launching this script? I'm a begginer with kOS and it's my first time using a heavy .ks like this.

Thanks in advance for your help!

Edit - Nevermind, I'm lacking sleep and misread the question. :)

However, when it throws an error with the line number, you can usually debug starting there. Search the file for menuanswer(), then look for where that function is. My guess is copying over to the local drive may be resulting in a path to a dependency being incorrect if an assumption was made in the script that you would be running this from the archive.

Edited by Zelda
Lack of sleep
Link to comment
Share on other sites

9 hours ago, Zelda said:

My guess is copying over to the local drive may be resulting in a path to a dependency being incorrect if an assumption was made in the script that you would be running this from the archive.

Thanks for your answer! Same thing happens if I try to launch the script in archive:

SWITCH TO 0.

RUN BAKER.

But you're talking about a dependency, maybe I should recheck that baker.ks doesn't call something that is not where it is expected to be.

Link to comment
Share on other sites

7 hours ago, Hippodingo said:

Thanks for your answer! Same thing happens if I try to launch the script in archive:

SWITCH TO 0.

RUN BAKER.

But you're talking about a dependency, maybe I should recheck that baker.ks doesn't call something that is not where it is expected to be.

Yeah, that's where I'd start! I don't know the Baker script very well, but I will also try to take a look at it this evening to see if I can help find the issue. :)

Link to comment
Share on other sites

6 hours ago, Zelda said:

I will also try to take a look at it this evening to see if I can help find the issue. :)

Thank you!

I just looked at it, it seems that the functions in the error messages are all defined in the Baker.ks script itself. So I guess it is not a dependency issue.

I'm beginning with kOS, but I found out that functions can be either local or global. Could it be that the script tries to call local functions and it doesn't find them because they are not global?

Edit: if you want to test it, add "@CLOBBERBUILTINS on." at the beginning (I guess you know this, but it could save you a little bit of time :)).

Edit 2: my Script folder if it can help: https://www.dropbox.com/s/t79f1ubczg8z3p4/Script.zip?dl=0

Edit 3: some other functions seem to work normally. I have atmosphere autopilot mod installed.

Edit 4: I just learnt how to scroll in terminal. I found this error message: https://www.dropbox.com/s/lpvpnb6crs49ljm/Capture d'écran 2023-03-16 231701.png?dl=0

Edit 5: I installed this: https://github.com/RCrockford/kOS-AtmosphereAutopilot and now AA interface shows up properly! https://www.dropbox.com/s/t00gb7zccscw080/Capture d'écran 2023-03-16 233416.png?dl=0

However, I can't interact with this page, no matter what MFD button I press nothing happens. Maybe are there some MFDs that work better with kOS than others?

 

Edited by Hippodingo
Link to comment
Share on other sites

  • 3 weeks later...

Can anyone think of any reason this might happen?

Why do the vessels all have no parts?

=============== Code snippet

declare function FindGndRelays {
    Global AllShips is 0.
    list targets in AllShips.    
    for AS in AllShips {
        Print AS:Name + " AS " + AS + "Parts " + AS:Parts.
        log "<" + AS:Name + "> AS " + AS + "Parts " + AS:Parts to "BugParts.txt".
        if isAGndRelay(AS) {
            AddGndRelay(AS).
        }
    }
    return AllRelays.
}

========================== log file output

Contents of "BugParts.txt"

<Overseer> AS VESSEL("Overseer")Parts LIST of 0 items:

<Scansat> AS VESSEL("Scansat")Parts LIST of 0 items:

<Bad lands lake> AS VESSEL("Bad lands lake")Parts LIST of 0 items:

<Ice shelf tundra ice caps> AS VESSEL("Ice shelf tundra ice caps")Parts LIST of 0 items:

<Relays> AS VESSEL("Relays")Parts LIST of 0 items:

==========================

Print vessel("Overseer"):Parts    (also says the list is of zero length)

Print vessel(name of current ship)   (does give me the part list)

 

I believe as (I am sure i remember the code working) that I used to be able to interrogate the parts on vessel outside physics range.

has that changed?

=========================

Also maybe relevant that i have a LOT of vessels ...  (just checked 132)

=========================

So I slept on it: it plausible that code never worked (parts wer never available unless loaded) and i remembered wrong...

 

 

 

 

Edited by AxleGreaser
more clarity
Link to comment
Share on other sites

  • 2 months later...


If ship:orbit:body:name="kerbin" and Periapsis>70000{
    until (ship:orbit:HASNEXTPATCH and ship:orbit:NEXTPATCH:body:name="mun")
    {
        if HASNODE remove NEXTNODE.
        run "0:/nodetomun".  <====
        MNV_EXEC_NODE().
        wait 10.reboot.
    }

Edited by danielboro
Link to comment
Share on other sites

  • 1 month later...

I read through the documentation, and see that it is possible to query the status of each Action Group (AG).  Is it also possible to query which Action Set (AS) is currently in use?  Or to set the desired AS?

Also, is it possible to search and find specific IVA Prop labels, and then to set them?

Here's what I envision:

  • Find ActionGroupsProp
  • Set ActionSet to 4
  • Set ActionGroupsProp:ActionsLabel to "AS4 Actions"
  • Set ActionGroupsProp:AG1Label to "MyLabel1"
  • Set ActionGroupsProp:AG2Label to "Another"
  • Set ActionGroupsProp:AG3Label to "3rdLabel"
  • etc
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...