Quick scripting question

General discussion about Train Simulator, your thoughts, questions, news and views!

Moderator: Moderators

Locked
JasVick
Been on the forums for a while
Posts: 241
Joined: Wed Jun 25, 2008 9:22 am

Quick scripting question

Post by JasVick »

Hi folks,

Does anyone know how I could use a variable to play a sound? What I'm looking at doing is for example if I have a command that says message1 = message1 +1, how do I script the line to play the new total of message1 as its new value in a wav file?

As an example, message1 = 1000, play 1000.wav, add 1 to messsge1, it would play 1001.wav etc?

I know that you can directly play wav files through scripting but don't know how to format the command to play the numbered value.

Also, in scripting is there any way that you can force a basic keyboard input from the user which then carries on with the scenario at the time, so that for example an input could be requested to set message1?

Any help on this would be very much appreciated!

Thank you!
User avatar
DaveDewhurst
Very Active Forum Member
Posts: 1994
Joined: Wed Nov 28, 2007 10:21 am
Location: Birkenhead
Contact:

Re: Quick scripting question

Post by DaveDewhurst »

Using tostring()
http://www.gammon.com.au/scripts/doc.php?lua=tostring
and concatenation ..
https://www.lua.org/pil/3.4.html

You should be able to get the desired outcome

Dave
JasVick
Been on the forums for a while
Posts: 241
Joined: Wed Jun 25, 2008 9:22 am

Re: Quick scripting question

Post by JasVick »

Thanks for reply!

Will have a look and see what I get.
Does anybody have any ideas on the input sequence and weather it would work in ts loco or scenario scripting?

Many thanks for any reply...
Locked

Return to “[TS] General Discussion”