TS2014 triggering audio in scenario?

Trains and Routes only entertain so far, what you need are engaging and entertaining scenarios. Here's where you can learn how to make bigger, better scenarios and really bring your virtual train world alive.

Moderator: Moderators

User avatar
chrisell
Well Established Forum Member
Posts: 533
Joined: Mon May 06, 2002 12:00 am
Location: England, Holland and America
Contact:

TS2014 triggering audio in scenario?

Post by chrisell »

I remember reading on one of the Engine Driver blog entries that the new scenario editor could trigger events (finally). I've got triggered cinematic cameras working but I remember reading that we'd be able to trigger audio events too. Has anyone managed this yet? I'm guessing it's the same method as the cameras but I can't figure out what the syscall would be to do it.

For example

Code: Select all

SysCall ( "CameraManager:ActivateCamera", "IntroCam", 0 );
is used for activating a cinematic camera. But what's the equivalent for a sound, and how / where is the sound stored?
vtrainRW3
Getting the hang of things now
Posts: 46
Joined: Wed Nov 02, 2011 10:21 pm

Re: TS2014 triggering audio in scenario?

Post by vtrainRW3 »

Hello Chris,

I have not managed to work out the code for audio but did find the code for video on the internet.

http://www.simflight.com/2013/08/15/mor ... ies-added/


SysCall ( "ScenarioManager:PlayVideoMessage","small.ogv",0,1,0,0); works for video

I tired the following but does not produce any errors or sound.
Really a guessing game at the moment till RSC write more documentation
Logmate does not show any errors for LUA so its hard to to tell if the syntax is wrong.
SysCall ( "ScenarioManager:PlaySoundMessage","small.dav",1);

Hope that helps

vtrain
User avatar
chrisell
Well Established Forum Member
Posts: 533
Joined: Mon May 06, 2002 12:00 am
Location: England, Holland and America
Contact:

Re: TS2014 triggering audio in scenario?

Post by chrisell »

I saw the 'PlayVideoMessage' function when I went digging through the code but couldn't see anything specific to audio. Also it's not entirely clear how to display HTML messages. The function is there, but it needs a long string of gobbeldegook in the function which looks like the path to the route, but isn't. Neither is it the path to the scenario itself, so simply dumping the HTML file in the folder with the scenario script doesn't work.

Point of note : PlayVideoMessage also appears to be looking in some divine location because it too fails when you put the OGV file in the same folder as the scenario script.

I wish RSC would give third party devs some documentation (other than the stuff they wrote in '08). Having to figure everything out using ouija boards and fairy dust isn't the way to support the people who support their product. :x
RudolfJan
Well Established Forum Member
Posts: 523
Joined: Thu Oct 18, 2007 6:40 pm

Re: TS2014 triggering audio in scenario?

Post by RudolfJan »

chrisell wrote:I saw the 'PlayVideoMessage' function when I went digging through the code but couldn't see anything specific to audio. Also it's not entirely clear how to display HTML messages. The function is there, but it needs a long string of gobbeldegook in the function which looks like the path to the route, but isn't. Neither is it the path to the scenario itself, so simply dumping the HTML file in the folder with the scenario script doesn't work.

Point of note : PlayVideoMessage also appears to be looking in some divine location because it too fails when you put the OGV file in the same folder as the scenario script.

I wish RSC would give third party devs some documentation (other than the stuff they wrote in '08). Having to figure everything out using ouija boards and fairy dust isn't the way to support the people who support their product. :x
Hi Chris,

For the HTML file you should create a subfolder in the scenario folder, reflecting the language, e.g. En for English. You need to place the HTML file in that folder. The GUID string just refers to the name of the scenario directory. I am experimenting with scripting, and I create a variable ScenarioId= ....
Then I use that in the code.

Maybe its possible to use the HTML sound functions inside the HTML. I will try some day ...

Without any documentation and only some examples it's quite hard to use the promised new features.
Rudolf

http://www.hollandhiking.nl/trainsimulator
Here you will find the latest version of the Senario Authors Guide, TSW starters Guide, LuaCreator and TSWTools and more ...
vtrainRW3
Getting the hang of things now
Posts: 46
Joined: Wed Nov 02, 2011 10:21 pm

Re: TS2014 triggering audio in scenario?

Post by vtrainRW3 »

Hi Chris,

Here is how I got video and html messages working.
This is based on the Horseshoe curve route and how RSC setup scripting for this route.

1) The html messages appear in a folder called En. This sits under the main scenario folder.
Sample file
<HTML>
<BODY BGCOLOR="#0000007F">
<FONT COLOR="#FFFFFF" FACE="Arial" SIZE="4">

<TABLE>
<TR valign="top">
<TD><img src="../sample1.png" alt="" width="256" height="256" /></TD>
<TD>
<FONT COLOR="#FFFFFF" FACE="Arial" SIZE="4">
<P>"Text Here"</P>
<P>"or Here"</P>
<P>"Or Here"</P>
</FONT></TD>
</TR>
</TABLE>
</FONT>
</BODY>
</HTML>

The img source points to the main scenario folder so any images must go into the scenario main folder and not the En folder.
Video ogg files need to sit in the En folder. Only image files that work seem to be png (tried Gif and jpeg don’t work).

2)The script files called scenarioscript.lua must live under the main scenario folder. luac is the compiled script.

