untoldwind / KontrolSystem2

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

Is it possible to run scripts on two separate craft? #86

Closed SodaPopinski closed 3 months ago

SodaPopinski commented 1 year ago

After I decouple my craft, I've got two craft. I'd like to be able to run two different scripts on each one. Any way to do this at this point?

untoldwind commented 1 year ago

I just added a ksp::vessel::get_vessels_in_range() function to actually get a list of other vessels that are potentially controllable. So far I only did some basic testing, but the SteeringManager seems to work on non-active vessel. Though I was not able to "remotely" activate the RCS (it only became really active when switching the active vessel).

That said: Starting a script on one vessel, then switch the active vessel and starting another script seems to be mostly fine. Though there seems to be some strangeness with the control_frame that I do not fully understand yet.

untoldwind commented 1 year ago

I added this to the 0.4.1.1 release. There is now also a ´vessel.make_active()´ method to switch the active vessel in a script.

Activating and controlling RCS on a non-active vessel is still not working. This might be a bug/missing-feature in the game itself. There seems to be some code in the Module_RCS that prevents flight control input being processed if the vessel is not the active vessel.

untoldwind commented 1 year ago

In the 0.4.1.2 I added some functions to launch scripts programmatically:

use { Vessel, get_vessels_in_range } from ksp::vessel
use { MAINFRAME } from ksp::game

pub fn main_flight(vessel: Vessel) -> Result<Unit, string> = {
    const other = get_vessels_in_range().find(fn(v) -> v.name == "Kerbal K2-12").ok_or("Other not found")?

    const dockit = MAINFRAME.find_process("dock").ok_or("Dock not found")?

    dockit.start(other)
}

This should do the same as launching the "dock" script for the vessel with name "Kerbal K2-12" via the UI. But as said before: Controlling a vessel which is not active might lead to some unexpected behavior.

github-actions[bot] commented 3 months ago

This issue is stale because it has been open for 60 days with no activity.

github-actions[bot] commented 3 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.