Page 1 of 1

Quick scripting question

Posted: Thu Jul 07, 2016 4:41 pm
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!

Re: Quick scripting question

Posted: Thu Jul 07, 2016 7:19 pm
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

Re: Quick scripting question

Posted: Thu Jul 07, 2016 9:02 pm
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...