untoldwind / KontrolSystem2

Autopilot scripting system for KSP2
Other
54 stars 15 forks source link

Action Group support, or at least change RAPIER cycle mode? #10

Closed SodaPopinski closed 1 year ago

SodaPopinski commented 1 year ago

Is there a method to activate an action group? I'm using them to toggle RAPIERs between closed and open cycle.

untoldwind commented 1 year ago

We are currently figuring out how to trigger action groups the "correct way". My initial guess just to call VesselComponent.SetActionGroup does not seem to be reliable enough. Once that is sorted out it should be easy to add all the custom action groups

untoldwind commented 1 year ago

... and I just took a brief glance that new the EngineMode. In KSP2 this is now much more generic and not just "AirBreathing Y/N`, i guess a preparation for some of the futuristic engines to come. If I remember correctly one the "Near Future" mods of KSP1 had some Vasimr-like engines that could operate in multiple modes as well.

Anyway, that will take a moment to sort out ;)

untoldwind commented 1 year ago

Current release: https://github.com/untoldwind/KontrolSystem2/releases/tag/v0.1.7 has bindings for all the custom action groups as well es additional mode information for the engine.

A little script to demonstrate:

use { Vessel } from ksp::vessel
use { CONSOLE } from ksp::console

pub fn main_flight(vessel: Vessel) -> Result<Unit, string> = {
    CONSOLE.clear()

    CONSOLE.print_line("No Engines: " + vessel.engines.length.to_string())

    for(engine in vessel.engines) {
        CONSOLE.print_line("No Modes: " + engine.engine_modes.length.to_string())
        CONSOLE.print_line("Current mode: " + engine.current_engine_mode.name)

        for(mode in engine.engine_modes) {
            CONSOLE.print_line("  Name: " + mode.name)
            CONSOLE.print_line("  Type: " + mode.engine_type)
        }
    }
}

How to do the mode-switch via the api I still have to figure out. Hope this is helpful anyway.

untoldwind commented 1 year ago

Did you have a chance to retest this with the 0.1.1.0 version? If I recollect the RAPIER engines were mentioned in the patchnotes

untoldwind commented 1 year ago

Closing this for to keep the list of issues manageable. Reopen if it still persists.