Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access Vessel in the VAB #127

Closed
PhilouDS opened this issue Feb 23, 2024 · 8 comments
Closed

Access Vessel in the VAB #127

PhilouDS opened this issue Feb 23, 2024 · 8 comments
Labels
enhancement New feature or request question Further information is requested stale Issue has not seen activity for 60 days

Comments

@PhilouDS
Copy link
Contributor

Hello.
I've written some UI scripts to use inside the VAB with the main_editor function. That works very well.

I'm wondering if it's possible to have access to the vessel, more precisely to each part of the vessel. For now, it doesn't seem possible. I wanted to compute myself the mass and the delta-v of my craft. Even the mod MicroEngineer makes mistakes sometimes.

Thanks.

@untoldwind untoldwind added enhancement New feature or request question Further information is requested labels Feb 24, 2024
@untoldwind
Copy link
Owner

I did some preparation to have entry points for all the different game modes, but this was mostly taken over from the original implementation for KSP1. Obviously the main focus has been on the flight-mode so far and wait for all the other parts of the game to settle down for a bit.

From what I can tell, inside the VAB the vessel (as understood by ksp::vessel::Vessel) does not even exist yet. It is "created" when pressing the launch button. Until then there just seems to be a collection of parts, that do not even need to be connected yet ... which kind of makes sense considering that you want to shift things around.

... in short: I do not think the current bindings in ksp::vessel will actually work in the VAB as they are right now. Most likely here has to be a different API, which might have a some overlap with the existing one.

I'll take a look if there are some low hanging fruits that do not require a total overhaul.

@PhilouDS
Copy link
Contributor Author

Okay, I perfectly understand that.
Thanks for your answer and for your great work!

@untoldwind
Copy link
Owner

I am still trying to figure out want kind of information are available in to VAB and what is specific to the flight-mode, so this is still somewhat minimal.
But there is now a ksp::oab module (https://kontrolsystem2.readthedocs.io/en/latest/reference/ksp/oab.html) to access the vessel parts in the VAB.

A little test script:

use { CONSOLE } from ksp::console
use { active_object_assembly_builder } from ksp::oab

pub fn main_editor() -> Result<Unit, string> = {
    CONSOLE.clear()

    const builder = active_object_assembly_builder()?

    CONSOLE.print_line(">>> " + builder.assemblies.length.to_string())
    const maybe_assembly = builder.main_assembly

    if(Some(assembly) = maybe_assembly) {
        for(part in assembly.parts) {
            CONSOLE.print_line(part.part_name + " " + part.relative_position.to_fixed(2))
        }
    } else {
        CONSOLE.print_line(">>> no main assembly")
    }
}

@PhilouDS
Copy link
Contributor Author

Thank you! This is already a good start, very promising!

@PhilouDS
Copy link
Contributor Author

PhilouDS commented Feb 29, 2024

Some examples of my UIs (the wrong stage info at the top is from MicroEngineer. The bottom UI is mine)

image

image

When I use WARP inside the VAB, at the end of the warp, the game automatically launches the craft. I don't know if it's a normal behaviour but it's handy :)

@untoldwind
Copy link
Owner

I have the feeling that this is not a desired behavior, considering that the time-control UI is hidden in the VAB view.
Maybe there is a way to have a clean put-vessel-to-launchpad-at-time helper.

Copy link

github-actions bot commented May 1, 2024

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

@github-actions github-actions bot added the stale Issue has not seen activity for 60 days label May 1, 2024
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested stale Issue has not seen activity for 60 days
Projects
None yet
Development

No branches or pull requests

2 participants