Scripting camera.

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

Moderator: Moderators

Locked
SammytheShunter
Getting the hang of things now
Posts: 99
Joined: Sun Jan 02, 2011 1:47 pm

Scripting camera.

Post by SammytheShunter »

I'm hoping someone can advise me how to write a snippet of lua script that will force the sim to change to cabview? I want to include that in the relevant sections of the AWS script to throw me into the cabview the moment there is an AWS warning, in the same way that the sim forces cabview when entering a tunnel. I do tend to stray from the driver's seat at the wrong moments!

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

Re: Scripting camera.

Post by DaveDewhurst »

Somebody will correct me if I'm wrong but I was under the impression you can only control the camera with the scenario script, ie to make the flybys.
Pretty useless when AWS/DSD wirning can occur at any given time
Dave
nschichan
Been on the forums for a while
Posts: 135
Joined: Thu Sep 15, 2011 10:52 pm

Re: Scripting camera.

Post by nschichan »

SammytheShunter wrote:I'm hoping someone can advise me how to write a snippet of lua script that will force the sim to change to cabview? I want to include that in the relevant sections of the AWS script to throw me into the cabview the moment there is an AWS warning, in the same way that the sim forces cabview when entering a tunnel. I do tend to stray from the driver's seat at the wrong moments!

Many thanks

Hi,

You can use this SysCall:

Code: Select all

SysCall("CameraManager:ActivateCamera", "CabCamera", 0)
This works from an engine script. (I use it in an engine script to force the camera to the cab right after loading).

Regards,
--
nschichan
shanyiqua
Been on the forums for a while
Posts: 262
Joined: Tue Dec 20, 2011 11:48 am

Re: Scripting camera.

Post by shanyiqua »

Before the "toy train" interface came, the AWS and other warings are displayed on screen with a yellow backgrounded exclamation mark icon... but that have been removed, now only the toy train interface have something like that...

There is a better workaround for this:

These constants are need to be included at the start of the script

Code: Select all

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
And this call creates a message box.

Code: Select all

SysCall ( "ScenarioManager:ShowInfoMessageExt", "header text", "message text", 60, MSG_LEFT + MSG_TOP, MSG_SMALL, 0 );
The number 60 is probably the timeout of the message, but the user can close it earier by clicking on X.
User avatar
DaveDewhurst
Very Active Forum Member
Posts: 1994
Joined: Wed Nov 28, 2007 10:21 am
Location: Birkenhead
Contact:

Re: Scripting camera.

Post by DaveDewhurst »

DaveDewhurst wrote:Somebody will correct me if I'm wrong .....
See :D :D
SammytheShunter
Getting the hang of things now
Posts: 99
Joined: Sun Jan 02, 2011 1:47 pm

Re: Scripting camera.

Post by SammytheShunter »

Thank you so much, guys. I've just tried both those syscall statements and both work brilliantly. After a long time hunting for one solution I now have two to choose from.
User avatar
Irishrailguy
Very Active Forum Member
Posts: 1338
Joined: Sun Mar 21, 2010 8:58 pm
Location: Dublin, Ireland

Re: Scripting camera.

Post by Irishrailguy »

This is great! I'll have to use that in my electrostar...

Just out of curiosity, what other system calls are there which work in the engine script? If this particular call is that useful I'd imagine there would be many other useful ones too...

Kev
Locked

Return to “[TS] General Discussion”