3) In TS14 create any scenario type you want and add a driver to the stock you want the message to appear for.
Add a trigger event to this train with the default 00:00 time. Give this a name in the event trigger e.g. "StartCam".
This name will appear in the script file as well and seems to be case sensitive. Create a cinematic camera from the miscellaneous section.
Name the camera the same as the trigger event name "StartCam". There is an Object name box. Set the camera offset to 5-10 seconds and add another cinematic camera by clicking the Add control point button (Orange triangle with green cross). This adds another camera to track to.

4) Click the Script button. Next to the red flag and then click reload. This should open the script file provided it is present in the scenario folder. Will error if not found.
You can click the open folder button to open the folder to view/edit the script file.


Looking at the script and a sub section:-

------------------------------------------------
-- Fn OnEvent
-- event - name of the event
-- return - TRUE/FALSE if event handled
function OnEvent ( event )

-- Timed triggers
---------------------------

if event == "StartCam" then -- Pan around at train

SysCall ( "ScenarioManager:ShowInfoMessageExt", "495d441f-631b-4a27-a99d-578af014e436", "TPC-01.html", 20, MSG_LEFT + MSG_TOP, MSG_REG, FALSE );
SysCall ( "CameraManager:ActivateCamera", "StartCam", 0 );
SysCall ( "CameraManager:ActivateCamera", "Getsite", 0 );

return TRUE;

You can see the "StartCam" trigger event and a ScenarioManager:ShowInfoMessageExt function call.

"495d441f-631b-4a27-a99d-578af014e436" is a subkey generated from the string window. Click the strings button next to the script button.
You will see 2 sections a Key and a string section. These will be blank. Click the add string button and a new key will be generated. Of the same format as the scenario folder and scenario name. Carefully copy this string by selecting and copying and paste into the script file as shown above. I say carefully as the text box can obscure extra characters and will only copy what is visible on screen. Ensure you expand the box. Next in the strings box place the html file name e.g. TPC-01.html. Then click the close button. Or Add more key/strings if you need. You can also enter text in quotes and this will display as well.

Next click the script button and click reload (optional) then click the Compile/Generate MD5 button. This will generate the LUAC script and MD5 files.

Then just press play and the camera and message should display.
For video add the following line.
SysCall ( "ScenarioManager:PlayVideoMessage","0001-0250.ogg",0,1,0,0);
Ensure the ogg file is in the En folder. The various 0,1,0,0) seem to control things like video screen size, playback with sound, and if the script waits for the video to play first then continues.


Hope that helps I am still playing with this myself but that is what I found.

Image
Naming trigger event

Image
String ceation
Image
En folder
Image
Cinematic camera settings


full script

-----------------------------------------------
-- ScenarioScript.lua
-- 24/09/2014
-- Copyright 2014 RailSimulator.com ltd
--
-- Scenario Script WCMLN - 'Flying Camera - Thunderbirds Away'
------------------------------------------------

-- true/false defn
FALSE = 0
TRUE = 1

-- condition return values
CONDITION_NOT_YET_MET = 0
CONDITION_SUCCEEDED = 1
CONDITION_FAILED = 2

-- Message types
MT_INFO = 0 -- large centre screen pop up
MT_ALERT = 1 -- top right alert message

MSG_TOP = 1
MSG_VCENTRE = 2
MSG_BOTTOM = 4
MSG_LEFT = 8
MSG_CENTRE = 16
MSG_RIGHT = 32

MSG_SMALL = 0
MSG_REG = 1
MSG_LRG = 2

------------------------------------------------
-- Fn OnEvent
-- event - name of the event
-- return - TRUE/FALSE if event handled
function OnEvent ( event )

-- Timed triggers
---------------------------

if event == "StartCam" then -- Pan around at train

SysCall ( "ScenarioManager:ShowInfoMessageExt", "495d441f-631b-4a27-a99d-578af014e436", "TPC-01.html", 20, MSG_LEFT + MSG_TOP, MSG_REG, FALSE );
SysCall ( "CameraManager:ActivateCamera", "StartCam", 0 );
SysCall ( "CameraManager:ActivateCamera", "Getsite", 0 );

return TRUE;

end

Vtrain
User avatar
chrisell
Well Established Forum Member
Posts: 533
Joined: Mon May 06, 2002 12:00 am
Location: England, Holland and America
Contact:

Re: TS2014 triggering audio in scenario?

Post by chrisell »

Thanks for the comprehensive write-up. I'd got cameras working - just not figured out the HTML.
Hmm.

Can an OGV contain just audio I wonder?
elbasco
New to the Forums
Posts: 3
Joined: Fri Nov 08, 2013 9:22 pm

Re: TS2014 triggering audio in scenario?

Post by elbasco »

