Stoney3K Posted October 21, 2015 Share Posted October 21, 2015 Is it currently possible to reload or modify the current solar system in-game?My idea is to write a plug-in that, when a player triggers a certain object in space, unloads (and saves) the entire solar system and loads a new one in its place. The player ship de-spawns and re-spawns in the newly loaded solar system in a predefined orbit.However, that depends on whether it is possible to modify orbital objects "on rails" at run time. The loading does not have to be instantaneous and physics do not have to simulate. Quote Link to comment Share on other sites More sharing options...
legacynl Posted October 27, 2015 Share Posted October 27, 2015 So I was wondering, what is the 'proper' way to detect another mods presence? For example, I want to make a plugin that does RemoteTech stuff, but only if remotetech is installed. I have been searching this forum, but the search on here isn't exactly that helpful. Quote Link to comment Share on other sites More sharing options...
blowfish Posted October 27, 2015 Share Posted October 27, 2015 So I was wondering, what is the 'proper' way to detect another mods presence? For example, I want to make a plugin that does RemoteTech stuff, but only if remotetech is installed. I have been searching this forum, but the search on here isn't exactly that helpful.You could try something like this. Essentially you iterate through loaded assemblies until you find the one you're looking for. Quote Link to comment Share on other sites More sharing options...
Diazo Posted October 27, 2015 Share Posted October 27, 2015 (edited) If you just want to check if another mod is installed, blowfish's method is the way to go. RT's assembly name is: if (Asm.dllName == "RemoteTech") (I actually check for RT in one of my own mods exactly like this.)If you are trying to call a command in another mod, you can also do it this way:The following code tries to execute the AGXInstalled method (which is static) from the AGExtExternal class in the ActionGroupsExtended namespace. If it is present it returns the bool from the method (in this case true as this is simply a check to see if AGX is present). If the mod is not present, it hits the catch block where you run the code you want to if the mod is not present (in this case false to indicate AGX is not present).public static bool AGExtInstalled() { try //try-catch is required as the below code returns a NullRef if AGX is not present.{Type calledType = Type.GetType("ActionGroupsExtended.AGExtExternal, AGExt"); return (bool)calledType.InvokeMember("AGXInstalled", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static, null, null, null);}catch{return false;} }D. Edited October 27, 2015 by Diazo Quote Link to comment Share on other sites More sharing options...
Padishar Posted October 27, 2015 Share Posted October 27, 2015 I would avoid the try/catch there and just test the Type reference returned for null. Much cleaner looking code than the exception handling and it will be (very slightly) faster too if this happens to be called a lot. Quote Link to comment Share on other sites More sharing options...
Diazo Posted October 27, 2015 Share Posted October 27, 2015 Have a documentation link for that? Not something I've heard of.D. Quote Link to comment Share on other sites More sharing options...
sarbian Posted October 27, 2015 Share Posted October 27, 2015 Catching an Exception is by design slower since it involve the creation of the Exception object and walking thru the heap to find where/if something catch it. Exception should be avoided in a "normal" flow if performance is key. For a single test like that it would not matter much but I would side with Padishar for a null testing anyway. Quote Link to comment Share on other sites More sharing options...
KaptainKrunch Posted October 28, 2015 Share Posted October 28, 2015 Documentation for creating contracts?I'm interested in starting small by creating a collection of contracts, but having looked through the various development postings here I don't see anything that talks about it. Can I get a pointer to documentation, tutorials, or anything else that would help with that? Thanks. Quote Link to comment Share on other sites More sharing options...
JPLRepo Posted October 28, 2015 Share Posted October 28, 2015 Documentation for creating contracts?I'm interested in starting small by creating a collection of contracts, but having looked through the various development postings here I don't see anything that talks about it. Can I get a pointer to documentation, tutorials, or anything else that would help with that? Thanks.http://forum.kerbalspaceprogram.com/threads/86588-Contract-Modding-Information-for-Mod-Authors Quote Link to comment Share on other sites More sharing options...
hab136 Posted November 1, 2015 Share Posted November 1, 2015 Is it currently possible to reload or modify the current solar system in-game?My idea is to write a plug-in that, when a player triggers a certain object in space, unloads (and saves) the entire solar system and loads a new one in its place. The player ship de-spawns and re-spawns in the newly loaded solar system in a predefined orbit.However, that depends on whether it is possible to modify orbital objects "on rails" at run time. The loading does not have to be instantaneous and physics do not have to simulate.Do you want to change the planets, ships, or both?Kerbal Warp Drive changes the planets while the game is loaded. Ships remain in the same orbit around their parent body.Modifying on-rails ships is also possible; Orbit Decay Lite does this.I don't know how either one works, but you can ask in the threads and/or look at the source. Quote Link to comment Share on other sites More sharing options...
Kalzuron Posted November 2, 2015 Share Posted November 2, 2015 Hopefully someone can point me in the right direction. Is it possible to find the footprint of a ship? I want to use a variable offset and I'm going to use the center of mass of the ship (or the center of my part) as a min and the radius of the ship as the max. I haven't started yet, just curious if anyone knows if its possible before I head down a road that could lead nowhere. Quote Link to comment Share on other sites More sharing options...
SlimJim Posted November 2, 2015 Share Posted November 2, 2015 Hey guys, I'm currently trying to create a contract where I need to specify the Mun as the targetBody. Anyone got a good idea on how to explicitly do that? Most examples I've found randonmly generates a target body depending on celestial progression. Quote Link to comment Share on other sites More sharing options...
sarbian Posted November 2, 2015 Share Posted November 2, 2015 (edited) It depends how precise you want to be. The fast version is more or less that. The slow one would go thru all the vertex of each parts.This code does not compute the distance to the CoM but it is an easy change.Edit : bonus code to draw it (with some MJ call you can find in the same file). I should rewrite some of this... Edited November 2, 2015 by sarbian Quote Link to comment Share on other sites More sharing options...
Kalzuron Posted November 2, 2015 Share Posted November 2, 2015 Sweet, thank you. That's amazingly helpful for when I start on the plug-in aspect of my project Quote Link to comment Share on other sites More sharing options...
Stoney3K Posted November 8, 2015 Share Posted November 8, 2015 Do you want to change the planets, ships, or both?Kerbal Warp Drive changes the planets while the game is loaded. Ships remain in the same orbit around their parent body.Modifying on-rails ships is also possible; Orbit Decay Lite does this.I don't know how either one works, but you can ask in the threads and/or look at the source.Thanks, I think I can start from there, that looks like the goal I was trying to accomplish (albeit through a separate object).My idea is to create a Mass Effect-style relay in high solar orbit that the player can discover and travel to other planets (and back). Quote Link to comment Share on other sites More sharing options...
legacynl Posted November 9, 2015 Share Posted November 9, 2015 If you just want to check if another mod is installed, blowfish's method is the way to go. RT's assembly name is: if (Asm.dllName == "RemoteTech") (I actually check for RT in one of my own mods exactly like this.)If you are trying to call a command in another mod, you can also do it this way:The following code tries to execute the AGXInstalled method (which is static) from the AGExtExternal class in the ActionGroupsExtended namespace. If it is present it returns the bool from the method (in this case true as this is simply a check to see if AGX is present). If the mod is not present, it hits the catch block where you run the code you want to if the mod is not present (in this case false to indicate AGX is not present).public static bool AGExtInstalled() { try //try-catch is required as the below code returns a NullRef if AGX is not present.{Type calledType = Type.GetType("ActionGroupsExtended.AGExtExternal, AGExt"); return (bool)calledType.InvokeMember("AGXInstalled", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static, null, null, null);}catch{return false;} }D.You're right that i'm trying to invoke a method in the remotetech api. For starters I first want to have it write the RT api's methods to the debuglog. I'm rather confused however. If I try to run the code below, it tells me that RTType is null, and indeed if I try RTType.GetMethods() I get a NullReferenceException.[FONT=Monospace][COLOR=#009695]if[/COLOR][COLOR=#333333]([/COLOR][COLOR=#333333]RTLoaded[/COLOR][COLOR=#333333])[/COLOR][COLOR=#333333]{[/COLOR] [COLOR=#3364a4]Debug[/COLOR][COLOR=#333333].[/COLOR][COLOR=#333333]Log[/COLOR][COLOR=#333333]([/COLOR][COLOR=#f57d00]"[/COLOR][COLOR=#f57d00]RT[/COLOR][COLOR=#f57d00] is [/COLOR][COLOR=#f57d00]loaded[/COLOR][COLOR=#f57d00]![/COLOR][COLOR=#f57d00]"[/COLOR][COLOR=#333333])[/COLOR][COLOR=#333333];[/COLOR] [COLOR=#3364a4]Type [/COLOR][COLOR=#333333]RTType [/COLOR][COLOR=#333333]= [/COLOR][COLOR=#3364a4]Type[/COLOR][COLOR=#333333].[/COLOR][COLOR=#333333]GetType[/COLOR][COLOR=#333333]([/COLOR][COLOR=#f57d00]"[/COLOR][COLOR=#f57d00]RemoteTech[/COLOR][COLOR=#f57d00].[/COLOR][COLOR=#f57d00]API[/COLOR][COLOR=#f57d00].[/COLOR][COLOR=#f57d00]API[/COLOR][COLOR=#f57d00]"[/COLOR][COLOR=#333333])[/COLOR][COLOR=#333333];[/COLOR] [COLOR=#009695]if[/COLOR][COLOR=#333333]([/COLOR][COLOR=#333333]RTType [/COLOR][COLOR=#333333]==[/COLOR][COLOR=#009695] null[/COLOR][COLOR=#333333])[/COLOR] [COLOR=#3364a4]Debug[/COLOR][COLOR=#333333].[/COLOR][COLOR=#333333]Log[/COLOR][COLOR=#333333]([/COLOR][COLOR=#f57d00]"[/COLOR][COLOR=#f57d00]RTTYPE[/COLOR][COLOR=#f57d00] is [/COLOR][COLOR=#f57d00]null[/COLOR][COLOR=#f57d00]"[/COLOR][COLOR=#333333])[/COLOR][COLOR=#333333];}[/COLOR][/FONT]GetType should take "Namespace.Classname" as an argument right? If so what does ", AGExt" mean in this:Type calledType = Type.GetType("ActionGroupsExtended.AGExtExternal, AGExt");if it helps the remotetech api code is here:https://github.com/RemoteTechnologiesGroup/RemoteTech/blob/1.7.0/src/RemoteTech/API/API.cs Quote Link to comment Share on other sites More sharing options...
Diazo Posted November 9, 2015 Share Posted November 9, 2015 GetType should take "Namespace.Classname" as an argument right? If so what does ", AGExt" mean in this:Type calledType = Type.GetType("ActionGroupsExtended.AGExtExternal, AGExt");That is referring to my AGX mod for which the code is found here.ActionGroupsExtended -> The Namespace, found at line 10 of the link.AGExtExternal -> The Class inside the namespace at line 13 of the linkAGExt -> Assembly Name, not in the code but .dll container my code compiles into.Now, I haven't tired exactly what you are doing, but it looks like you are not telling it which assembly to look for that class in.As another example, the following is a call to RT that gets the signal delay for the current vessel:public static double RTTimeDelay(Vessel vsl) //gets delay for directly activated actions { try { Type calledType = Type.GetType("RemoteTech.API.API, RemoteTech"); return (double)calledType.InvokeMember("GetShortestSignalDelay", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static, null, null, new System.Object[] { vsl.id }); } catch { return 0; } }That is a direct copy-paste from my working code so I know it works. All my RemoteTech related code can be found here if you want other examples.D. Quote Link to comment Share on other sites More sharing options...
JPLRepo Posted November 10, 2015 Share Posted November 10, 2015 (edited) KSP 1.0.5 IScienceDataContainer interface.Seems there is a new method expected:- ReturnData(ScienceData data).Anyone have any ideas what this is expected to do?An empty method of course seems to work.. but would be good to know what this is for.Edit: Never mind I figured it out. Should read the release notes more carefully. It's for when a transmit of science data fails and is called to return the science back to the container. Edited November 10, 2015 by JPLRepo Quote Link to comment Share on other sites More sharing options...
legacynl Posted November 10, 2015 Share Posted November 10, 2015 @Diazo: Thanks! I finally got it to work. It wasn't clear from online C# documentation/tutorials that I needed to specify the assembly which contains the class I wanted to access. So thanks again, you (and this thread as a whole) have been a great help. Quote Link to comment Share on other sites More sharing options...
DMagic Posted November 11, 2015 Share Posted November 11, 2015 KSP 1.0.5 IScienceDataContainer interface.Seems there is a new method expected:- ReturnData(ScienceData data).Anyone have any ideas what this is expected to do?An empty method of course seems to work.. but would be good to know what this is for.Edit: Never mind I figured it out. Should read the release notes more carefully. It's for when a transmit of science data fails and is called to return the science back to the container.You should also note that the Science Data constructor has two new arguments (with default values). I'm not really sure what the bool does, but the uint is used by the transmitter to correctly identify which part the science data came from. This is used to return the data if the transmission fails. I'm using false for the bool and the part.flightID for the uint and it seems to be working correctly. Quote Link to comment Share on other sites More sharing options...
JPLRepo Posted November 12, 2015 Share Posted November 12, 2015 You should also note that the Science Data constructor has two new arguments (with default values). I'm not really sure what the bool does, but the uint is used by the transmitter to correctly identify which part the science data came from. This is used to return the data if the transmission fails. I'm using false for the bool and the part.flightID for the uint and it seems to be working correctly.Good pick up. Thanks. Yeah, nothing as to what that bool triggered is for. Quote Link to comment Share on other sites More sharing options...
Kalzuron Posted November 12, 2015 Share Posted November 12, 2015 Does anyone know if it's possible to use props outside of IVA, like a walk up control panel? Quote Link to comment Share on other sites More sharing options...
hab136 Posted November 13, 2015 Share Posted November 13, 2015 Does anyone know if it's possible to use props outside of IVA, like a walk up control panel?Isn't that what Pro Props does? Quote Link to comment Share on other sites More sharing options...
Kalzuron Posted November 13, 2015 Share Posted November 13, 2015 That's a pretty cool mod, I'll have to play around with it. I was more looking for buttons and such, like push a button and open the cargo bay. I know I can just right click but what I'm building will have quite a long right click menu. I'd like to be able to put a button somewhere that I can walk up and use as a Kerbal in EVA. I don't know if anyone has done that yet, if not I will see what I can figure out when my project gets to that point. Any assistance on the matter would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
S1gmoid Posted November 13, 2015 Share Posted November 13, 2015 (edited) [deleted, i'm an idiot] Edited November 13, 2015 by S1gmoid 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.