Jump to content

owensm0132

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by owensm0132

  1. ok, I figured it out. For other devs who feel like they are in the dark, looking at KAS plugin source code has really helped me. I am not sure if it is cool to add the link so I will not but it is on github. For my solution I used a static class to maintain state information. For the SendMessage it seems I had to send to the partmodule and not to the part - I am still not sure the difference between the two things (noob). public static class MO_Shared { public static ModuleDockingNode activeMOPort1 = null; public static ModuleDockingNode activeMOPort2 = null; public static List<Dockingv2> GetAllDockingv2sWithState(Vessel fromVessel = null, bool ActiveState = false) { ... } } ... public class Dockingv2 : ModuleDockingNode { ... [KSPEvent(guiActiveUnfocused = true, externalToEVAOnly = false, unfocusedRange = 20f, guiName = "Pair With This Port", active = false)] public void PairWithPort() { ... MO_Shared.activeMOPort1.SendMessage("LinkUp"); ... } }
  2. I have not tried it but the wiki has code for drawing lines (under the Visual Debugging) http://wiki.kerbalspaceprogram.com/wiki/Module_code_examples
  3. Again I am stumbling around in the dark not sure why this is not working. I am trying to activate a function in a partmodule in the active vessel from a near by vessel but it is not being activated - see code below; class mypart: PartModule { // Send Message [KSPEvent(guiActiveUnfocused = true, externalToEVAOnly = false, unfocusedRange = 20f, guiName = "Pair With This Port", active = false)] public void TestEvent() { BroadcastMessage("T1", this); SendMessage("T2", this); FlightGlobals.ActiveVessel.BroadcastMessage("T3", this); FlightGlobals.ActiveVessel.SendMessage("T4", this); FlightGlobals.ActiveVessel.rootPart.BroadcastMessage("T5", this); FlightGlobals.ActiveVessel.rootPart.SendMessage("T6", this); } // Send Messages [KSPEvent(guiActive = false, active = true)] public void T1(object Part) { ScreenMessages.PostScreenMessage("T1", 5.0f, ScreenMessageStyle.UPPER_CENTER); } [KSPEvent(guiActive = false, active = true)] public void T2(object Part) { ScreenMessages.PostScreenMessage("T2", 5.0f, ScreenMessageStyle.UPPER_CENTER); } [KSPEvent(guiActive = false, active = true)] public void T3(object Part) { ScreenMessages.PostScreenMessage("T3", 5.0f, ScreenMessageStyle.UPPER_CENTER); } [KSPEvent(guiActive = false, active = true)] public void T4(object Part) { ScreenMessages.PostScreenMessage("T4", 5.0f, ScreenMessageStyle.UPPER_CENTER); } [KSPEvent(guiActive = false, active = true)] public void T5(object Part) { ScreenMessages.PostScreenMessage("T5", 5.0f, ScreenMessageStyle.UPPER_CENTER); } [KSPEvent(guiActive = false, active = true)] public void T6(object Part) { ScreenMessages.PostScreenMessage("T6", 5.0f, ScreenMessageStyle.UPPER_CENTER); } } Notice that TestEvent is only being triggered from a nearby vessel. The only thing I get on the screen is T1 and T2. What am I doing wrong? Also, I was wondering if there is a way for a vessel to save some sort of custom meta data?
  4. I think I got it. I found ModuleDockingNode class! public class mydockingpart : ModuleDockingNode { ... } It works!!! It has all the default features of a docking port plus whatever I add to it! The following link was the clue for me; https://github.com/Anatid/XML-Documentation-for-the-KSP-API/blob/master/DockingPort.cs
  5. ok, I guess my question then is, how do I dock two ships so they become one in the code like the dockingport module already does. Or even better, how do add the the existing functionality of a dockingport? That is, if I implement PartModule I have to provide all the code to handle docking to ships together - I do not know the API required for that. Or, maybe I can just implement DockingPort?? But I tried this by associating with a cfg like you would for a PartModule but to now avail. I clearly am stumbling around in the dark.
  6. OK, I am a noob to ksp plugin development but not to c# or programming in general. I have read and searched many locations and even looked at other plugin's code. But nothing is clear enough to get me going in the right direction. Goal: I want to create a new docking port. Why- because I love the game and I love programming. I have tried the plugin from NavyFish but I want something a little different. It is just for my personal enjoyment. Progress: From what I understand, you can create a new kind of part by inheriting from the Parts class and (I guess) associating the code with a cfg via the module name parameter. I have not done this because I believe I what I need to do is modify the behavior of an existing part by inheriting from the PartModule class and associating that with a docking port cfg (via copy and past into new plugin folder and changing the name). I have tried this and it seems to not complain but the new part does not dock. I am not overriding anything except onAwake but even then I am just logging a string debug console and calling base.onAwake. Yes, I have followed the tutorial (http://wiki.kerbalspaceprogram.com/wiki/Creating_your_first_module) but these parts mods don't do anything like dock 2 ships together. Any help will be appreciated as I cannot find any reasonable collection of api documentation. Mark Owens
×
×
  • Create New...