Jump to content

fatcargo

Members
  • Posts

    393
  • Joined

  • Last visited

Everything posted by fatcargo

  1. More problems and ... more questions. I've discovered that i've made a mistake in above example code. The line with "new BaseAction(Actions,"name of action"" ... etc should have "name of action" string as valid identifier for C# and ConfigNode ie no whitespace whatsoever, no preceding numbers etc. This can be tested by writing a simple function with [KSPAction] attribute and then checking for it's name property as Debug.Log(Actions["YourActionFunction"].name) . "name" property will match the name used in array operator to reference this specific action. Not also that i have another roadblock. Again my example shows how to add runtime actions to config but that is also "static" as it ALWAYS adds those actions. While developing my plugin, i have managed to: -load and parse config with PartModule.OnStart() during editor scene -save config with my additional ConfigNode in PartModule.OnSave() in editor into craft file If i understand this correctly, when launching a craft from editor, PartModule.OnSave() is called three times : 1st for saving to craft file, 2nd to save with craft file with added "autosaved ship" string and 3rd time into persistence.sfs file. However, i did not managed to retain my custom ConfigNode while changing scenes from editor to flight (aka when launching a craft), it gets lost on scene change. How do i keep data i saved in craft file to transfer to persistence file (the above mentioned 3rd step) ?
  2. 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).
  3. 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).
  4. 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".
  5. 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.
  6. 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).
  7. 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.
  8. @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...
  9. 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.
  10. 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.
  11. 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 ?
  12. 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.
  13. 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.
  14. @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.
  15. 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.
  16. 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.
  17. Omnipius good one Aaand one more thing : @DMagic adding Experiment Storage Unit as Universal Storage part to would nicely complete the Orbital Science package . Pretty please ! With whipped cream and cherry on top
  18. Hi, just to chime in : please add "system check" to impact hammer so player can test for proper orientation and if possible stackable sensor pods. With stackable pods, player can use rover to seed the pods from single mount point (for planetary science, not much use for asteroids - unless someone mods 2.5km monstrosities - which now gave me the idea about Armageddon-style missions that require first scanning the asteroid, finding a weakspot and planting bd armory nukes - never leave train of thought running without proper supervision )
  19. @Diazo Of course ! Plugin is working great at this stage, no need to rush. And good luck with the move, be careful with overhang piano (can't help it with old cartoon references).
  20. And while i'm here, another two bug-like reports : 1. Very wide stock toolbar overlapped with stock action group display disables access to toolbar buttons. To elaborate : i have clicked AGX app button by accident, replacing AGX UI with stock. The stock action group UI is full height overlap of editor window, partically covering the stock toolbar. This causes user to loose access to those buttons. BUT, in case of AGX, this means that new UI won't be accessible once player switches to stock UI. Solutions : one is to manually edit plugin config to set editor = 1 and other is to bypass the problem entirely but installing Blizzy's toolbar and controlling AGX UI switch from there. 2. Editing text in AGX UI window that overlaps with staging column causes stage icons to hang, get stuck and persist on all screens (editor, space center, map, flight) during game session. To elaborate : - Drag AGX UI window titled "AGExt Selected parts : xxx" over staging column, making sure input textbox overlaps with staging icon - Click down and drag inside textbox with stage icon below. Underlying stage icon(s) will receive the mouse click - Move mouse to cause stage icon to move outside staging column -Release button and icon(s) will follow vertical mouse position -While icons are outside staging column, single mouse click will get them stuck in that position Stuck icons are visible in both editors, space center, tracking station and flight I also had inconsistent repeatibility of dragging staging icons and deleting them entirely. There was no way to restore icon (sans reloading the craft). Solution : restrict window positioning to exclude staging column.
  21. Sorry for not posting sooner. To clarify : move entire group. Example : First group named "engine cluster" for firing multiple types of engines (or special engine arrangements). Second group "reactors online" for switching nuclear cores. Third group "transfer boosters" for SRB cluster for interplanetary transfers. Player may define them in "wrong" order and needs to swap them after already placing all required actions into slots (between 1 and 250). Since all work is already done, re-doing all actions into correct slots again by hand should be avoided by using "move group" and "swap group". Thanks for the 1-5 visibility button explanation, i used this plugin for so long and never bothered to RTFM, sorry about that. I think this feature will indeed cover nearly all of the above problems.
  22. I apologize if i'm requesting an old feature, but here it goes : is it possible to add arrangement of action groups in editor/flight ? It may be needed when player defines one cluster of several actions and goes on the next one, but forgets to arrange them in order. Useful for crafts with complex functionality needing a lot of action groups, in those cases having logically arranged groups helps (for example action groups match staging or mission waypoints or ... you get the idea ) Arrangment operations could be : - move group (move to empty slot) - swap groups (exchange actions between slots) It can immensely speed up finalizing craft design process.
  23. Feature request : if possible, please add experiment repeatibility counter with manual reset marker in "here and now" experiment listing. This can help keep track of experiments that have limited collection capacity and need to be reset by scientist on EVA. Very useful for missions with many experiments attached to crafts, and player should be aware of some experiments needing a EVA reset.
  24. As is customary, first congratulations on a excellent plugin ! It saved me from spamming action group keys to collect science (and checking the biome in research window), it got tedious very fast. Now a report : i'm using Universal Storage science parts from DMagic Orbital Science pack. The "here and now" window detects available science from the above mentioned parts, but when executing offered experiments i get screen message "can't be done right now". Ofcourse, i again use action groups to collect science from all experiments at once and it works. Event this partial functioning still helps a great deal. I don't consider this issue a top priority, though it may point to some more serious issues "under the hood".
×
×
  • Create New...