Automatic ignition when blade is NOT detected (for crystal chamber)

I’m building my first removable crystal chamber chassis and was planning to use blade_detect to have a different selection of fonts/effects when the chassis is out. What I was also hoping was to automatically ‘ignite’ the blade when the chassis is pulled out so I can have the hum sound effect playing immediately as the chassis is removed. Think the sound that plays every time the Tesseract is taken out of a box in the MCU movies.

I tried calling On() in the prop file after the blade detect returns false but that didn’t work.

Any thoughts or suggestions?

I’d say take a peek at how blaster.h works … that defaults to On.
Busy at the moment but can dive in deeper a bit later if still want another pair of eyes on it.

1 Like

Thanks, I’ll check that out

  // Pull in parent's SetPreset, but turn the blaster on.
  void SetPreset(int preset_num, bool announce) override {
    PropBase::SetPreset(preset_num, announce);
      if (!SaberBase::IsOn()) {
        On();
      }
  }

I wonder if it might not be better to do it in the blade detect event:

      case EVENTID(BUTTON_BLADE_DETECT, EVENT_LATCH_OFF, MODE_ANY_BUTTON | MODE_ON):
      case EVENTID(BUTTON_BLADE_DETECT, EVENT_LATCH_OFF, MODE_ANY_BUTTON | MODE_OFF):
        // Might need to do something cleaner, but let's try this for now.
        blade_detected_ = false;
        FindBladeAgain();
        SaberBase::DoBladeDetect(false);
        if (!IsOn()) On();  // Added this line
        return true;

If you do do it in SetPreset, you also need to check blade_detected_, like:

  // Pull in parent's SetPreset, but turn the blaster on.
  void SetPreset(int preset_num, bool announce) override {
    PropBase::SetPreset(preset_num, announce);
    if (!blade_detected_ && !IsOn()) On();
  }

I did try in the blade detect event, just as you have there and for whatever reason it didn’t work. Once I’m done installing and testing that blade detect works as expected, I can circle back to the code.