Jump to content

SixHourDays

Members
  • Posts

    27
  • Joined

  • Last visited

Everything posted by SixHourDays

  1. @xEvilReeperx I am adding my own unique KSPEvents via ModuleScienceHelpers, in addition to the supressing/altering/replacing my targets KSPEvents as I described above :-( Good suggestion though. Thanks to everyone who's helping out! We're almost there folks - I just need a way to erase that MODULE configNode from the parent. Does Part or Vessel have some equivalent to OnSave like PartModule does? All I need is access to the ConfigNode's above my PartModule....I'd settle for the whole Part, the whole Vessel...anything? (btw I'm still working, I'm replying when I can)
  2. I agree, hence wanting the parent, so I can remove that. @Crzyrndm - I could do that, but I'm left in the same predicament if you leave the flight scene (and thus save) with Kerbals on EVA. They would save out my helpers still - this kind of duality dealing with Kerbals in one way and ships another was what drove me to attempt a single solution to begin with.
  3. I have ModuleScienceHelper part modules, and necessarily so. I create one whenever I detect existing ModuleScienceContainers or ModuleScienceExperiment modules in parts, and my module targets that. So every ModuleScienceContainer has a ModuleScienceHelper dealing with it, and similarly for the experiments. To be clear - my mod is partless; I'm altering existing parts behaviour, not adding new ones. The ModuleScienceHelper modules exist to supress / mess with the target right click events (changing descriptions / visibility), and they also usurp those events with their own versions so I can get a notification of the right click event. For example: for containers, I'm surpressing the ReviewData KSPEvent in the original module, providing my own identical looking version, and when my version is clicked, it notifies my mod and then passes through the call to the original containers handler method. I've done it that way because some things in KSP just don't have an event, and I need a notify when those things happen. Probably not. It solves the issue of stuff saving out, but I lose the ability to provide my own KSPEvents etc, which I need. Furthermore - by using my pairwise helper modules whenever I find parts with my desired targets (ModuleScience[Container/Experiment]), I'm hoping to work with other mods more easily - as long as their crazy new parts have my target part modules, I'll find them, pair up helpers, and all should go smoothly. Tbh though that's more of a future concern...solely considering working on stock 1.0.5 atm. Let's talk about OnSave. It appears that the whole contents of my PartModule is present in the ConfigNode passed to me. Can I literally just erase all of it? If I can somehow get the parent ConfigNode, erase the child (my partmodules MODULE section), would that save out as if my part module doesn't exist in the ship? Ideally that's what I'd like - keep my PartModules, and have them never save to disk.
  4. Hey everyone, How can I prevent a PartModule from saving entirely? Mine are completely stateless, but there can be a lot of them; I'd like to not clutter up saves. Longer explanation - I originally used ModuleManager to add these modules to ships - but I discovered that EVA Kerbals are immune to ModuleManager. So I switched to scanning ships in the scene myself, and adding my helper modules to them in OnAwake. However - on reload of ships that have saved them out, all the mismatched module indices make a lot of warning spam. As always - any help is appreciated!
  5. Here we are, and I'm days away from releasing an alpha...and of course one final, snarly problem comes up. Two parts: Is it possible to stop a lab copy that is mid-progress? I've tried using IEnumerator x = someLab.ProcessData(...); myMonoBehaviour.StartCoroutine(x); or Coroutine x = myMonoBehaviour.StartCoroutine( someLab.ProcessData(...) ); either way, sometime later myMonoBehaviour.StopCoroutine( x ) //doesn't stop it :-( Neither seem to stop the lab process - progress prints keep streaming. I can't use the string versions as I have to pass parameters to the coroutine itself function. Is it possible to stop a result transmission? I call ModuleDataTransmitter.StopTransmisison(), which does stop the transmit, but seems to leave the antenna in an unusable state afterward. Further calls to ModuleDataTransmitter.TransmitData(...) do nothing. PS - you folks have been really great, I wouldn't be about to release without you! I literally have learned Unity and KSP from scratch via the hundreds of pages of guidance I've found here. Grateful hugs for all!
  6. Ahhhhh ok then! <FeelsGood.gif>! That's the second stock bug I've bumped into and thought was mine. Thanks for the bug tracker link.
  7. My PartModules don't implement OnDestroy. I'm working off of KSP 1.04 (I'll upgrade when I've stabilized things), and it's completely stock, short of my mod. I have one additional piece of info - it only happens if the Kerbal boards and they've got science on them. Which...makes me sad cause it's probably my bug then (my mod deals in shoving around science). Still, unsure how altering kerbal science would affect the collision stuff.
  8. This has started popping up whenever I board an eva Kerbal back into a ship...and I don't know why. [EXC 20:56:06.040] InvalidOperationException: Collection was modified; enumeration operation may not execute. System.Collections.Generic.List`1+Enumerator[UnityEngine.Collider].VerifyState () System.Collections.Generic.List`1+Enumerator[UnityEngine.Collider].MoveNext () Part.OnDestroy () My only thought is that I've used Part::AddModule("myModuleName") on the kerbalEVA part. I added three of my own PartModules that way - they're simple modules, nothing to do with collision, just messing with the PartModule::Events. Is it saying that I've altered the collection of Colliders by adding PartModules? That doesn't make any sense to me. Has anyone seen such an error before on EVA kerbals boarding craft / otherwise being destroyed?
  9. aaaaaaaand the lightbulb goes on (also after a significant sleep). Thanks for this, and the link - 'impossible' has now been explained into 'nefarious'.
  10. Summary: if you refer to a kerbalEVA vessel, then board said kerbal onto a craft, KSP appears to null out your reference on you. How can that be? k i'm pretty tired, and maybe my eyes are playing tricks....but I swear I just saw this happen in my Monobehavior. Please forgive the pseudocode, typing from memory. I have this field: Vessel m_shipRef = null; in Awake() I have GameEvents.OnVesselSwitch.Add( MySwitchHandler ); in MySwitchHandler(), I have Debug.Log(" ship was " + m_shipRef == null ? "null" : m_shipRef.ToString() ); m_shipRef = FlightGlobals.ActiveVessel; Debug.Log(" ship is " + m_shipRef == null ? "null" : m_shipRef.ToString() ); Now the test case - spawn a ship with a kerb in it. print will be "ship was null, ship is PartName (YourShipName) (Vessel)" - so far so good. then, eva the kerbal. print wlil be "ship was PartName (YourShipName) (Vessel), ship is kerbalEVA (Jebediah Kerman) (Vessel)" - again, all ok then, board the kerbal back onto the ship...the print will be "ship was null, ship is PartName (YourShipName) (Vessel)"! The "ship was x" section here should refer to jeb, not null. I've racked my brain and for the life of me can't figure out how that happens. nothing uses / refers to m_shipRef except the handler. Intuitively, KSP is destroying the 'kerbalEVA' ship when I board him, so I can see KSP cleaning up after itself internally. but how can KSP go null out my reference to the ship? I don't expect it in the scene anymore, but I do expect my C# reference to keep kerbalEVA alive until I drop it. Any ideas anyone?
  11. Like it says. I don't want to inherit the module class, or stop the original function..i want to piggyback it. I'd like to get a callback event when the Module gets theirs from a right click UI. Is that possible? I'd like to listen for ModuleScienceContainer::CollectDataExternalEvent, so I get notified when an EVA kerb takes the data from a container. Afaik no GameEvent goes off during that action. If I did subclass ModuleScienceContainer, and hid CollectDataExternalEvent with a wrapper implementation...the lack of virtual makes me fear it'll get called wrong from places I don't know about - and it seems like overkill just to observe. If someone knows a game event that _does_ go off during an EVA "take data", I'd love to hear it...
  12. Thanks so much! I didn't think Squad would make me put this in explicitly...foolish me. Your code looks about right, except the 'grounded' case should be Landed || Splashed for both if statements. Also, can I hug you? HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier has been sitting in my code as "float m_hackICantFind = 2f;" for about 3 months now! It feels SOOOO good to know where the blazes that number comes from, finally! Thanks so much for your help.
  13. Ah ModuleScienceLab, how you torment me so. I'd like to get the 'lab data points' for a particular ScienceData, but neither the ScienceData nor the ModuleScienceLab will provide it to me. [LIST] [*]KSP 1.0.4 [*]ship is a lab in orbit of Kerbin [*]1 scientist in the lab [*]we have a low-space goo Science Data [*]that data is in the Goo, and [I]has not[/I] been copied to the lab [*]there are no resource concerns: adequate power, lab has room to accept data, etc. [/LIST] The data is worth 20 pts of science, and 25 pts of 'lab copy data'. I'd like to programmatically get that 25. I checked the ScienceData.labValue (this seems like a relatively new member), but it's zero. I checked ModuleScienceLab.GetBoostForData(ScienceData d), but it's also zero. How can I retrieve the lab data points for a Science Data & Lab? PS - paging xEvilReeperx
  14. I don't know what evaOnlyStorage affects. But I can tell you that what you're irritated with (pointless EVA's to move science data around) is something I'll be solving in my upcoming mod, [B]WhichData[/B]! So sit tight, and you'll have a solution hopefully before xmas :-D
  15. THAT is the real answer! Thank you xEvilReeperx. I was calling ProcessData as a plain member function in my mod's update... calling it as a Coroutine works perfectly, including firing the OnComplete callback. In hindsight, the IEnumerator return type should have been the hint. My C# experience hadn't encountered Coroutines yet :-) Learn something new every day...
  16. Wow... I haven't done any ships with a lab since 1.02, and was just remembering it working correctly! Yet, I tested on 1.04 and so did my friend (unrelated save & PCs), and sure enough: http://bugs.kerbalspaceprogram.com/issues/5212 each and every time. Ok! Thank you jkortech. I'll update my post to the remaining question; why doesn't ProcessData work in the first place?
  17. EDIT2 answered (thanks xEvilReeperx!) ProcessData is meant to be used in a Coroutine, not called as a regular member function: StartCoroutine( myLab.ProcessData( myData, myDoneCallback) ); Read on for my big long sob story of doing it every which way except the right way (facepalm)... Hi. Grab a beer, pull up a bar stool. It's a long story, and I'm a little frustrated. I'm trying to automate some science features for my mod. One thing I'd like to do is make a data-research copy of a ScienceData using the MPL Lab via code. Now - this seems like the obvious choice to do that: public IEnumerator ModuleScienceLab::ProcessData( ScienceData item, Callback<ScienceData> onComplete ); except when I run it, nothing happens. No "Sending data to vessel labs.." etc print in the log, no top left green text running up a percentage complete, and the callback never fired. I provided a simple dummy print method callback, which never called (no print). Why doesn't this function work? Is a specific callback expected? EDIT1 - The following has been answered as a stock bug, thanks to jkortech. http://bugs.kerbalspaceprogram.com/issues/5212 Next up, we have the magic callback: public Callback<ScienceData> ExperimentResultDialogPage::OnSendToLab; Now this actually does work. However I don't like this route: you have to call a ReviewData N times for N IScienceDataContainers, to get a result page and therein a callback each, then fire said callbacks and dismiss the dialog yourself, while the user sees N dialogs flash by for 1 frame uninvited... ugh. It's abusing an entire dialog class just to get callback, and we're better than that, damnit. Ok, so lets get MacGyver: If we know that OnSendToLab works, and it's a callback, we can use reflection to see what it's calling, and we find it's actually a multidelegate calling - void ModuleScienceExperiment::sendDataToLab(ScienceData) - void ExperimentsResultDialog::dismissCurrentPage(ScienceData) ...which I don't see in the assembly object viewer in VS 2015. This leads me to think the delegates are calling private / hidden methods Squad doesn't want us using. So let's use those! Disclaimer: kids don't do this at home! Abusing reflection to access private methods of strange assemblies that can change at any moment is clearly a quick trip to brittle, breaky code. Beware. So we roll up our sleeves, remember some reflection code, and arrive here: Type modSciExperiType = Type.GetType("ModuleScienceExperiment, Assembly-CSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"); //grabbing types from assemblies other than yours needs fully qualified name MethodInfo privateMethodInfo = modSciExperiType.GetMethod("sendDataToLab", BindingFlags.Instance | BindingFlags.NonPublic); //specifically search for non-public instance methods to find hidden/private ones privateMethodInfo.Invoke(myLabModuleInstance, new object[] {myScienceData}); //invoke private method on an instance, passing a science data as a parameter Now, this actually works. You can directly call it on the module. It prints the "Sending Data to Vessel Labs..." print in log. The green progress text shows up top left. The data gets copied into the lab's research-data bank. But...it always ends the progress with the top left orange failure text "[MPL] not enough data storage...". Even when the lab clearly has enough storage for said data. And that's about when I rage quit. I can accept the brittle factor of using the private sendDataToLab; I feel like that functionality is what ProcessData should have given me to begin with. But spewing a failure message each time, I can't accept. Can RoverDude/NathanKell/Squad bretheren please read my plea, and explain to me what is happening? The function succeeds in every way - except throwing the fail message up to the player. I'm also open to unknown other ways to get the MPL to make a data-research copy of a ScienceData into an onboard MPL lab. <clink my beer to yours>As always, any help is appreciated. Thanks for reading.
  18. You were right! OnPartJointBreak fires even for the VAB dockingport undock case, first time, and every time after. Thank you. I'll edit the main post to answered.
  19. A side thought: in the VAB, you can attach any part to a docking port, and then undocking in game is a one way trip, releasing that stack permanently, and exposing the docking port for normal use. I wonder if that's the reasoning for this: easier to assume anything attached to the docking port is just a normal part being discarded, even if that part happens to be another docking port, appearing to be docked.
  20. I can tell you that onStageSeparation does not fire, and that onVesselWasModified does fire. When I get home I'll try out onPartJointBreak, and onVesselCreate. Can I ask what the 'normal' intention of onPartJoinBreak is? Struts snapping, parts cracking off others? Regardless, thanks for the suggestion :-)
  21. The only way I know of undocking is to right click the docking port, and select "Decouple Node" (or use an action group). Is there another way I'm oblivious to? If you mean code-undocking, that's not what I'm doing. This is all meant to capture normal-user-gameplay undocks. I agree with you, it seems that the VAB created docked ports behave different. The only GameEvent with "couple" anywhere in the name is public static EventData<GameEvents.FromToAction<Part, Part>> onPartCouple; which I have subscribed to, and am listening for. It fires during docking/redocking. I don't see a 'decouple' event anywhere in GameEvents.cs. Does anyone understand the nature of docking ports which were built docked to one another in VAB?
  22. Update! Here's a pic of the test ship I've registered for these events: GameEvents.onVesselWasModified.Add(OnVesselModified); GameEvents.onPartCouple.Add(OnPartCouple); GameEvents.onPartUndock.Add(OnPartUndock); GameEvents.onSameVesselDock.Add(OnSameVesselDock); GameEvents.onSameVesselUndock.Add(OnSameVesselUndock); GameEvents.onUndock.Add(OnUndock); I've discovered the following sequence of events occur: Undock the capsules: - OnVesselModified event x2 Redock the capsules: - OnPartCouple event - OnVesselModified event x2 Undock capsules again: - OnPartUndock event - OnVesselModified event x2 Redock the capsules again: - OnPartCouple event - OnVesselModified event x2 So, why doesn't OnPartUndock or OnSameVesselUndock fire during the first undock event? Why only on 2nd docking forward? I'm betting something about launching the ship with the two capsules docked counts as it all being one ship, until I split it with the first undock. But then I'd expect OnSameVesselUndock to cover that case... As always, any help is appreciated.
  23. Hi. I'm SixHourDays, and I'm a few months into my first plugin. This forum has been a goldmine of answers for SO MUCH of what I needed. So thank you! I'm looking for the specific GameEvents event for undocking. ANSWERED: onPartUndock fires for all undocking, except the first undock of something attached to them in VAB (including another docking port). Subsequent undockings of these ports will fire onPartUndock like usual. onPartJointBreak will fire for all undockings, even the aforementioned special case, on every try. ------------ The onPartUndock and onUndock events don't fire for me. //inside my plugin's Awake() GameEvents.onPartCouple.Add( MyDockEventHandler ); //this works fine for docking GameEvents.???.Add( MyUndockEventHandler ); //what do I subscribe my handler to? For the curious, I am unsubscribing from these same handlers in OnDestroy. Even more peculiar is most other events work. I readily get events for OnPartDie, OnExperimentDeployed, OnCrewTransferred, OnStageSeparate, etc. From the assembly info on GameEvents.cs, I see only these that I could use... public static EventData<Part> onPartUndock; //tried it, didn't fire public static EventData<GameEvents.FromToAction<ModuleDockingNode, ModuleDockingNode>> onSameVesselDock; //wrong (docking), and I want the two ship case public static EventData<GameEvents.FromToAction<ModuleDockingNode, ModuleDockingNode>> onSameVesselUndock; //I want the two ship case public static EventData<EventReport> onUndock; //tried it, didn't fire Thanks for anyone's help in this.
×
×
  • Create New...