Add sound for idle?
 
Notifications
Clear all

Add sound for idle?

6 Posts
2 Users
1 Likes
1,212 Views
Elaphe
(@elaphe)
Eminent Member
Joined: 2 years ago
Posts: 18
Topic starter  

Hello. I would like to ask how I can make simhub play a sound when the car doesn't move from the start or the pits for a certain amount of time. It would be like a warning to tell the driver to move.


   
Quote
Elaphe
(@elaphe)
Eminent Member
Joined: 2 years ago
Posts: 18
Topic starter  

I have found this in Simhub / Available properties: DataCorePlugin.GameData.NewData.IsInPitSince

Now, what can I do with that?

Do I need to write something like

[DataCorePlugin.GameData.NewData.IsInPitSince] >10
"Target": "AudioControlPlugin.Play_mysound"

I am trying with the Ncal tester and the pit time counter works, but not the function to start the sound.

But where do I write it? The event window doesn't let write that. Maybe in a file?

 

This post was modified 2 years ago by Elaphe

   
ReplyQuote
(@romainrob)
Honorable Member
Joined: 4 years ago
Posts: 530
 

Hi, the function to trigger an action from a formula is triggeraction(actionName).
Here is an example:

if( isincreasing(1, blink(secondsbeeps, 500, 1))
,triggeraction( 'AudioControlPlugin.Play_beep-07') ,'')

If you'd rather use the event mapper, you can add custom events to the list with a NCalc script.
https://github.com/SHWotever/SimHub/wiki/NCalc-scripting


   
ReplyQuote
Elaphe
(@elaphe)
Eminent Member
Joined: 2 years ago
Posts: 18
Topic starter  

Your code must be wrong. If I paste it in the Ncalc tester it reports "Expression error: function not found. Parameter name: triggeraction"


   
ReplyQuote
(@romainrob)
Honorable Member
Joined: 4 years ago
Posts: 530
 

@elaphe It works on my end. You should ear the beeping when pasting the formula in the tester
triggeraction was added to SimHub nearly 2 years ago now.
What version of SimHub are you running?


   
ReplyQuote
Elaphe
(@elaphe)
Eminent Member
Joined: 2 years ago
Posts: 18
Topic starter  

Finally, after copying some examples and doing many tests I have been able to make this work. I have created a .ini file in the ncalcscripts folder with this content:

[ExportEvent]
name='LetsGoMrDriver'
trigger=if([DataCorePlugin.GameData.NewData.IsInPitSince]>20,1,0)

Then I created an event, selected the external event as source and the audio control plugin as target.


   
Romainrob reacted
ReplyQuote
Share: