This is fun.
https://chat.openai.com/
Here’s what I pasted from my blaster prop and the response it gave:
void Loop() override {
PropBase::Loop();
PollNextAction();
sound_library_.Poll(wav_player);
if (wav_player && !wav_player->isPlaying()) wav_player.Free();
STATE_MACHINE_BEGIN();
while (true) {
if (auto_firing_) {
tmp = GetWavPlayerPlaying(&SFX_auto);
// Set the length for WavLen<>
if (tmp) {
tmp->UpdateSaberBaseSoundInfo();
} else {
SaberBase::ClearSoundInfo();
}
if (millis() - auto_time_ > 1000 * tmp->length()) {
shots_fired_++;
auto_time_ = millis();
STDOUT << "AUTOFIRING - Remaining shots = " << GetBulletCount() << "\n";
CheckEmpty();
if (empty_) {
SaberBase::DoEndLockup();
SaberBase::SetLockup(SaberBase::LOCKUP_NONE);
auto_firing_ = false;
return;
}
}
}
YIELD();
}
STATE_MACHINE_END();
} void Loop() override {
PropBase::Loop();
PollNextAction();
sound_library_.Poll(wav_player);
if (wav_player && !wav_player->isPlaying()) wav_player.Free();
STATE_MACHINE_BEGIN();
while (true) {
if (auto_firing_) {
tmp = GetWavPlayerPlaying(&SFX_auto);
// Set the length for WavLen<>
if (tmp) {
tmp->UpdateSaberBaseSoundInfo();
} else {
SaberBase::ClearSoundInfo();
}
if (millis() - auto_time_ > 1000 * tmp->length()) {
shots_fired_++;
auto_time_ = millis();
STDOUT << "AUTOFIRING - Remaining shots = " << GetBulletCount() << "\n";
CheckEmpty();
if (empty_) {
SaberBase::DoEndLockup();
SaberBase::SetLockup(SaberBase::LOCKUP_NONE);
auto_firing_ = false;
return;
}
}
}
YIELD();
}
STATE_MACHINE_END();
}
“This code is part of a loop function that is responsible for managing the state of an automatic firing mode in a device, such as a lightsaber soundboard. The loop function checks if automatic firing is currently enabled, and if so, it plays a sound effect for each shot fired and updates the number of remaining shots. It also checks if the device has run out of shots, and if so, it disables the automatic firing mode and performs any necessary cleanup. The code uses a StateMachine object to manage the state transitions and wait for the appropriate time to take a new action. It also uses a wav_player object to play sound effects and a sound_library_ object to manage the available sound effects.”