Crzyrndm Posted January 31, 2015 Share Posted January 31, 2015 Ah, I thought the Instance.crew was a collection (hence the head scratching). My bad. And no, I can't seem to find a reference to the crew inside the editor anywhere either... Quote Link to comment Share on other sites More sharing options...
*Aqua* Posted February 2, 2015 Share Posted February 2, 2015 Ok and now another one. (Maybe I should open my own thread here.)In the editor I add a custom PartModule to every part which can be crewed. That works like it should. The part module has a slider control which you can change via the context menu. For reasons I don't know about, the PartModules OnUpdate() method isn't called so it can't react on the changed settings.Did I miss something? Or aren't the PartModule's OnUpdate() methods supposed to be called in the editor?Comparing to other mods I don't do something different. Quote Link to comment Share on other sites More sharing options...
Padishar Posted February 2, 2015 Share Posted February 2, 2015 The OnXXX functions are only called during flight. Try the versions without the On at the start... Quote Link to comment Share on other sites More sharing options...
*Aqua* Posted February 2, 2015 Share Posted February 2, 2015 Thanks for the quick answer. It works now! And I really thought that PartModules don't have an Update() method. There's nothing about that in the class or the parent classes. Quote Link to comment Share on other sites More sharing options...
Zetla Posted February 2, 2015 Share Posted February 2, 2015 (edited) Hii'm writting a plugin, and my biggest problem is all my images are blurred !!I use texture2D, with good resolution. I have the same problem for the main logo, in the application launcher buttoncode: private WWW imgGM = new WWW("file://"+root+"Plugins/Textures/gm.png");public static Texture2D buttonGM = newTexture2D(24,24);(its the same with other size)and in my awake() method: imgGM.LoadImageIntoTexture(buttonGM);hum test with a existing logo(mechjeb2), with texture2d 24*24, and he is blurred too if someone can help me ??thx Edited February 2, 2015 by Zetla add screenshot Quote Link to comment Share on other sites More sharing options...
Crzyrndm Posted February 2, 2015 Share Posted February 2, 2015 (edited) I believe that's because you have texture downsizing set in KSP settings. If you set texture resolution to full, it should appear as expected.EDIT: *facepalm* Didn't even check the image size... */facepalm* Edited February 2, 2015 by Crzyrndm Quote Link to comment Share on other sites More sharing options...
Zetla Posted February 2, 2015 Share Posted February 2, 2015 Thx for repply when i use mechjeb, he appear as normal, and run too with other modthe problem appear when i make my own pluginsee in the left, mechjeb logo, used by mechjeb, and in the right, my own plugin with the mechjeb logo (for test)i take the same image file, so i don't understand.... Quote Link to comment Share on other sites More sharing options...
stupid_chris Posted February 2, 2015 Share Posted February 2, 2015 Hii'm writting a plugin, and my biggest problem is all my images are blurred !!I use texture2D, with good resolution. I have the same problem for the main logo, in the application launcher buttoncode: private WWW imgGM = new WWW("file://"+root+"Plugins/Textures/gm.png");public static Texture2D buttonGM = newTexture2D(24,24);(its the same with other size)and in my awake() method: imgGM.LoadImageIntoTexture(buttonGM);hum test with a existing logo(mechjeb2), with texture2d 24*24, and he is blurred too http://s16.postimg.org/6kztxujs1/blurred_image.jpgif someone can help me ??thxThe textures used for the AppLauncher button are 40x40, if you instantiate them into a 24x24 texture, KSP will scale them up and loose resolution. Scale your texture to 40x40 and load them up accordingly and it should make more sense. Quote Link to comment Share on other sites More sharing options...
Zetla Posted February 2, 2015 Share Posted February 2, 2015 Hi Chriswhen i test with 38*38 image, its better, but i think the problem is ths samehttp://s7.postimg.org/ln53119vv/blurred_image.pngas you can see, i have the same problem with all my images Quote Link to comment Share on other sites More sharing options...
Robotengineer Posted February 2, 2015 Share Posted February 2, 2015 How do I use UrlDir? Do I need it to search GameData for config nodes? Quote Link to comment Share on other sites More sharing options...
Crzyrndm Posted February 2, 2015 Share Posted February 2, 2015 Config nodes, generally no.const string asstPreset = "PIDPreset"; // this is actually elsewhere so I can use it in multiple locationsforeach (ConfigNode node in GameDatabase.Instance.GetConfigNodes(asstPreset))Loops through all nodes of type PIDPreset (snippet from Pilot Assistant) found inside GameData Quote Link to comment Share on other sites More sharing options...
tomf Posted February 4, 2015 Share Posted February 4, 2015 How do I find out what biome a vessel is in/over? Quote Link to comment Share on other sites More sharing options...
Crzyrndm Posted February 4, 2015 Share Posted February 4, 2015 snippet from KER FlightEngineer.cs[COLOR=#333333][FONT=Consolas]ScienceUtil.GetExperimentBiome(vessel.mainBody, lat, long)[/FONT][/COLOR]I'm assuming that's a KSP class since I can't check right now and I couldn't find a ScienceUtil class in KER Quote Link to comment Share on other sites More sharing options...
tomf Posted February 5, 2015 Share Posted February 5, 2015 Thanks.Another one, I am creating contracts that involve landing at a specific biome.Some biomes are much harder than others e.g. landing on the munar highlands is a lot easier than hitting the canyons. Is there already a representation of the difficulty of each biome or am I going to have to go through each every biome and put them in a config file?In fact just getting a list of the existing biomes out of the engine would be useful. Quote Link to comment Share on other sites More sharing options...
Koobze Posted February 9, 2015 Share Posted February 9, 2015 I am trying to write my first plugin, but am running up against a wall. I would like to resize a part via right-click, for example to shrink parts of a ship while in-flight. I tried modifying the Mesh vertices and updating the bounds, I tried modifying the collider's bounds.size directly, changing scaleFactor and rescaleFactor, but none if it seems to achieve what I want. Changing the vertices worked, but the other parts attached to the resized part remained where they used to be, still connected to the previous location, without updating to reflect the new visual size of the object. Am I missing something obvious? Can someone point me in the right direction? I've looked at some existing mods (infernal robotics, b9) but can't find the relevant part of the code. Thanks! Quote Link to comment Share on other sites More sharing options...
Crzyrndm Posted February 9, 2015 Share Posted February 9, 2015 Attach nodes are defined seperately to geometry. You probably need to alter their position when you do the resizing.// Semi-psuedo code. Not at dev PCforeach (AttchNode AN in APart.AttachNodes){ AN.position *= rescaleFactor;} Quote Link to comment Share on other sites More sharing options...
NathanKell Posted February 9, 2015 Share Posted February 9, 2015 And even then, IIRC that won't move anything already attached to them; you'll need to move the attached parts yourself. Quote Link to comment Share on other sites More sharing options...
Crzyrndm Posted February 9, 2015 Share Posted February 9, 2015 And even then, IIRC that won't move anything already attached to them; you'll need to move the attached parts yourself.Thinking about it a little more, even if they did stick to the shifted node, you'd still have to move it yourself otherwise things will break/explode due to joints trying to snap into place. Quote Link to comment Share on other sites More sharing options...
Koobze Posted February 10, 2015 Share Posted February 10, 2015 (edited) Thanks for the info guys! Thinking about it a little more, even if they did stick to the shifted node, you'd still have to move it yourself otherwise things will break/explode due to joints trying to snap into place. Can you point me at where that's best done? I've tried messing with a child-part's transform.position and it seemed to do nothing, same with offset. Is it .attPos?Edit: It actually is transform.position. No idea what I was doing wrong before, but I tried it again now and it works. Edited February 10, 2015 by Koobze Quote Link to comment Share on other sites More sharing options...
Robotengineer Posted February 10, 2015 Share Posted February 10, 2015 (edited) Is this going in the right direction for loading configs?public void GeneratePages(){ foreach(ConfigNode node in GameDatabase.Instance.GetConfigNodes("WIKI")) { string type = node.GetValue("type"); switch (type) { case "celestial": break; case "part": break; case "default": break; case "info": break; default: goto case "default"; break; } }} Edited February 10, 2015 by Robotengineer formatting. Quote Link to comment Share on other sites More sharing options...
Diazo Posted February 10, 2015 Share Posted February 10, 2015 While I have never seen the GameDatabase.Instance.GetConfigNodes("WIKI") method before, what comes after that looks correct.It will load the value in the 'type' key of each node and then compare it in your switch statement.D. Quote Link to comment Share on other sites More sharing options...
Robotengineer Posted February 10, 2015 Share Posted February 10, 2015 While I have never seen the GameDatabase.Instance.GetConfigNodes("WIKI") method before, what comes after that looks correct.It will load the value in the 'type' key of each node and then compare it in your switch statement.D.That's what I want it to do, thanks! It's for loading the pages of an upcoming plugin. Quote Link to comment Share on other sites More sharing options...
LordFjord Posted February 10, 2015 Share Posted February 10, 2015 I have a question regarding best practice on making a mod support other mods without including 3rd party DLLs - which I do not want to do because of common sense and I can not do due to licensing.The following code is a method that helps me determine if a part is an intake, an airbreatherengine or both in case of modded engines. PartType is an enum that helps me processing all this.How could I make this support for example Karbonite or Interstellar? Folks have asked for it in the Intake Build Aid dev thread and I would like to support it if possible.My idea was to create resource-sets, one for the stock stuff and one for each modded resources and handle them independently. I'm stuck on how to implement this without the dependencies to the types. A search for these in the KSP directory would be possible, but then I would need to adjust the mod for each dependency changes. It would be better to be able to handle this in a generic way maybe via reflections.private PartType GetPartType( Part part ) { // find engines by ModuleEngines and ModuleEnginesFX module with intakeair propellant // this is for modded engines that are both intakes and engines in one part if ( ( ( part.Modules.OfType<ModuleEnginesFX>().Any( x => x.propellants.Any( y => y.name == "IntakeAir" ) ) ) || ( part.Modules.OfType<ModuleEngines>().Any( x => x.propellants.Any( y => y.name == "IntakeAir" ) ) ) ) && ( part.Modules.OfType<ModuleResourceIntake>() != null && part.Modules.OfType<ModuleResourceIntake>().Any( x => x.resourceName == "IntakeAir" ) ) ) { return PartType.IntakeAndEngine; } // find engines by ModuleEngines and ModuleEnginesFX module with intakeair propellant else if ( ( part.Modules.OfType<ModuleEnginesFX>().Any( x => x.propellants.Any( y => y.name == "IntakeAir" ) ) ) || ( part.Modules.OfType<ModuleEngines>().Any( x => x.propellants.Any( y => y.name == "IntakeAir" ) ) ) ) { return PartType.AirBreatherEngine; } // find intakes by resource intakeair else if ( part.Modules.OfType<ModuleResourceIntake>() != null && part.Modules.OfType<ModuleResourceIntake>().Count() > 0 && part.Modules.OfType<ModuleResourceIntake>().Any( x => x.resourceName == "IntakeAir" ) ) { return PartType.Intake; } else { return PartType.SomethingElse; } }So in the end I would need to get the correct ModuleEngine and ModuleResourceIntake types and the resource names from the mods.From what I've seen with a quick look at Karbonite, it uses ModuleResourceIntake with resource name "IntakeAtm".So, how to get all this under the hood?Cheers,Fjord Quote Link to comment Share on other sites More sharing options...
Crzyrndm Posted February 10, 2015 Share Posted February 10, 2015 (edited) if ((( part.Modules.OfType<ModuleEnginesFX>().Any( x => x.propellants.Any( y => y.name == "IntakeAir" [COLOR=#ff0000]|| y.name == "IntakeAtm"[/COLOR]))) || (part.Modules.OfType<ModuleEngines>().Any( x => x.propellants.Any( y => y.name == "IntakeAir" [COLOR=#FF0000]|| y.name == "IntakeAtm"[/COLOR])) ...If all you need to check against is more resource options, just add more options. No need for any reflection or dependencies (it doesn't matter if there is no resource called IntakeAtm to your function, .Any will just return false if it can't find a match)The issue would be if they aren't using the stock modules// find intakes by resource intakeairelse if ([COLOR=#ff0000]part.Modules.OfType<ModuleResourceIntake>() != null[/COLOR][COLOR=#FF0000] && part.Modules.OfType<ModuleResourceIntake>().Count() > 0[/COLOR] && part.Modules.OfType<ModuleResourceIntake>().Any( x => x.resourceName == "IntakeAir")){ return PartType.Intake;}Why all these checks? .Count > 0 definitely isn't needed (.Any() has that covered) and .OfType<> won't be returning an unintialised list... Edited February 10, 2015 by Crzyrndm Quote Link to comment Share on other sites More sharing options...
LordFjord Posted February 10, 2015 Share Posted February 10, 2015 Thanks for the quick reply. I already removed those checks, thanks for pointing that out (the first two queries didnt have them anymore, missed the last one).My problem is: what if the other mods do not use the ModuleReourceIntake or ModuleEngine types?From an interstellar intake's config:MODULE{name = AtmosphericIntakearea = 0.04}RESOURCE{name = IntakeAtmamount = 1maxAmount = 1}AtmosphericIntake is a custom resource type or am I wrong with it? 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.