Jump to content

Search the Community

Showing results for tags 'additem'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements
    • Welcome Aboard
  • Kerbal Space Program 2
    • KSP2 Dev Updates
    • KSP2 Discussion
    • KSP2 Suggestions and Development Discussion
    • Challenges & Mission Ideas
    • The KSP2 Spacecraft Exchange
    • Mission Reports
    • KSP2 Prelaunch Archive
  • Kerbal Space Program 2 Gameplay & Technical Support
    • KSP2 Gameplay Questions and Tutorials
    • KSP2 Technical Support (PC, unmodded installs)
    • KSP2 Technical Support (PC, modded installs)
  • Kerbal Space Program 2 Mods
    • KSP2 Mod Discussions
    • KSP2 Mod Releases
    • KSP2 Mod Development
  • Kerbal Space Program 1
    • KSP1 The Daily Kerbal
    • KSP1 Discussion
    • KSP1 Suggestions & Development Discussion
    • KSP1 Challenges & Mission ideas
    • KSP1 The Spacecraft Exchange
    • KSP1 Mission Reports
    • KSP1 Gameplay and Technical Support
    • KSP1 Mods
    • KSP1 Expansions
  • Community
    • Science & Spaceflight
    • Kerbal Network
    • The Lounge
    • KSP Fan Works
  • International
    • International
  • KerbalEDU
    • KerbalEDU
    • KerbalEDU Website

Categories

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Skype


Twitter


About me


Location


Interests

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[kerbal.name]; "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) { $"{kerbal.name} 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.
×
×
  • Create New...