Jump to content

Tahvohck

Members
  • Posts

    80
  • Joined

  • Last visited

Everything posted by Tahvohck

  1. I've updated this to work on RPM 0.17 (Changing the pointers to the basic RPM props, if anyone was wondering: they're no longer an "example" prop but are now part of a basic resource library) and uploaded it for anyone interested here. I didn't see a license on the first page but there was a fan edit, so I'm unsure of the legality of this. If there's a problem let me know and I'll remove the link. If there's interest and WaRi doesn't get to it before me, I'll do the same for his edit. (Pending it being okay that I do that as well) Oh, also also, the camera FOVs on this are kind of absurdly small--or at least they don't remotely match up with the VAB/SPH preview--that's something else I've fixed in my personal copy but not the uploaded one. For the definition of "fixed" being bumped it from 30° to a guesstimate of 45° for the preview size (and 7 5° zoom steps). Anyone wants that and doesn't know how to do it on their own, let me know.
  2. Start() is actually a better place to put it all, I'd argue, because then you know for a fact everything else has at least initialized. And the massive amount of events is what I'm counting on. Thanks for the isEva note! That'll make my life all sorts of easier. Now I just need to figure out the proper syntax for dynamic resource adding. Oh, so that was part of my problem... don't use static in GameEvent, noted. Alright then, now that I've got it working... time to rewrite all my code! D: Figures that this'd make me have to restructure it.
  3. Also of note (here's expecting this to show up before my other reply, but whatever) is that last time I tried to use Lambda functions, KSP wigged out and (I think? Don't remember the specific error) started throwing null references like crazy. //sumOxygen = connectedOxygen.Sum(res => res.amount); //sumCO2 = connectedCO2.Sum(res => res.amount); //sumWater = connectedWater.Sum(res => res.amount); //sumSnacks = connectedSnacks.Sum(res => res.amount); Commented out because I want it in there as reference and am using a different (more expensive?) method instead. Supposedly Kethane used this method to sum the resources on the ship, but like I said it's not working for me.
  4. Hi, thanks for being condescending! That was rude, but in fairness, so was your reply. I did do research, and while I saw the Add() function, and did in fact assume it was for adding code, only onHideUI has the type EventVoid. OnVesselChange has type <Vessel>, on both its Add() and its definition, yet this code: //inside another function GameEvents.onVesselChange.Add(HOOK_VesselChange); public static Vessel HOOK_VesselChange() { print("Vessel changed."); return FlightGlobals.ActiveVessel; } refuses to compile, with the error "The best overloaded match for 'EventData<Vessel>.Add(EventData<Vessel>.OnEvent)' has some invalid arguments" and as someone relatively new to passing functions as variables, that doesn't help at all. That's not even mentioning the more complex onCrewOnEva(), which has the type <GameEvents.FromToAction <Part, Part>> or the fact that I don't want most of the code I'll be calling on these events to have to return the expected type just to get it to work, which is what the documentation is implying I'd have to do (to me, at least). ... Of course, after a bit more fiddling around, I realize that the event is passing said types to the function, not expecting it of them; but still, while I'm glad for the help you could have done it in a kinder way. For anyone having the same problem I was having, and using the example above, this is what you'd do: //inside another function GameEvents.onVesselChange.Add(HOOK_VesselChange); public static void HOOK_VesselChange(Vessel v) { print("Vessel changed."); }
  5. I've searched around a bit (probably not enough), but I can't find anything dealing with how to use events that aren't override-able based on the class you extend--that is, I can override, for example OnFixedUpdate on a PartModule just fine, but don't know how to get access to, say, OnVesselChange--so I've given up searching for now and decided to just ask. I know that the GameEvents class has a list of all the events, but I don't know how to register code to them. (I'll admit, I'm new to C#, so this may be where I'm going wrong.) I'm currently extending MonoBehaviour and I want to access, among others, these events: OnVesselChange onCrewOnEva onCrewBoardVessel onHideUI onJointBreak onPartCouple Should I change what I'm extending, or is there a way (delegates come to mind, but I don't see how to make those work) to register a method to the event so I don't have to override it?
×
×
  • Create New...