I think I understand how to activate a cinematic camera with a trigger event, I have managed to place the starting point for a camera, but I cannot for the life of me work out how to place the location for the camera to fly to.

Any ideas?

Thanks.
User avatar
chrisell
Well Established Forum Member
Posts: 533
Joined: Mon May 06, 2002 12:00 am
Location: England, Holland and America
Contact:

Re: TS2014 triggering audio in scenario?

Post by chrisell »

elbasco wrote:I think I understand how to activate a cinematic camera with a trigger event, I have managed to place the starting point for a camera, but I cannot for the life of me work out how to place the location for the camera to fly to.

Any ideas?

Thanks.
Check my post midway down this topic - it might help : http://forums.uktrainsim.com/viewtopic. ... 6&t=126023
elbasco
New to the Forums
Posts: 3
Joined: Fri Nov 08, 2013 9:22 pm

Re: TS2014 triggering audio in scenario?

Post by elbasco »

>it might help

Yes it does! Thank you.

I've managed to place a second camera for a second reference point, and pressing the "play" button in the object definition dialog makes it fly from the first to the second.
It just doesn't work in the scenario ... yet!
But progress is being made. Thank you.
elbasco
New to the Forums
Posts: 3
Joined: Fri Nov 08, 2013 9:22 pm

Re: TS2014 triggering audio in scenario?

Post by elbasco »

Placing the second camera, as a part of the first camera seems to be the trick. Then move the second camera position to where you want the view to fly to.
Set the script for teh event to match the trigger name to match the camera name, and now it works!

Thanks for your help.
Cheers.
User avatar
chrisell
Well Established Forum Member
Posts: 533
Joined: Mon May 06, 2002 12:00 am
Location: England, Holland and America
Contact:

Re: TS2014 triggering audio in scenario?

Post by chrisell »

Glad I Could help :)
Friedy
Getting the hang of things now
Posts: 16
Joined: Mon Jun 30, 2008 1:21 am
Location: Fairport, New York USA

Re: TS2014 triggering audio in scenario?

Post by Friedy »

Returning to the original topic of this thread:
Triggereing audio in a scenario - yes it is possible, but currently I have discovered no straight forward way. In the development of Stevens Pass route the GNTX team wanted to implement "talking" DED's ( Dragging Equipment Detectors ) which would report via audio the status of a passing train. We were able to accomplish this by doing a "work-around" using the weather pattern extension blueprint which can can called via a .LUA script. This blueprint can, in turn, call the generic audio controller, which can then play a .dav audio file.
The steps involved take several pages to document and we ( the authors of Stevens Pass ) are currently developing a "how to do it" document.
For those who like to find out things on your own : Here is how I figured it out. I noticed that the development of the Thunderstorms in a scenario for the Sherman Hill route, was triggered by the passage of a scenario marker. This event was both audio and visual. Reasoning that the sound of a thunderstorm must be an audio file, I investigated how the authors did it.

While not perfect, the result is not dependent on the situation and can be used to play any sound file at a given scenario "stop at destination", "tigger", or "add to ..." instruction in a scenario script.
If this posting develops any interest, I will post a URL to the document when it is finished.
User avatar
chrisell
Well Established Forum Member
Posts: 533
Joined: Mon May 06, 2002 12:00 am
Location: England, Holland and America
Contact:

Re: TS2014 triggering audio in scenario?

Post by chrisell »

Ah yes. Good idea. I'd been digging around in that same scenario a while back looking at the custom weather setup but it never occurred to me that it could also be used to trigger audio.
User avatar
chrisell
Well Established Forum Member
Posts: 533
Joined: Mon May 06, 2002 12:00 am
Location: England, Holland and America
Contact:

Re: TS2014 triggering audio in scenario?

Post by chrisell »

In case anyone has more ideas, I'm messing around with this right now trying to find the magic format of command to make it work ...

SysCall ( "ScenarioManager:PlayDialogueSound","message1.dav");

Got nuthin. No errors, no sounds, nothing in logmate. There HAS to be a way to make the bloody thing play just a sound ....
nschichan
Been on the forums for a while
Posts: 135
Joined: Thu Sep 15, 2011 10:52 pm

Re: TS2014 triggering audio in scenario?

Post by nschichan »

chrisell wrote:In case anyone has more ideas, I'm messing around with this right now trying to find the magic format of command to make it work ...

SysCall ( "ScenarioManager:PlayDialogueSound","message1.dav");

Got nuthin. No errors, no sounds, nothing in logmate. There HAS to be a way to make the bloody thing play just a sound ....

Hi Chrisell,

I finaly took the time to have a look at the PlayDialogueSound Function, with good results I guess:

- The file is looked up relative to Content/Routes/<route-uuid>/Scenarios/<scenario-uuid>/en/. You can escape from that path using the appropriate number of "../" sequence at the beginning of the path.

- For some reason underscore in the file name seem to result in the file being ignored.

- The file must be in the wav format (that is not the encoded form that use in other parts of the sim).


Unfortunately, there are no traces in logmate when the file is not found.

Regards,
--
nschichan
Locked

Return to “[TS] Scenario Creation”