Jump to content

[1.8.1] kOS v1.2.1.0 : kOS Scriptable Autopilot System


Recommended Posts

1 hour ago, scimas said:

Check the ModuleManager documentation, it does allow checking for presence of modules among many many other things.

 

6 hours ago, darthgently said:

Is there a way to tell by the syntax of the KOSProcessor entry in the .cfg whether it is checking to see if it is already there or not?  Or does that logic occur elsewhere?  Pardon my jumping in please, but this applies to something.  I want something to grep for to automate this kind of audit for this and related situations

For module checking you want to use something like this:

 

@PART[*]:HAS[MODULE [kOSProcessor]{ }

Link to post
Share on other sites

Just to add that you'd use a ! to negate the check i.e. anything that tries to add in a kOS processor module should be checking that there isn't already one.

Something like kos-for-all goes through all parts with the Command module, adding kOSProcessor if there isn't already one. I imagine it would be harder to find examples where the check isn't done properly (if at all).

Link to post
Share on other sites
26 minutes ago, ElWanderer said:

Just to add that you'd use a ! to negate the check i.e. anything that tries to add in a kOS processor module should be checking that there isn't already one.

 

True, but it so depends on what you want to do.  If you're just checking for it to be there, before pushing the module, yeah.  But, you really want a sequential patch.

@PART[*]:HAS[MODULE[kOSProcessor]]:NEEDS[Gobbledegook]
{
    %diskSpace = 10000
    %ECPerBytePerSecond = 0.00001
    %ECPerInstruction = 0.000008
}

@PART[*]:HAS[!MODULE[kOSProcessor]]:NEEDS[Gobbledegook]
{
    %MODULE
    {
        %name = kOSProcessor
        %diskSpace = 10000
        %ECPerBytePerSecond = 0.00001
        %ECPerInstruction = 0.000008
    }
}

 

Edited by TranceaddicT
Link to post
Share on other sites

In the interest of good form and efficiency I want to use "listeners" over polling when possible. 

I have a stack of vessels connected to a main vessel and they each have multiple potential control points.  I want to detect when each has been separated and which control point takes over on that vessel any time it changes.  I'm wanting to allow for mods (TCA, mechjeb), ksp, or me (setting "control from here" for docking etc), or whatever changing the control point for whatever reason so my code can simply adapt to the situation or change it to what it requires.  One thing I'm working on is changing the colors of the nav lights on the craft to reflect current dorsal, ventral, starboard, port sides of the vessel (like the nav lights on aircraft or boats) so I can tell at a glance the orientation of the vessel as the colors change along with the change in control point (and control point orientation).  Can I "listen" for this change of control point in some non-blocking notification style way or do I have to poll for it using a WHEN that evals every loop?  I realize that from a user perspective the WHEN/ON seems like a type of event listener, but it is really polling every loop from what I can tell

Maybe a better way to ask this is what is the nature of cooked, recurring, and callback triggers with regards to whether it is more of an event listener or basically just polling.  My take so far is that some (but not all) LOCKs and cooked stuff seem like they may be more of a non-blocking event listener type mechanism underneath updating the locked variable from which can be read the most current value in a quasi-polling kind of way, while recurring WHEN/ON stuff is basically polling.  And the GUI callbacks appear to be true listeners, but a lower priority than most other code.  I haven't fully digested delegates yet but I'm thinking they could work like true listeners also.  That said, can I listen for point of control change or will I need to do a WHEN/ON or some type of delegate (that I've yet to fully understand)

Thanks!

Edited by darthgently
Link to post
Share on other sites

Nevermind.  

Going to try this I found on reddit: SHIP:CONTROLPART

But in my defense, I searched in the git docs for "control" and this did not come up! :D

Edited by darthgently
Link to post
Share on other sites

What is the best forum for discussing KOS coding detail questions?  I've about got my nav light script how I want it but want to know the best way to make it always running on all of my ships.  I don't want just hack it then have to fix it later.  But this forum seems a bit quiet for that kind of getting into the weeds on things

 

Here is question relevant to this forum: is there a way to attach an exit function to the code that always executes even if terminated by the user (ctrl-c etc)?

Edited by darthgently
Link to post
Share on other sites
  • 2 weeks later...

Please add new feature:

Now KSP supports USER AXIS INPUT.
Player can set USER AXIS INPUT to model airplane controller. (Menu-Settings-Input-Vessel-AxisActions)
Please add them to Pilot Input (Structure Control).

Thanks.

Link to post
Share on other sites
  • 3 months later...
16 hours ago, infinite_monkey said:

Can someone point me to a formula that limits my steering vector by a maximum AoA angle?

This is how I do it:

 
FUNCTION launchSteerUpdate
{
    LOCAL cur_v IS SHIP:VELOCITY:SURFACE.
    LOCAL new_v IS HEADING(launchBearing(),launchPitch()):VECTOR.
    LOCAL max_ang IS launchMaxSteer(). // returns different values depending on height/velocity

    IF VANG(cur_v,new_v) > max_ang
    {
        // limits the maximum angle between our surface velocity vector
        // and where we are aiming to steer
        SET new_v TO ANGLEAXIS(max_ang,VCRS(cur_v,new_v)) * cur_v.
    }

    SET LCH_VEC TO new_v. // LCH_VEC is a global where I store the vector I want to steer to
}

 

Link to post
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...