• Content count

  • Joined

  • Last visited

Community Reputation

13 Good

About fatcargo

  • Rank
    Spacecraft Engineer
  1. WOOHOO ! I found a way for a runtime added action group to persist from editor to vessel launch !!! And AGX recognizes it, no NREs !!! Here is what i've done. public override void OnSave (ConfigNode node) { node.AddNode("ACTIONS").AddNode("base action name 1").AddValue("actionGroup","None"); } public override void OnStart (StartState state) { if (HighLogic.LoadedSceneIsEditor) SingleRuntimeAction(); } public override void OnLoad (ConfigNode node) { if (!HighLogic.LoadedSceneIsEditor) SingleRuntimeAction(); } public void SingleRuntimeAction() { KSPAction ksp_action = new KSPAction("AG test 1", KSPActionGroup.None, false, false); BaseAction base_action = new BaseAction(Actions,"base action name 1", (a) => { ScreenMessages.PostScreenMessage("test 1"); }, ksp_action); Actions.Add(base_action); } After inserting this in your PartModule, add this group (it's name is displayed in action group editor as "AG test 1") to custom group 1, launch vessel and then activate action group. Watch screen message appear. Note how "base action name 1" is defined in BaseAction class and later added in config node. BEFORE the above test, i had also written two functions with KSPAction[] attributes BuiltInAction() and BuiltInAction2(). This is what config node contained during OnSave() : {MODULE { stagingEnabled = True isEnabled = True name = TestPartModule EVENTS { } ACTIONS { BuiltInAction { actionGroup = None } BuiltInAction2 { actionGroup = None } } } } During OnLoad() vessel's config node has simiar (if not exactly the same) content. Above config node sample shows also EVENTS{}, but currently i'm not interested in these. If the above test proves stable (though everything seems straightforward), this should add one more configuration option in my part module i'm developing. For me, this would be next to impossible to discover without excellent guide about debugging with VS/MonoDevelop by @sarbian . Note that the above works with Xamarin Studio Community Edition (i've got it by trying to download MonoDevelop, links there are replaced with Xamarin Studio CE). Also a great help is Action Group Extended by @Diazo which i used to visualize and test action groups (if i didn't do something right, AGX would start throwing NREs, even before i tinkered with action groups).
  2. Have a look at RoverDude's Konstruction. It has a weldable docking port, which should provide a code basis. You should name them "weldable struts" (now when i think about it more, there is a whole slew of parts that can be permanently welded, though KAS already solved most of it).
  3. Well, yes that is what what i'm going to do, i just wondered about shorter, more direct approach. I guess we could call this one "solved".
  4. One last ditch effort. I can add and remove actions groups in runtime in my PartModule plugin, but they can't persist from editor to flight (probably also on vessel load/spawn), so i gave up on that front. To elaborate : i've tried with Action Groups Extended by @Diazo to have a look into mechanics of action groups in flight scene, and while i can add actions on the fly and use them, KSP "forgets" them from SPH/VAB to vessel launch. Next, i've discovered by "type - compile - run - duck and cover" testing i can add multiple [KSPAction("somename"]) above a single function and have fully working multiple actions that persist from editor to flight scenes ! What bugs me is that i can't find out WHICH KSPAction attribute fired the function, there is no apparent link to trace back to corresponding action. Sigh... Example: [KSPAction("action one")] [KSPAction("action two")] [KSPAction("action three")] public void DoSomething(KSPAction param) { // ...stuff.. note that received "param" has only [float] Cooldown, [KSPActionGroup] group and [KSPActiontype] type, no backtracking from this } If there is a way to determine a calling action, this could save some space and simplify code. As one can guess from the above, i really would like to save up on repeating the same blocks of code (i need a lot of them for my plugin). This is me more sharing this discovery rather than me following up on this, i'll take the usual one-attribute-one-function route until this is resolved either as a failure or a success.
  5. Why not try Xamarin Studio Community ? It supports C# 6.0. I got it from this DL link for Monodevelop. Straightforward click and download. After some tweaks its has 90% of VS functionality. My concern was VS-like code navigation, though i didn't quite nailed it with indentation (but i do very much like what they've done with visual feedback in editor preferences).
  6. Wow i found a fully working example that enables my plugin to load config from any folder, it is a direct copy/paste into test project in VS. I can now load required config data into plugin inside editor from relevant part config.
  7. @wasml Thanks for the info, will look into it. If i ever intend to continue writing plugins, debugging will be unavoidable. One other thing : Does this in-game-debug enable me to explore data structures ? Like for example how does API "see" my config nodes in part cfg, when i traverse all ConfigNode items in VS ? @ALL thanks for the insights, because of your effort i have realized that PartModules are designed to have static data structures, some flexibility is possible in flight scenes. So, the module that i write is not purely a PartModule, or more accurately, it needs more than PartModule can offer on it's own. So, i further researched the subject and came up with my working solution for loading part config in editor. My module needs to configure itself from part config in flight and editor scenes. Below is example code, a promising start. ConfigNode rootNode = ConfigNode.Load(KSPUtil.ApplicationRootPath + "GameData/0000_MyMods/mypart.cfg"); ConfigNode moduleNode = GetNode("PART").GetNodes("MODULE").Where(m => m.name == "YourModuleClassName").Single().GetNodes(); I can put this in OnStart() and have my config available in editor. Drawback is that i don't know how to obtain my module DLL path from part config is was called from and then use that to build a full path. As it is now, path is hard-coded into plugin, if i can just somehow obtain assembly path it could make my plugin more portable...
  8. Here is the project file with compiled DLL in debug mode. Please review at your leisure. Thanks in advance ! NOTE: I'm on win 7 x64, KSP 1.2.2, VS 2015 CE update 3. Performed one VS installation repair.
  9. I did a similar test in Unity3D (attached a script to camera, filled a text mesh with output) and let it run. It worked from start.
  10. In the meantime i've changed struct to class and same thing happened. I know c# has garbage collector that frees unused stuff from memory as soon as all references are gone (included leaving method's scope). But keeping a reference inside a List should keep GC from freeing it. I'm just reusing the same variable to point to newly created item to be added into List, this shouldn't be the problem ?
  11. Firstly, thanks to all for replies ! Secondly, i forgot to mention that example plugin was tested in SPH editor scene and OnLoad() does get called properly, every time. What i don't understand, is that my list simply does not "carry over" to OnStartFinished(), as if it was never called. Simply all references inside List were lost, wiped clean. Any attempt to use complex type (class, struct, list, dictionary) fails to retain reference outside calling method. Calling GC.KeepAlive() on my list and its newly added item at end of OnLoad() also failed. I tried searching on net but no such problems were mentioned (i find most solutions over at stackexchange). The above example source is what i have compiled into DLL, copied into subfolder in GameData and referenced it in part cfg via MODULE{} node. I did look at plugin sources at github and pretty much everywhere List is normally used from OnLoad(), nothing unusual. I'm starting to believe something is wrong with my VS 2015 CE install.
  12. I've got serious problem with using a List / Dictionary collection classes where adding data in one event does not propagate to other event. Code example: using System; using System.Collections.Generic; using System.Linq; using System.Text; using UnityEngine; namespace TestPartPlugin { public class TestPartPlugin : PartModule { public struct teststruct { public string s; public int i; } public class testclass { public string s; public int i; } // this is shared among events, it will be passed as argument, for purposes of this example its not a problem ? public List<teststruct> l = new List<teststruct>(); public string ss; public override void OnLoad(ConfigNode node) { base.OnLoad(node); ss = new string('x', 10); // just allocate in runtime and fill it with dummy data, for reference to the problem at hand teststruct t; //now the interesting part for (int i = 0; i < 10; i++) { t = new teststruct(); //also did same with testclass, same problem t.s = "a"; //dummy fill t.i = i; l.Add(t); //add new item. if i looped in collection inside here, it would work } } public override void OnStartFinished(StartState state) // now the troublesome part { base.OnStartFinished(state); Debug.Log("LIST DUMP START"); foreach (teststruct t in l) Debug.Log("string: " + t.s + " int: " + t.i.ToString()); // BANG ! List/struct is empty ! Debug.Log("LIST DUMP END"); Debug.Log("simple string test: " + ss); //this worked, meh ... } } } I need a mutable collection that will be filled in OnLoad() and then later being used in OnStartFinished() . Right now, when i fill data in OnLoad(), inside OnStartFinished() my collection will be empty, no data is present. What now ? would using "out" keyword in method argument work ? I tried "ref" also with no result.
  13. @Diazo Yes that was my idea as well, move grouped actions among keybindings, keybinds are left in fixed order. But do keep in mind that swapping may be useful, if not the only reason for coding such functionality, in my humble opinion.
  14. I too have seen the same problem, and i've posted this issue at the [x] science thread. When used with action groups, all Universal Storage science parts do execute properly. Author of [x] science admits there is more work to be done on his addon. Now when i think of it some more, there is no "failure log" where player can review all science experiments that didn't deploy due to some condition not being met, an alternative to speed-reading failure messages spam on screen.
  15. Just to report i've opened new issue on GH about an old issue (i apologize for the pun, couldn't help it ) Its about a bug that prevents runway launches if airbags are mounted of craft.