Search the Community

Showing results for tags 'additem'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Announcements
    • The Daily Kerbal
  • Kerbal Space Program 2
    • KSP 2 Discussion
  • General KSP
    • KSP Discussion
    • Suggestions & Development Discussion
    • Challenges & Mission ideas
    • The Spacecraft Exchange
    • KSP Fan Works
  • Gameplay and Technical Support
    • Gameplay Questions and Tutorials
    • Technical Support (PC, unmodded installs)
    • Technical Support (PC, modded installs)
    • Technical Support (PlayStation 4, XBox One)
  • Add-ons
    • Add-on Discussions
    • Add-on Releases
    • Add-on Development
  • Community
    • Welcome Aboard
    • Science & Spaceflight
    • Kerbal Network
    • The Lounge
  • Making History Expansion
    • Making History Missions
    • Making History Discussion
    • Making History Support
  • Breaking Ground Expansion
    • Breaking Ground Discussion
    • Breaking Ground Support
  • International
    • International
  • KerbalEDU Forums
    • KerbalEDU
    • KerbalEDU Website

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 1 result

  1. I am trying to add new functionality to my WalkAbout mod so that it will spawn kerbals with selected items already in their inventory. Currently, I am still in the proof-of-concept stage. The problem I am having is that I can't seem to get KIS to add an item to an inventory. Below is a snippet of the code I am using to test things out (the Debug() method is my extension method to write messages to the log file): if (inventory != null) { var items = WalkAboutPendingItems.InventoryItems[]; "performing getinfo on inventory".Debug(); var info = ModuleKISInventoryType.InvokeMember("GetInfo", System.Reflection.BindingFlags.InvokeMethod, null, inventory, new object[0]); $"obtained info from inventory [{info}]".Debug(); foreach (var itemName in items) { $"{} has a {itemName} to be added".Debug(); var defPart = PartLoader.getPartInfoByName(itemName); $"obtained part [{defPart}] for item [{itemName}]".Debug(); if (defPart != null) { $"invoking AddItem member using defPart [{defPart.GetType()}]".Debug(); ModuleKISInventoryType.InvokeMember("AddItem", System.Reflection.BindingFlags.InvokeMethod, null, inventory, new object[] { defPart }); $"If you can read this then ... hurray! It worked! {itemName} is in the inventory".Debug(); } else { "Cannot add item to inventory".Debug(); } } } And the resulting entries from the log file: [LOG 07:36:21.281] WalkAbout: performing getinfo on inventory [LOG 07:36:21.282] WalkAbout: obtained info from inventory [<b>Max Volume</b>: 300.00 L <b>Internal access</b>: ALLOWED <b>External access</b>: ALLOWED ] [LOG 07:36:21.283] WalkAbout: Jebediah Kerman has a KIS.wrench to be added [LOG 07:36:21.283] WalkAbout: obtained part [AvailablePart] for item [KIS.wrench] [LOG 07:36:21.284] WalkAbout: invoking AddItem member using defPart [AvailablePart] [EXC 07:36:21.287] MissingMethodException: The best match for method AddItem has some invalid parameter. System.MonoType.InvokeMember (System.String name, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object target, System.Object[] args, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParameters) System.Type.InvokeMember (System.String name, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object target, System.Object[] args) KspWalkAbout.WalkAboutEva.Start () As you can see, I have properly obtained the kerbal's ModuleKISInventory object and can query it for info by invoking "GetInfo". The call to invoke "AddItem" uses the same object and the only difference is that I am passing an AvailablePart object (just as is shown here). I just can't figure out where I've gone wrong. Any help would be appreciated.