Jump to content

[Resolved] Hang with KSPEvent in 1.2


Recommended Posts

I've been keeping the AviationLights mod working for a couple of KSP revisions now.  It has the following code in it to allow the user to toggle light modes:

        [KSPEvent(name = "FlashEvent", active = true, guiActive = true, guiName = "Flash")]
        public void FlashEvent()
        {
            _lastTimeFired = 0;

            if (navLightSwitch == 1)
                navLightSwitch = 0;
            else
                navLightSwitch = 1;
        }

        [KSPEvent(name = "DoubleFlashEvent", active = true, guiActive = true, guiName = "Double Flash")]
        public void DoubleFlashEvent()
        {
            _lastTimeFired = 0;

            if (navLightSwitch == 2)
                navLightSwitch = 0;
            else
                navLightSwitch = 2;
        }

        [KSPEvent(name = "IntervalEvent", active = true, guiActive = true, guiName = "Interval")]
        public void IntervalEvent()
        {
            _lastTimeFired = 0;

            if (navLightSwitch == 3)
                navLightSwitch = 0;
            else
                navLightSwitch = 3;
        }

        [KSPEvent(name = "OnEvent", active = true, guiActive = true, guiName = "Light")]
        public void OnEvent()
        {
            _lastTimeFired = 0;

            if (navLightSwitch == 4)
                navLightSwitch = 0;
            else
                navLightSwitch = 4;
        }

 

Which worked in KSP 1.1.3.  In KSP 1.2, the game hangs.  I tried renaming the methods, and I sprinkled a few more of the fields from KSPEvent, so it looked more like this:

[KSPEvent(name = "LightFlashEvent", advancedTweakable = false, guiActiveUncommand = false, requireFullControl = false, active = true, guiActive = true, guiName = "Flash")]

 

But that didn't fix it.  Can someone tell me what else do I need to update for this to work in KSP 1.2?  The plugin works if I use the KSPAction fields to set it up.  The KSPAction fields are simply wrappers to call these methods, so my suspicion is that something is different about KSPEvent that I need to account for.

EDIT: To clarify "Which worked in KSP 1.1.3.  In KSP 1.2, the game hangs": when the user right-clicks on one of the lights in the Flight scene, it used to bring up the context menu, which allowed the user to select one of those modes.  In KSP 1.2, when the user right-clicks on the light, the game hangs.

EDIT 2: RPM uses KSPEvent, and it's not crashing, so there must be something else going on with either the model or the config - I also notice that the part highlighter doesn't highlight the aviation light when I hover the mouse over it in flight.

EDIT 3: No, it's something in the Module that's causing the problem.  If I remove ModuleNavLight, I can fly the mouse over the part without a problem.  With ModuleNavLight, as soon as I fly the mouse over it, the game hangs.  Urk.

Edited by MOARdV
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...