Jump to content

WaveFunctionP

Members
  • Posts

    863
  • Joined

  • Last visited

Everything posted by WaveFunctionP

  1. New version should be up soon with an adjustment to the science value filter to reduce the number of trailing repeat experiments that are done for extremely little value. Experiments now require that it be worth at least .1 science. v 1.2 - Science value filtering adjustment - Increased the minimum value to run an experiment to .1 science. I take the silence lately as everything is going well.
  2. Minor update. v 1.1 - EVA science support - Science will be automaticly gathered while EVA.
  3. Small update. v1.1 - Fix Duplicate entries on EVA. - Resolved an issue where duplicate surface samples and eva reports would be stored each time the experiment was activated.
  4. Yup. it fixes these scenarios: Crew report > eva > take science data > store science data > reenter pod > now you can take a new crew report EVA report > store data > now you can take a new eva report Surface Sample > store data > now you can take a new surface sample Also, great thread. This mod does not add any containers. So, no, probes will not be effected. This is just removing that tedious dance everyone has to do with report storage. Which reminds me that I should probably do a check for that to avoid errors. I've never used it. I have no idea what it involved.
  5. Do you find it annoying to do the "data dance" of storing data into the command pod before you can run another eva report, crew report or surface sample? I did! So I made a simple mod that moves the unique reports automatically to the science container on your vessel or kerbal so that you can run another report if you so desire. And just like stock, it will not allow multiple of the same exact experiment in the command pod or kerbal. Note: If you use my mod ForScience!, you have no need for this mod. Download it here. License: CC by SA Source Coffee Fund Known Issues: None.
  6. Like SpaceTiger said, the science container is on all stock command pods. Just like all stock engines use a module called ModuleEngine to do their enginey-type things. So do all command pods have a module called ModuleScienceContainer that handles the storage of science data. You can see these module references in the part file, and they are associated with bits of compiled c# code that handle how they behave.
  7. Ah, I don't have those in that case. There are similar problems areas around the launchpad where everything is different, but return launchpad. I spent hours running around KSC, those things were everywhere.
  8. private string currentBiome() // we keep a running check on the vessels state to see if we've changed biomes. { if (currentVessel().landedAt != string.Empty) // more string emptys for weird biomes { if (currentVessel().landedAt == "KSC_Pad_Grounds") return "LaunchPad"; // handle a bunch of special biomes around ksc else if (currentVessel().landedAt == "KSC_LaunchPad_Platform") return "LaunchPad"; else if (currentVessel().landedAt == "KSC_Pad_Flag_Pole") return "LaunchPad"; else if (currentVessel().landedAt == "KSC_Pad_Water_Tower") return "LaunchPad"; else if (currentVessel().landedAt == "KSC_Pad_Tanks") return "LaunchPad"; else if (currentVessel().landedAt == "KSC_Pad_Round_Tank") return "LaunchPad"; else if (currentVessel().landedAt == "KSC_SPH_Grounds") return "SPH"; else if (currentVessel().landedAt == "KSC_SPH_Round_Tank") return "SPHRoundTank"; else if (currentVessel().landedAt == "KSC_SPH_Main_Building") return "SPHMainBuilding"; else if (currentVessel().landedAt == "KSC_SPH_Water_Tower") return "SPHWaterTower"; else if (currentVessel().landedAt == "KSC_SPH_Tanks") return "SPHTanks"; else if (currentVessel().landedAt == "KSC_Crawlerway") return "Crawlerway"; else if (currentVessel().landedAt == "KSC_Mission_Control_Grounds") return "MissionControl"; else if (currentVessel().landedAt == "KSC_Mission_Control") return "MissionControl"; else if (currentVessel().landedAt == "KSC_VAB_Grounds") return "VAB"; else if (currentVessel().landedAt == "KSC_VAB_Round_Tank") return "VABRoundTank"; else if (currentVessel().landedAt == "KSC_VAB_Pod_Memorial") return "VABPodMemorial"; else if (currentVessel().landedAt == "KSC_VAB_Main_Building") return "VABMainBuilding"; else if (currentVessel().landedAt == "KSC_VAB_Tanks") return "VABTanks"; else if (currentVessel().landedAt == "KSC_Astronaut_Complex_Grounds") return "AstronautComplex"; // yes, it is messy else if (currentVessel().landedAt == "KSC_Astronaut_Complex") return "AstronautComplex"; else if (currentVessel().landedAt == "KSC_Administration_Grounds") return "Administration"; else if (currentVessel().landedAt == "KSC_Administration") return "Administration"; else if (currentVessel().landedAt == "KSC_Flag_Pole") return "FlagPole"; else if (currentVessel().landedAt == "KSC_R&D_Grounds") return "R&D"; else if (currentVessel().landedAt == "KSC_R&D_Corner_Lab") return "R&DCornerLab"; else if (currentVessel().landedAt == "KSC_R&D_Central_Building") return "R&DCentralBuilding"; else if (currentVessel().landedAt == "KSC_R&D_Wind_Tunnel") return "R&DWindTunnel"; else if (currentVessel().landedAt == "KSC_R&D_Main_Building") return "R&DMainBuilding"; else if (currentVessel().landedAt == "KSC_R&D_Tanks") return "R&DTanks"; else if (currentVessel().landedAt == "KSC_R&D_Observatory") return "R&DObservatory"; else if (currentVessel().landedAt == "KSC_R&D_Side_Lab") return "R&DSideLab"; else if (currentVessel().landedAt == "KSC_R&D_Observatory") return "R&DObservatory"; else if (currentVessel().landedAt == "KSC_R&D_Small_Lab") return "R&DSmallLab"; else if (currentVessel().landedAt == "KSC_Tracking_Station_Grounds") return "TrackingStation"; else if (currentVessel().landedAt == "KSC_Tracking_Station_Hub") return "TrackingStationHub"; else if (currentVessel().landedAt == "KSC_Tracking_Station_Dish_East") return "TrackingStationDishEast"; else if (currentVessel().landedAt == "KSC_Tracking_Station_Dish_South") return "TrackingStationDishSouth"; else if (currentVessel().landedAt == "KSC_Tracking_Station_Dish_North") return "TrackingStationDishNorth"; // very messy else return currentVessel().landedAt; // you're still here? } else return ScienceUtil.GetExperimentBiome(currentBody(), currentVessel().latitude, currentVessel().longitude); //else give up, err...return squad's *cough* highly accurate biome *cough* } This should return the proper biomes. private bool StatesHaveChanged() // Track our vessel state, it is used for thread control to know when to fire off new experiments. { if (currentVessel() != stateVessel | currentSituation() != stateSituation | currentBody() != stateBody | currentBiome() != stateBiome) { stateVessel = currentVessel(); stateBody = currentBody(); stateSituation = currentSituation(); stateBiome = currentBiome(); stopwatch.Reset(); stopwatch.Start(); } if (stopwatch.ElapsedMilliseconds > 100) // trottling detection to kill transient states. { stopwatch.Reset(); #if DEBUG Debug.Log("[For Science] Vessel in new experiment state."); #endif return true; } else return false; } And this should throttle those transient states that I was speaking of earlier. The entire structure of forscience was reworked for this release. Most of the complicated stuff has been moved to smaller helper functions, and nearly all of the state variables were removed as a result, making for much more readable code I hope. If you have an questions, just PM me, I'd be glad to help.
  9. Interesting. It shouldn't be too hard, though probably more difficult than it seems if it is anything like my projects. I think most of what you need is available in the randd and sciencesubject classes. You could also take a look a bit at my forscience code, because I do quite a bit of checking for experiments which may give you some inspiration. If you are just getting started with modding, a limited scope like this would be a great way to start.
  10. I will add support for probes as soon as I work out a reasonable solution for transmission, since probes do not have containers, I can't simply transmit willy nilly without making the probe inoperable.
  11. The mod knows when science science is available, and runs the appropriate experiments. That's the automagic part. It's all in the video, if you can make it past my very uninspiring vocal talents. If you use ForScience!, you don't have much need for science alert except for things like eva and surface samples, which have rules that are pretty clear compared to the contorted list of states that other experiments require that you remember.
  12. Yes. I didn't think about that case. :/ I'll add it to the list.
  13. PCGamer: http://www.pcgamer.com/the-best-kerbal-space-program-mods-2/ ForScience! is an autopilot for running, collecting and resetting experiments. Science can start to be a little grindy or tedious after some time playing KSP. This plugin is intended to help improve the experience in various ways. What it does: Automagicly detects and runs experiments that have science available, when they are available. (Even those special biomes around KSC.) Automagicly collects the data from those experiments into a science container (command pod). Automagicly resets experiments that are "run once", when you have a scientist onboard. (mystery goo, sci jrs) What it does not do: Give you science you could haven't gotten otherwise. Run experiments that do not implement the stock science modules. Run "run once" experiments without a scientist on board. How to Use: The Green FS toolbar icon means it is running. The Red FS toolbar icon means it is not running. No toolbar icon means you have no containers onboard, (And that it is not runnning). Download Source Change Log License: CC by SA Coffee Fund (donations) Known Issues: - none - let me know in this thread if you have one Acknowledgements: Special Thanks to stupid_chris, DMagic and xEvilReeperx for helping me navigate the many issues I had while developing this plugin.
  14. I could probably clean my logic up quite a bit with switch, continue and break in general. But after finding out the issue with nulls, I've been able to simplify that particular portion quite a bit with methods that I've tried but failed at before. This is the full method now. private void RunScience() { if (GetExperimentList() == null) { #if DEBUG Debug.Log("[For Science] GetExperiment() was null."); #endif } else { completedExperiments.Clear(); // clear our list of experiments that have been run so we start with a fresh list. foreach (ModuleScienceExperiment currentExperiment in GetExperimentList()) { var fixBiome = string.Empty; // some biomes don't have 4th string, so we just put an empty in to compare strings later if (currentExperiment.experiment.BiomeIsRelevantWhile(currentSituation())) fixBiome = currentBiome();// for those that do, we add it to the string // we build the current string to check against the available experiements var currentScienceSubject = ResearchAndDevelopment.GetExperimentSubject(currentExperiment.experiment, currentSituation(), currentBody(), fixBiome);// << squad's fancy string builder. ikr!, with all this work, we pretty much did all the work already // and we check the value to see if it is worth running var currentScienceValue = ResearchAndDevelopment.GetScienceValue(currentExperiment.experiment.baseValue * currentExperiment.experiment.dataScale, currentScienceSubject); #if DEBUG Debug.Log("[For Science] Checking experiment: " + currentScienceSubject.id); #endif if (completedExperiments.Contains(currentExperiment)) // do we have the same experiment onboard? { #if DEBUG Debug.Log("[For Science] Skipping: Experiment duplicate detected."); #endif } else if (!currentExperiment.rerunnable & !IsScientistOnBoard()) // no cheating goo and materials here { #if DEBUG Debug.Log("[For Science] Skipping: Experiment is not repeatable."); #endif } else if (!currentExperiment.experiment.IsAvailableWhile(currentSituation(), currentBody())) // this experiement isn't available here so we skip it { #if DEBUG Debug.Log("[For Science] Skipping: Experiment is not available for this situation/atmosphere."); #endif } else if (currentScienceValue == 0) // this experiment has little value so we skip it { #if DEBUG Debug.Log("[For Science] Skipping: No more science is available: "); #endif } else { ScienceData newdata = new ScienceData( currentExperiment.experiment.baseValue * currentScienceSubject.dataScale, currentExperiment.xmitDataScalar, 0f, currentScienceSubject.id, currentScienceSubject.title ); if (ActiveContainer() == null || !ActiveContainer().HasData(newdata)) { #if DEBUG Debug.Log("[For Science] Running experiment: " + currentScienceSubject.id); #endif //manually add data to avoid deployexperiment state issues ActiveContainer().AddData(newdata); //} } completedExperiments.Add(currentExperiment); // add this to the list of experiments to check for duplicates earlier in the runscience logic } } } }
  15. GetContainerList() just returns FlightGlobals.ActiveVessel.FindPartModulesImplementing<ModuleScienceContainer>().First().GetData() I've tried FlightGlobals.ActiveVessel.FindPartModulesImplementing<ModuleScienceContainer>()[0].GetData() as well as checking for null. I just ended up skipping then container check with getstoreddata() == 0, and flagging to run the experiments. edit: The firstordefault thing is new to me, thanks for the tip. edit edit: I just tried the firstordefault and i'm finally getting null errors. That works like a charm!
  16. I just tried iterating a foreach loop through all the containers and the result was the same behavior. foreach (ModuleScienceContainer container in GetContainerList()) { foreach (ScienceData data in container.GetData()) // search through all the data we have collected onboard to check if we've collected it already { isincontainer = false; if (currentScienceSubject.id == data.subjectID) // we already have this data in our container, so we skip this experiment { #if DEBUG Debug.Log("[For Science] Skipping: Found existing experiment data: " + currentScienceSubject.id); isincontainer = true; // if this never goes off, this flag is used to actually fire off the experiment break; #endif } } } There are only two modulesciencecontainers between the two ships that I'm testing with. When I undock, the first one the list SHOULD be the only one on the list. I think. When I dock, it seems a random pod is chose to be at the top of the part tree and so it seem random which pod will get chosen, but still, only ever one pod get the data. And the pod with the data is the only one that continues to collect data properly. (wild guess inc!) I don't think that getdata()'s ScienceData[] object is getting reinitialized properly for the module after the data is removed, and I don't know how to force initialization. edit: Here's the error I get if I try to access the first data in the sciencedata array when the problem is occurring.
  17. I'm looking through some sciencedata in a foreach loop, and for some reason or the other, it stopped working after docking. foreach (ScienceData data in FlightGlobals.ActiveVessel.FindPartModulesImplementing<ModuleScienceContainer>().First().GetData()) // search through all the data we have collected onboard to check if we've collected it already { isincontainer = false; Debug.Log(data.subjectID + currentScienceSubject.id); if (currentScienceSubject.id == data.subjectID) // we already have this data in our container, so we skip it { #if DEBUG Debug.Log("[For Science] Skipping: Found existing experiment data: " + currentScienceSubject.id); isincontainer = true; break; #endif } } I check in several places, but I don't think that FlightGlobals.ActiveVessel.FindPartModulesImplementing<ModuleScienceContainer>().First().GetData() is returning a value to iterate through after docking. I can run a crew report and store it and it will start working. It is just wierd, and I figure its some obscurity of object references that i don't understand or something, but i tried it a bunch of different ways. I'm made a new arrays, tried calling the object before the loop. To be clear, it works fine before docking, and while it is docked, but stops working after undocking on the vessel with no data (the data is transferred to one single container during docking). And debug log of the object says sciencedata as expected, but I get no errors whatsoever, so I don't know what else to inspect or how to try and figure it out. Here's the relevant transfer code. private void TransferScience() { if (ActiveContainer().GetActiveVesselDataCount() != ActiveContainer().GetScienceCount()) // only actually transfer if there is data to move to active container { #if DEBUG Debug.Log("[For Science] Tranfering science to container."); #endif ActiveContainer().StoreData(GetExperimentList().Cast<IScienceDataContainer>().ToList(), true); // this is what actually moves the data to the active container List<ModuleScienceContainer> containerstotransfer = GetContainerList(); // a temporary list of our containers containerstotransfer.Remove(ActiveContainer()); // we need to remove the container we storing the data in because that would be wierd and buggy ActiveContainer().StoreData(containerstotransfer.Cast<IScienceDataContainer>().ToList(), true); // now store all data from other containers } } Yes, I talk to myself a lot in my code.
  18. An MM patch is all that is need to add a container to the probe core, fyi.
  19. Have you looked in the settings config? It appears to generate a config file with colors you can set for the markers. https://github.com/kitoban/EnhancedNavBall/blob/master/EnhancedNavBall/Config/NavballSettings.cs UNless I need more coffee.
  20. Yeah, assuming my next playthrough goes without major issues, I'll be publishing an updated release soon. Maybe this weekend. hard to say, ofcourse. Feel free to use any of the bits you like, you won't step on my toes.
  21. If that part of code didn't change in your version, I had a check for containers. If there are no containers onboard, then the addon would not run anything, since there was no place to store, and the logic to figure out which experiment to run of duplicate experiemnts would get nasty very quickly. Which is also a reason why I didn't run goo/scijrs either. The pad, and various other places, mostly around ksc that I know of are special biomes that aren't reported in the same way as science biomes. The strings don't match basicly. They aren't even listed in the science definitions that I could fine. I have a mostly working update soon that include MUCH improved detection of these special cases. This is related to the above issue, but also the VERY MANY transient states that the vessel passes. The next version should have some basic protection against transient states. Also, having a scientist onboard will reset experiments automatically! I'm not sure yet if I'll be able to add lab logic yet, because honestly, I don't understand it yet. And using a transmitter for probes is on the radar as well. I'm not sure I'll delay the update for those features though.
  22. I had a quick gander, and I didn't see where you registered the toolbar load and unload. They changed the way toolbars are loaded and destroyed in 1.0 (or rather, when certain events that were commonly used to fire off toolbar registration). I'm using awake() and destroy(), respectively.
  23. Contracts.ContractSystem.GetCurrentContracts()? Idk, I just did a search in the references. There is no mention in the community docs from what I could see.
  24. Maybe this is related to the problem I was having with the tech tree the other night. I could go to the rd building, open the cheat menu and unlock every node and add every part with the nifty new buttons, and save it, but as soon as I left the building, all the changes would be lost.
×
×
  • Create New...