I have a trigger button on my dashboard that I use to mute/unmute my shaker profile during caution laps and green laps. How can I handle this in code so that it automatically mutes/unmutes whenever these flag events occur?
No need for a button. This can be handled with custom events in an existing or new .ini file in the c:\Program Files (x86)\SimHub\NCalcScripts folder. Mappings to triggers can then be created for these events in "Controls and events".
Custom events:
[ExportEvent]
name='ShakerOn'
trigger=[DataCorePlugin.GameRunning] and ! [DataCorePlugin.GameData.Flag_Yellow] and [ShakeITBSV3Plugin.GlobalGain] != '85'
[ExportEvent]
name='ShakerOff'
trigger=[DataCorePlugin.GameRunning] and [DataCorePlugin.GameData.Flag_Yellow] and [ShakeITBSV3Plugin.GlobalGain] = '85'
Event Mappings:
ExternalScriptShakerOn -> ShakeITBSV3Plugin.ToggleMuteFeedback
ExternalScriptShakerOn -> ShakeITBSV3Plugin.MainFeedbackLevelIncrement (changes the Global Gain to 85 from 84 to signify unmuted)
ExternalScriptShakerOff -> ShakeITBSV3Plugin.MainFeedbackLevelDecrement (changes the Global Gain to 84 from 85 to signify muted)
ExternalScriptShakerOff -> ShakeITBSV3Plugin.ToggleMuteFeedback
Note
Due to the absence of a Global Gain Muted property (as far as I know), the ShakeITBSV3Plugin.GlobalGain value is used to determine if the Global Gain is muted or not. '85' is just a placeholder for whatever your default global gain is set to. If you ever adjust this value from whatever the value is in your custom events, then the events will not fire.