theSpeare Posted January 31, 2014 Share Posted January 31, 2014 Oh right, sorry I didn't dig through. Thanks Faark Quote Link to comment Share on other sites More sharing options...
Headhunter09 Posted February 1, 2014 Share Posted February 1, 2014 I know that thats a little confusing especially sense I used a made up coding/ English languageThat's called pseudocode, and there's a generally accepted way to do that is more readable than what you wrote. Quote Link to comment Share on other sites More sharing options...
Chronothan Posted February 1, 2014 Share Posted February 1, 2014 Having an issue trying to create a config setting for controls.Any C#/Unity gurus out there who have any idea why the following code gives me a 'Enum.TryParse - method not found' exception at runtime?KeyCode reviewData;if (Enum.TryParse(cfg.GetValue("storedDataKey"), out reviewData) { return reviewData; }It's inside a method that is called during flight scene Awake(), to set the keybinding. Visual studio has no problems, it compiles just fine. I get the error in game however. Quote Link to comment Share on other sites More sharing options...
MrHappyFace Posted February 1, 2014 Share Posted February 1, 2014 How can I get the current Game? Quote Link to comment Share on other sites More sharing options...
NathanKell Posted February 1, 2014 Share Posted February 1, 2014 Chronothan: which framework level are you compiling for?MrHappyFace: HighLogic.CurrentGame? Quote Link to comment Share on other sites More sharing options...
DMagic Posted February 1, 2014 Share Posted February 1, 2014 Anyone know how I can go about accessing the biome name where a vessel is located?The solution to the problem in Rhidian's answer is that you have to report lat and long in radians not degrees. So you need something like:public void BiomeCheck() { print(FlightGlobals.currentMainBody.BiomeMap.GetAtt(vessel.latitude * Mathf.Deg2Rad, vessel.longitude * Mathf.Deg2Rad).name); }That will return the correct biome, though you won't get anything for the KSC, just shores (maybe there is some specific area that will return KSC, but I didn't find it). Quote Link to comment Share on other sites More sharing options...
Chronothan Posted February 1, 2014 Share Posted February 1, 2014 Chronothan: which framework level are you compiling for?MrHappyFace: HighLogic.CurrentGame?I am embarrassed to admit this. But I have no idea what that means I am working on this to learn C# and modding in general. This is my first actual project so I'm learning as I go. Basically, I'm becoming a master at restarting KSP.Here is the full method: public KeyCode checkKeys() { checkConfig();//Makes sure the config exists. Creates it if it doesn't. KeyCode key; if (!Enum.TryParse(cfg.GetValue("reviewDataKey"), out key)) { cfg.SetValue("reviewDataKey", "Backslash"); cfg.Save("GameData/ForceIVA/IVAoptions.cfg"); Debug.Log("Make sure to use the list of keys to set the key! Reverting to backslash"); return KeyCode.Backslash; } else { return key; } }I have two classes, the main ForceIVA class, and the ConfigUtil class that this method is located in. The ForceIVA class instantiates ConfigUtil and calls this method in Awake().ForceIVA class itself is instantiated in at flight mode startup. Quote Link to comment Share on other sites More sharing options...
NathanKell Posted February 1, 2014 Share Posted February 1, 2014 In build properties for your project you'll see a target framework, like .NET 4.5. Change it to .NET 3.0. Most versions of VC# (or, presumably, MonoDevelop) default to more recent frameworks which may allow things KSP won't understand. Quote Link to comment Share on other sites More sharing options...
Tidus Klein Posted February 3, 2014 Share Posted February 3, 2014 ok what im i doing wrong?. C++ will not compile my code, it just gives me a list of errors.I even tried to compile code from an open source mode, KSPI and it still gave me the errorshere is a list 2 7 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected nested-name-specifier before 'System'2 7 G:\Games\kerbal space\ModulePrecooler.cpp [Error] 'System' has not been declared3 1 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected ';' before 'using'3 7 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected nested-name-specifier before 'System'3 7 G:\Games\kerbal space\ModulePrecooler.cpp [Error] 'System' has not been declared3 13 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected ';' before '.' token3 13 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected unqualified-id before '.' token4 7 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected nested-name-specifier before 'System'4 7 G:\Games\kerbal space\ModulePrecooler.cpp [Error] 'System' has not been declared4 13 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected ';' before '.' token4 13 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected unqualified-id before '.' token5 7 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected nested-name-specifier before 'System'5 7 G:\Games\kerbal space\ModulePrecooler.cpp [Error] 'System' has not been declared5 13 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected ';' before '.' token5 13 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected unqualified-id before '.' token6 7 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected nested-name-specifier before 'UnityEngine'6 7 G:\Games\kerbal space\ModulePrecooler.cpp [Error] 'UnityEngine' has not been declared9 40 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected class-name before '{' token10 9 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected unqualified-id before '[' token13 19 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected ':' before 'bool'13 37 G:\Games\kerbal space\ModulePrecooler.cpp [Warning] non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]14 19 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected ':' before 'ModuleResourceIntake'14 19 G:\Games\kerbal space\ModulePrecooler.cpp [Error] 'ModuleResourceIntake' does not name a type16 16 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected ':' before 'override'16 16 G:\Games\kerbal space\ModulePrecooler.cpp [Error] 'override' does not name a type30 16 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected ':' before 'override'30 16 G:\Games\kerbal space\ModulePrecooler.cpp [Error] 'override' does not name a type38 16 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected ':' before 'override'38 16 G:\Games\kerbal space\ModulePrecooler.cpp [Error] 'override' does not name a type47 16 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected ':' before 'bool'50 5 G:\Games\kerbal space\ModulePrecooler.cpp [Error] expected ';' after class definition32 G:\Games\kerbal space\Makefile.win recipe for target 'ModulePrecooler.o' failedand code, This is going to be a huge post (stolen from KSPI) using System using System.Collections.Generic;using System.Linq;using System.Text;using UnityEngine;namespace PRPlugin { class ModulePrecooler : PartModule { [KSPField(isPersistant = false, guiActive = true, guiActiveEditor = true, guiName = "Precooler status")] public string statusStr; protected bool functional = false; protected ModuleResourceIntake attachedIntake; public override void OnStart(PartModule.StartState state) { if (state == StartState.Editor) { return; } foreach (AttachNode attach_node in part.attachNodes) { if (attach_node.attachedPart != null) { List<ModuleResourceIntake> mres = attach_node.attachedPart.FindModulesImplementing<ModuleResourceIntake>().Where(mre => mre.resourceName == "IntakeAir").ToList(); if(mres.Count > 0) { attachedIntake = mres.First(); } } } part.force_activate(); } public override void OnUpdate() { if (functional) { statusStr = "Active."; } else { statusStr = "Offline."; } } public override void OnFixedUpdate() { functional = false; if (attachedIntake != null) { if (attachedIntake.intakeEnabled) { functional = true; } } } public bool isFunctional() { return functional; } }}what is going ON? Quote Link to comment Share on other sites More sharing options...
Diazo Posted February 3, 2014 Share Posted February 3, 2014 (edited) To confirm, you have added the two dependencies you need so that the compiler knows where System and UnityEngine can be found?These two dependencies are what I'm talking about:KSP_INSTALL_FOLDER\KSP_Data\Managed\Assembly-CSharp.dllKSP_INSTALL_FOLDER\KSP_Data\Managed\UnityEngine.dll They need to be linked as References in your IDE.D. Edited February 3, 2014 by Diazo Quote Link to comment Share on other sites More sharing options...
Tidus Klein Posted February 3, 2014 Share Posted February 3, 2014 O.0 ooo ok, still new to coding let me try ituuuu how do i add a Reference in Dev C++ portable Quote Link to comment Share on other sites More sharing options...
Diazo Posted February 3, 2014 Share Posted February 3, 2014 Errr, I'll have to point you at the help file.I use Visual Studio, it's References option in the Project menu in that program.D. Quote Link to comment Share on other sites More sharing options...
Faark Posted February 3, 2014 Share Posted February 3, 2014 @tibusThe code you have posted isn't c++! It is C#, like most other mods you will find around the KSP forum. So make sure you are using a C# compiler (like Visual Studio Express for Windows Desktop) and create a C# project (Class Library) or use a C++ dev environment that can create CLI assemblies (VS 2008 can, CLR => class library) and follow the language specifics of that environment! Quote Link to comment Share on other sites More sharing options...
Tidus Klein Posted February 3, 2014 Share Posted February 3, 2014 @tibusThe code you have posted isn't c++! It is C#, like most other mods you will find around the KSP forum. So make sure you are using a C# compiler (like Visual Studio Express for Windows Desktop) and create a C# project (Class Library) or use a C++ dev environment that can create CLI assemblies (VS 2008 can, CLR => class library) and follow the language specifics of that environment!WHAT?! but it says C++ on my aptly named devC++ portable hmmm ill try it. Quote Link to comment Share on other sites More sharing options...
metaphor Posted February 4, 2014 Share Posted February 4, 2014 Is is possible to transfer crafts between different saves of the game? Or create a new save with a plugin? I'm thinking of some ideas for a possible mod, and switching between saves would make or break it. Quote Link to comment Share on other sites More sharing options...
TriggerAu Posted February 4, 2014 Share Posted February 4, 2014 Is is possible to transfer crafts between different saves of the game? Or create a new save with a plugin? I'm thinking of some ideas for a possible mod, and switching between saves would make or break it.I havent done exactly this myself, but I'm pretty sure the save file format is a standard ConfigNode structure so yes you could do this. You'd want to be careful not to corrupt the save of course , but should be possible. Quote Link to comment Share on other sites More sharing options...
Diazo Posted February 4, 2014 Share Posted February 4, 2014 Okay, what I'm pretty sure is a simple question.I want to check for the presence of another mod and run some code if it exists, but I don't actually call the mod itself so I don't want to make a dependency.So, check to see if the mod's .dll file exists. Except I can't get this to co-operate.Here's what I'm running:if (KSP.IO.File.Exists<File>(KSPUtil.ApplicationRootPath + "GameData/KAS/Plugin/KAS.dll")) { print("KAS Detected!"); } else { print("KAS Not Detected"); }and it prints "KAS Not Detected" to the debug log so the code is executing, but I can't make it find the KAS.dll file.Instead of KSPUtil.ApplicationRootPath + "GameData/KAS/Plugin/KAS.dll" I've also tried:"KAS/Plugin/KAS""KAS/Plugin/KAS.dll"trying to use the loader that catches images files and stuff and no go there either.I'm 99% sure it's a simple syntax thing that I've got wrong but google is no help (I don't know the right term to be searching for) and the C# File.Exists command is different enough from the KSP.IO.File.Exists<T> command that references to that are not helping me.So, anyone able to help please?Thanks,D. Quote Link to comment Share on other sites More sharing options...
Faark Posted February 4, 2014 Share Posted February 4, 2014 @DiazoYou might want to try Type.GetType with a namespace-qualified type name of an KAS type... null => no KAS. Though it kinda depends on whether the KAS assembly was already loaded, so it might not be a good idea to use it on KSPAddon.Startup.Instantly. Quote Link to comment Share on other sites More sharing options...
Diazo Posted February 4, 2014 Share Posted February 4, 2014 (edited) One of the reasons I tried to go with a File.Exists was so I would not have to worry about loaded or not. Although I suppose doing a File.Exists check does not tell me if it loaded correctly or not, the file could be there and KAS has failed to load.Type.GetType is probably a better idea. If I put it in my FlightScene Awake module I think I can guarantee that KAS is loaded (if it's going to load) by the time my Awake code runs.Thanks for the idea Faark.D.edit: Hun. Apparently KSP 0.21 removed the System.IO restriction. I'll probably still go with the GetType method, but apparently System.IO.File.Exists would have worked. Source Edited February 4, 2014 by Diazo Quote Link to comment Share on other sites More sharing options...
TriggerAu Posted February 4, 2014 Share Posted February 4, 2014 I've used both file exists and the GetType option, they will both work. Personally for checking for a Mod I think Faark has the best idea, especially as you have no guarantee the player will install KAS into the same place . The assemblies all get loaded in the loading scene so they will be there when awake is called Quote Link to comment Share on other sites More sharing options...
Diazo Posted February 5, 2014 Share Posted February 5, 2014 For reference, I used the AssemblyLoader.loadedAssemblies list.More exactly:foreach (AssemblyLoader.LoadedAssembly Asm in AssemblyLoader.loadedAssemblies) { if (Asm.dllName == "KAS") { TWR1KASDetect = true; } }Detects if KAS is loaded or not.Asm.name also exists, but while both are unlikely to change, I figure the .dllname is less likely to change then the .nameD. Quote Link to comment Share on other sites More sharing options...
cyoung_mi Posted February 6, 2014 Share Posted February 6, 2014 Hello all,I'm really hoping I can find a Mac Modder out there that can fork this plugin..I think the original idea was very cool, but unfortunately the creator is unable to made a Mac version of the plug in.Can anyone help?http://forum.kerbalspaceprogram.com/...l-%2804-Feb%29Source code for the plugin https://github.com/zitron-git/KSPSerialIO Quote Link to comment Share on other sites More sharing options...
FlowerChild Posted February 6, 2014 Share Posted February 6, 2014 (edited) Minor issue, but has anyone figured out how to set the title for a module in the new extended right-click-to-display part description pane?For example, all my custom modules automagically grab the title from the class name and it results in stuff like this:Now, I'd really prefer not to alter my mod's class naming convention just to alter the string that's displayed as a title, but so far I'm having no luck in changing it through any other method.Also, as a secondary question, does anyone know the format codes to display parts of the GetInfo() string in green or what have you? You'll notice above that "Requires:" is written in the default white, but for all stock parts, it's displayed in green. For the sake of consistency, I'd like to be able to do so as well if possible.EDIT: Figured out the second part. For reference, debug outputting the GetInfo() string for stock modules, gives stuff along these lines:<b><color=#99ff00ff>Requires:</color></b>From which the format codes can be extracted.Still have no clue on the title part though Edited February 6, 2014 by FlowerChild Quote Link to comment Share on other sites More sharing options...
Faark Posted February 6, 2014 Share Posted February 6, 2014 @flowerLooks like RT is doing it via a KSPModule attribute. Also AvailablePart seems to have an moduleInfos & messing around with that could offer some neat features as well. Quote Link to comment Share on other sites More sharing options...
FlowerChild Posted February 6, 2014 Share Posted February 6, 2014 (edited) @flowerLooks like RT is doing it via a KSPModule attribute. Also AvailablePart seems to have an moduleInfos & messing around with that could offer some neat features as well.Thanks Faark! Will take a look at the RemoteTech code base then.EDIT: Yup, the following does the trick: [KSPModule( "Life Support" )] class BTSMModuleLifeSupport : PartModule { }Thanks a million man. Would have taken me forever to figure that one out Edited February 6, 2014 by FlowerChild 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.