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

[QUESTION] Is there a way to set the starting DU for an engine config? #212

Closed
dgfl-gh opened this issue Sep 7, 2020 · 7 comments
Closed

Comments

@dgfl-gh
Copy link

dgfl-gh commented Sep 7, 2020

This isn't really an issue for TestFlight, it's actually an issue for me. I'm trying to add a way for my CustomScenarioManager mod to set the DU amount for an arbitrary config.
The idea is that you'd have a tfStartingDU field that you could populate with a comma-separated list of EngineConfig@DU. My mod would then check if TF is installed, find that engine config and set its DU amount so that the player will find that specific engine with the specified data amount.

My question therefore is: how do I do that? I read through TF's documentation and code, but it hasn't occurred to me exactly what would the outcome of that method be (check the "code" link), and how how I would call it from the KSC.

I preemptively ask for forgiveness if this is addressed 15 lines further than what I've linked, but I wasn't able to figure it out myself. @jwvanderbeck would you be available to give some directions?

@jwvanderbeck
Copy link
Collaborator

If I understand you properly, then I think you just want the ModifyFlightData method in the API?

@dgfl-gh
Copy link
Author

dgfl-gh commented Sep 8, 2020

Probably, as I said, but I don't understand why ApplyFlightDataMultiplier is the way it is nor how I would call the ModifyFlightData method for a config. It's a part module, how does that translate to a generalized per-config thing?

@jwvanderbeck
Copy link
Collaborator

I apologize for not taking the time to click on your link which showed you were already looking at that method.

In hindsight that probably won't work for what you want to do anyway because there are a lot of assumptions made about the context of that call. Plus, I think you just want to set a flat value not actually modify an existing value.

Ideally you really need to be interacting with the scenario store directly I think, though none of that is exposed if I recall correctly.

Would probably need to add a new method to the API class for this.

@jwvanderbeck
Copy link
Collaborator

jwvanderbeck commented Sep 8, 2020

Ultimately what you want to be hitting is this: https://github.com/KSP-RO/TestFlight/blob/master/TestFlightCore/TestFlightCore/TestFlight.cs#L1022

But I don't think that is currently accessible through reflection.

@dgfl-gh
Copy link
Author

dgfl-gh commented Sep 8, 2020

Yeah, that seems pretty much what I need. Would it be possible to expose it? I'd make a PR myself, but reflection makes my head spin every time I look at something beyond the basics. Is making the method static enough?

@jwvanderbeck
Copy link
Collaborator

jwvanderbeck commented Sep 10, 2020 via email

@dgfl-gh
Copy link
Author

dgfl-gh commented Sep 10, 2020

Can confirm that SetFlightDataForPartName was indeed the right method, and also that it can be called by reflection just fine. If you want to check out the reflection code, here it is: CustomScenarioManager/ModIntegration/TestFlight.cs

Closing since the feature works. Thanks for the help @jwvanderbeck!

@dgfl-gh dgfl-gh closed this as completed Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants