[Enhancement Request] Default equipable parts or slot
GER-Space opened this issue ยท 3 comments
for a kOS handeld computer it would be really usefull when the part would be automatic equiped as soon as the kerbal goes on EVA. (without any keyboard input).
It might be a part setting (which could lead to race conditions) or a global setting, from which slot the part is taken.
As soon the part is spawned kOS can be made to take care of the rest.
Right now it looks like this:
- automatic lauch
- automatic select kerbal and start eva.
- manual activtion of the handheld kOS computer
- automatic perfoing of EVA tasks
- automatic boarding of vessel.
- automatic returning home.
point 3. is not exactly how it could be...
How about an API to KIS to have any item in the inventory equipped? There is no API at the moment but if there was one, would it be the solution? Kind of:
if (FlightGlobals.ActiveVessel.isEVA && KISAPI.isLoaded) {
var kis = FlightGlobals.ActiveVessel.rootPart.FindModuleImplementing<ModuleKISInventory>();
if (kis != null) {
var neededItem = kis.items.FirstOrDefault(x => x.name == "RequiredItemName");
if (neededItem != null) {
neededItem.Equip();
} else {
Debug.LogWarning("No needed item");
}
}
}
* this is not an actual code (yet)
The mods versioning bug may be an issue here but I'm currently working on a solution to workaround it.
Thank you.
With some minor modifications I was able to bind your code to the GameEvents.onVesselChange hook.
It only works, because the the active vessel is switched to the kerbal. (and every subsequent switching will also reequip the part)
Well, this code was actually just an idea :) It may work with the current KIS but due to the mentioned versioning bug your mod will get broken on every new KIS release :( The only way to avoid it for now is using reflections. To make this code safe KIS needs to be significantly changed (it's in the long term plans).