Electr0ninja Posted September 30, 2016 Share Posted September 30, 2016 (edited) Does anyone know how to get the in-editor call back functions to fire, like void OnEditorAttach() ? Mono claims there is a link, but it doesn't seem to do anything. I am just try to write a debug string to the debug console for testing. nvm figured it out, now I am working on getting isMirrored to give me a valid result. hmm, is seems that ismirrored is set after attachment, that is not so useful. Edited September 30, 2016 by Electr0ninja Quote Link to comment Share on other sites More sharing options...
Papa_Joe Posted September 30, 2016 Share Posted September 30, 2016 23 hours ago, enneract said: I'm trying to create a vessel on the launchpad from the spacecenter or editor scenes. I think I'm on the right track with ShipConstruction.PutShipToGround, but I'm having trouble locating the correct Transform for the second argument. The following Gist demonstrates the issue; has anyone else tried doing something like this or run into a similar problem?Gist I can do it from flight... Vessel mover does something like this. Take a look if that might help. Quote Link to comment Share on other sites More sharing options...
Electr0ninja Posted September 30, 2016 Share Posted September 30, 2016 The isMirrored member doesn't do anything in the editor currently, may be a bug idk, but I even set up a 1 second time delay thread so I could check the value after the OnEditorAttach() function was done. And nothing, it seems that the isMirrored member may never actually get set at all. Might just be dead code. Quote Link to comment Share on other sites More sharing options...
haselnuss Posted October 1, 2016 Share Posted October 1, 2016 And the next problem, I can't solve myself. I want to run some code, if KSP or the user adds, modifies or removes stages in the VAB. What I found is the class GameEvents.StageManager. This class contains the following functions: GameEvents.StageManager.OnStageAdded GameEvents.StageManager.OnStageRemoved GameEvents.StageManager.OnStageSequenceModified Are this the functions I am looking for? How do I use them? The code below is not working and I do not understand the error message, my IDE shows me. void Awake() { GameEvents.StageManager.OnStageAdded(eventStageAdded); } private void eventStageAdded() { //do something } Quote Link to comment Share on other sites More sharing options...
katateochi Posted October 2, 2016 Share Posted October 2, 2016 7 hours ago, haselnuss said: How do I use them? The code below is not working and I do not understand the error message, my IDE shows me. You need to call .Add() and pass your delegate to that, and then work out what parameters the delegate expects to be passed (I just define the delegate with no params and then see what error it throws, in this case it wanted an int). void Awake() { GameEvents.StageManager.OnGUIStageAdded.Add (eventStageAdded); } private void eventStageAdded(int e) { //do something } (also check out .Remove() to unbind your listener) Quote Link to comment Share on other sites More sharing options...
enneract Posted October 2, 2016 Share Posted October 2, 2016 On 9/30/2016 at 1:19 PM, Papa_Joe said: I can do it from flight... Vessel mover does something like this. Take a look if that might help. I'm specifically need to avoid going to flight to do this. :/ If I have to do it in flight, I need to figure out how to fake the icon on the launchpad indicating a craft ready to launch. Quote Link to comment Share on other sites More sharing options...
Papa_Joe Posted October 2, 2016 Share Posted October 2, 2016 8 hours ago, enneract said: I'm specifically need to avoid going to flight to do this. :/ If I have to do it in flight, I need to figure out how to fake the icon on the launchpad indicating a craft ready to launch. No problem. I did not fully understand your use case Quote Link to comment Share on other sites More sharing options...
Anase Skyrider Posted October 3, 2016 Share Posted October 3, 2016 I'm making a program in Visual Studio using C#. I need to be able to export the source code as per the rules of the forum. Can anyone help me? Quote Link to comment Share on other sites More sharing options...
blowfish Posted October 3, 2016 Share Posted October 3, 2016 1 hour ago, Anase Skyrider said: I'm making a program in Visual Studio using C#. I need to be able to export the source code as per the rules of the forum. Can anyone help me? Simplest way is to just include the entire project folder in the download (or as a separate download). Quote Link to comment Share on other sites More sharing options...
Anase Skyrider Posted October 4, 2016 Share Posted October 4, 2016 4 hours ago, blowfish said: Simplest way is to just include the entire project folder in the download (or as a separate download). If that's the simplest way, then what are the other ways? Quote Link to comment Share on other sites More sharing options...
blowfish Posted October 4, 2016 Share Posted October 4, 2016 16 minutes ago, Anase Skyrider said: If that's the simplest way, then what are the other ways? Many plugin developers post their code on Github, which is great but git itself has quite a learning curve. Quote Link to comment Share on other sites More sharing options...
Anase Skyrider Posted October 4, 2016 Share Posted October 4, 2016 Just now, blowfish said: Many plugin developers post their code on Github, which is great but git itself has quite a learning curve. I didn't mean places to put the code, but rather, ways of exporting the code. Were you suggesting that I put the project files on Github? Quote Link to comment Share on other sites More sharing options...
blowfish Posted October 4, 2016 Share Posted October 4, 2016 28 minutes ago, Anase Skyrider said: I didn't mean places to put the code, but rather, ways of exporting the code. Were you suggesting that I put the project files on Github? All the source code files are in the project directory. The Visual Studio project just knows about all the files and how to compile them. Quote Link to comment Share on other sites More sharing options...
Rodhern Posted October 4, 2016 Share Posted October 4, 2016 How to use USI and Scansat modules for contracts Suppose that a player uses the USI MKS/OKS and Scansat mods. Let us say KSP version 1.2, in case Kerbnet is relevant for any of my questions. I would like to program a mission/contract that determines that the player has detected, say, a large patch of "Substrate" on Kerbin, or Eve for that matter. Then the goal of the contract is to build a small outpost in the vicinity. Are there any good tutorials for mod interoperation? If not, can you give short answers to these questions: 1) If the player uses USI MKS/OKS and Scansat, there will be "Substrate" in the player's game, right? 2) How do I refer to/manipulate the community resource "Substrate"? Maybe via Kerbnet? 3) Can I determine which patches of "Substrate" the player has discovered? 4) If my plugin mission refers to (USI) "Substrate" and the quantities discovered (Scansat), how will the license terms of either USI MKS/OKS or "community resource pack" influence my license selection possibilities? (Scansat is straight forward; attribution where it is due) 5) If the answer to "4)" is that I can make an all rights reserved license, is it a nice thing to do, or is it frowned upon, given that the inspiration source is 'creative commons' protected? Quote Link to comment Share on other sites More sharing options...
katateochi Posted October 4, 2016 Share Posted October 4, 2016 (edited) I've got something odd with the process of adding a button to the toolbar. I'd been working against pre-release build 1473 and it was working as expected, but I've just moved up to 1564 and am now getting odd behaviour. I've got 2 toolbar buttons; One is set to appear in the VAB/SPH with the 7th arg to AddModApplication() being given as; ApplicationLauncher.AppScenes.VAB | ApplicationLauncher.AppScenes.SPH, That one works as expected, button only shows up in the editors. The other button which should just appear in the space center scene has it's 7th arg given as just ApplicationLauncher.AppScenes.SPACECENTER but it is being shown in the spacecenter, both editors and in flight. The really odd thing is that if I change it to have ApplicationLauncher.AppScenes.SPACECENTER | ApplicationLauncher.AppScenes.VAB | ApplicationLauncher.AppScenes.SPH, The it stops showing up in flight (but obv appears in the editors, which I don't want). I'm either doing something daft or maybe there's an issue with 1564 and the toolbar? Can anyone confirm? Edited October 4, 2016 by katateochi Quote Link to comment Share on other sites More sharing options...
JPLRepo Posted October 4, 2016 Share Posted October 4, 2016 1 hour ago, katateochi said: I've got something odd with the process of adding a button to the toolbar. I'd been working against pre-release build 1473 and it was working as expected, but I've just moved up to 1564 and am now getting odd behaviour. I've got 2 toolbar buttons; One is set to appear in the VAB/SPH with the 7th arg to AddModApplication() being given as; ApplicationLauncher.AppScenes.VAB | ApplicationLauncher.AppScenes.SPH, That one works as expected, button only shows up in the editors. The other button which should just appear in the space center scene has it's 7th arg given as just ApplicationLauncher.AppScenes.SPACECENTER but it is being shown in the spacecenter, both editors and in flight. The really odd thing is that if I change it to have ApplicationLauncher.AppScenes.SPACECENTER | ApplicationLauncher.AppScenes.VAB | ApplicationLauncher.AppScenes.SPH, The it stops showing up in flight (but obv appears in the editors, which I don't want). I'm either doing something daft or maybe there's an issue with 1564 and the toolbar? Can anyone confirm? I'm having no issues with AppLauncher. perhaps if you supply a link to your code and have you checked your log for errors? Quote Link to comment Share on other sites More sharing options...
katateochi Posted October 5, 2016 Share Posted October 5, 2016 21 hours ago, JPLRepo said: I'm having no issues with AppLauncher. perhaps if you supply a link to your code and have you checked your log for errors? I'm not getting any errors in the logs. I made a stripped down version of my toolbar initializer code to test and I'm getting the same odd things happening. I've put that code in a gist here https://gist.github.com/Sujimichi/23cf077d89bc15acdc3c889cd39ac638 With that setup, when I first get to the space center both buttons are shown (expected: just button 2). Then when I go into the VAB just button 1 is shown (as expected). Then when going to launch button 2 shows up again (expected: no buttons). Then when I revert to the VAB both buttons are shown (expected: just button 1), then when going back to the space center from there just button 2 is shown (as expected). Then!! going back to the main menu, button 1 shows up! (not at all expected!). And then finally when re-loading the save and going back to the space center, both buttons are shown twice. Can't see anywhere in the logs showing the call to remove the buttons. I'm clearly doing something spectacularly wrong here! Halp requested! Quote Link to comment Share on other sites More sharing options...
DMagic Posted October 6, 2016 Share Posted October 6, 2016 I'm wondering if anyone can tell me what Orbit.ObT does, and if and how it relates to Orbit.getObtAtUT and/or Orbit.getPositionAtUT. According to the docs Orbit.Obt is "time on this orbit (since periapsis)." But I'm not really clear on how that relates to the other two functions. SCANsat has a check in its background scanning method for a negative Orbit.Obt: if (o.ObT <= 0) goto dequeue; It basically short-circuits the background scanning for a vessel. In 1.2 SCANsat was having some spotty results when scanning at even moderate timewarp, around 100 - 1000X. I can "fix" the problem by removing this check, vessels were periodically ending the loop this way during part of their orbit, but I'm assuming this check was in there for a reason (I've always been wary of touching the background scanning mechanism as I don't really understand how it works ). Quote Link to comment Share on other sites More sharing options...
JPLRepo Posted October 8, 2016 Share Posted October 8, 2016 On 06/10/2016 at 3:20 AM, katateochi said: I'm not getting any errors in the logs. I made a stripped down version of my toolbar initializer code to test and I'm getting the same odd things happening. I've put that code in a gist here https://gist.github.com/Sujimichi/23cf077d89bc15acdc3c889cd39ac638 With that setup, when I first get to the space center both buttons are shown (expected: just button 2). Then when I go into the VAB just button 1 is shown (as expected). Then when going to launch button 2 shows up again (expected: no buttons). Then when I revert to the VAB both buttons are shown (expected: just button 1), then when going back to the space center from there just button 2 is shown (as expected). Then!! going back to the main menu, button 1 shows up! (not at all expected!). And then finally when re-loading the save and going back to the space center, both buttons are shown twice. Can't see anywhere in the logs showing the call to remove the buttons. I'm clearly doing something spectacularly wrong here! Halp requested! Sorry ran out of time to look at your code. But have you looked at this guide? Quote Link to comment Share on other sites More sharing options...
taniwha Posted October 8, 2016 Share Posted October 8, 2016 On 07/10/2016 at 1:35 AM, DMagic said: In 1.2 SCANsat was having some spotty results when scanning at even moderate timewarp, around 100 - 1000X. I can "fix" the problem by removing this check, vessels were periodically ending the loop this way during part of their orbit, but I'm assuming this check was in there for a reason (I've always been wary of touching the background scanning mechanism as I don't really understand how it works ). I changed all the parameters for Orbit to be -X..X instead of 0..2X (X may be pi or period/2) for consistency and slightly (1 bit) better precision. In the past, ObT was always 0..period for elliptical orbits (and -Inf..Inf for hyperbolic trajectories), but now ObT is -period/2..period/2 (meanAnomaly, eccentricAnomaly and trueAnomaly are now -pi..pi instead of 0..2pi). ObT is indeed time since periapsis, so -ObT -> -since = until. I don't know if it is of interest to you, but there is now also meanMotion: the "velocity" of meanAnomaly (meanAnomaly = meanMotion * ObT), which holds for all orbit types. I hope that helps. (btw, the change is mentioned in the changelog) Quote Link to comment Share on other sites More sharing options...
Crzyrndm Posted October 13, 2016 Share Posted October 13, 2016 (edited) With the integrated settings using GameParameters.CustomParameterNode, is there any way to refresh an IList parameter? (I want to use the value of one setting to restrict the list values) Edited October 13, 2016 by Crzyrndm Quote Link to comment Share on other sites More sharing options...
nightingale Posted October 13, 2016 Share Posted October 13, 2016 2 hours ago, Crzyrndm said: With the integrated settings using GameParameters.CustomParameterNode, is there any way to refresh an IList parameter? (I want to use the value of one setting to restrict the list values) No, the ValidValues method is only called when the UI is built. The closest you can come (short of hacking the unity objects) is to enable/disable fields dynamically. Quote Link to comment Share on other sites More sharing options...
katateochi Posted October 13, 2016 Share Posted October 13, 2016 On 08/10/2016 at 11:35 AM, JPLRepo said: Sorry ran out of time to look at your code. But have you looked at this guide? I had been following that guide and it talks about GameEvents.onGUIApplicationLauncherReady and GameEvents.onGUIApplicationLauncherDestroyed as events to listen to to bind methods to add and remove the buttons. So I'd subscribed to those events but what I was seeing was the Ready event was being fired on every scene change but I wasn't seeing the Destroy event fire at all. I then looked at some other mods (KerbalAlarmClock in particular, thanks @TriggerAu) and saw the use of onGameSceneLoadRequested as an event to bind the removal of buttons to. So I added that Event and set the same button removal method as the Destroy Event would call to it and presto, everything is working as expected. So that seems to be sorted! I have another Q, and sorry for re-asking it, but; how can I check if a craft in the editor has unsaved changes? (the hacky solution I mentioned before is unreliable, as expected with hacky solutions!) Quote Link to comment Share on other sites More sharing options...
DMagic Posted October 13, 2016 Share Posted October 13, 2016 I always use onGUIApplicationLauncherUnreadifying to trigger removal of the button. It seems to work well enough. Quote Link to comment Share on other sites More sharing options...
katateochi Posted October 14, 2016 Share Posted October 14, 2016 7 hours ago, DMagic said: I always use onGUIApplicationLauncherUnreadifying to trigger removal of the button. It seems to work well enough. Do you make any use of onGUIApplicationLauncherDestroyed as well? I can't see it being called at any point. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.