LUA Scripting in Scenarios
Moderator: Moderators
-
tnleeuw01
- Very Active Forum Member
- Posts: 2493
- Joined: Sat Oct 08, 2011 11:17 am
- Location: Diemen, Netherlands
Re: LUA Scripting in Scenarios
I haven't found time yet unfortunately to read through this documentation, but I am curious if there is any way through scripting or editing of files to manipulate the new 3D Silverlining weather system, such as height and density of clouds, and type of clouds?
Kind regards,
--Tim
Kind regards,
--Tim
- smarty2
- Very Active Forum Member
- Posts: 9976
- Joined: Sun Aug 21, 2005 8:16 am
- Location: 1963, at Snow Hill!
- Contact:
Re: LUA Scripting in Scenarios
Good question, I would like to see more "realistic" weather conditions in real time rather than the comically fast transitions we have at the moment.
Best Regards
Martin (smarty2)
Non technically minded individual!
Is There A God?
Dudley Bible web page
Martin (smarty2)
Non technically minded individual!
Is There A God?
Dudley Bible web page
-
NeutronIC
- Atomic Systems Team

- Posts: 11085
- Joined: Fri Oct 05, 2001 12:00 am
- Location: E11, London, England
- Contact:
Re: LUA Scripting in Scenarios
I'm going to do the next post all about weather systems and how to dynamically script their changes. You'll need to roll up your sleeves and get down and dirty with the blueprint editor, but i'll try and make it easy to follow 
I must admit i'm not entirely familiar with the wider capabilities of the Silverlining implementation, the last time I played with dynamic scripted weather it was all just in the original sky system, so I will be having a play with that first so I can report back on options.
Since I last posted btw, articles 7, 8 and 9 are now up.
7 - Interfacing with loco controllers
8 - Locking and unlocking player controls
9 - Ending the scenario early
Coming next:
10 - Weather
11 - Audio
12 - Video
13 - Is the train at a location
If anyone has ideas for other topics to add to that, then shout
Matt.
I must admit i'm not entirely familiar with the wider capabilities of the Silverlining implementation, the last time I played with dynamic scripted weather it was all just in the original sky system, so I will be having a play with that first so I can report back on options.
Since I last posted btw, articles 7, 8 and 9 are now up.
7 - Interfacing with loco controllers
8 - Locking and unlocking player controls
9 - Ending the scenario early
Coming next:
10 - Weather
11 - Audio
12 - Video
13 - Is the train at a location
If anyone has ideas for other topics to add to that, then shout
Matt.
- AndiS
- Very Active Forum Member
- Posts: 6207
- Joined: Fri Sep 23, 2005 4:43 pm
- Location: Jester's cell in ivory tower
- Contact:
Re: LUA Scripting in Scenarios
My shout is for taking control of AI and talking to signals.
1) It has been said that you can set controllers in AI trains by substituting PlayerTrain with the Service Name of the AI train concerned. For the horn, it has been demonstrated. But for the throttle and brake, you would be fighting against the game, I guess. So I never ventured into these domains myself.
2) I don't know of a solution for communication between signals and scenario script. If that would work, the scenario script could make AI and signals cooperate.
Of course, sending messages from a signal to AI would be a more direct implementation.
Things that could be achieved then would be:
AI not starting before signal clears.
AI not stopping at clear signals. (Currently some rule 39-like behaviour is shown at all signals, not just UK semaphore home signal).
AI coupling to vehicles that have moved before (signals see them and can direct the approach).
Signals showing shunting aspect (call-on) instead of aspects for running movements on a scenario-specific basis. Now you need invisible signal objects, placed in scenario editor. This one is important for the player train too. Using TAB to switch does not really cut it.
Permissive block working and entering occupied platforms. Now you need invisible block signals to make AI do that.
1) It has been said that you can set controllers in AI trains by substituting PlayerTrain with the Service Name of the AI train concerned. For the horn, it has been demonstrated. But for the throttle and brake, you would be fighting against the game, I guess. So I never ventured into these domains myself.
2) I don't know of a solution for communication between signals and scenario script. If that would work, the scenario script could make AI and signals cooperate.
Of course, sending messages from a signal to AI would be a more direct implementation.
Things that could be achieved then would be:
AI not starting before signal clears.
AI not stopping at clear signals. (Currently some rule 39-like behaviour is shown at all signals, not just UK semaphore home signal).
AI coupling to vehicles that have moved before (signals see them and can direct the approach).
Signals showing shunting aspect (call-on) instead of aspects for running movements on a scenario-specific basis. Now you need invisible signal objects, placed in scenario editor. This one is important for the player train too. Using TAB to switch does not really cut it.
Permissive block working and entering occupied platforms. Now you need invisible block signals to make AI do that.
-
NeutronIC
- Atomic Systems Team

- Posts: 11085
- Joined: Fri Oct 05, 2001 12:00 am
- Location: E11, London, England
- Contact:
Re: LUA Scripting in Scenarios
Bear in mind that the despatcher handles all the driving of the AI trains, if you try taking over control of them it'll likely result in a major problem with the despatcher. Whether you can do it or not, I absolutely would not recommend it, I can't imagine how badly it will affect other parts of the system. Along the same lines, since AI trains don't actually use normal "full" physics, they won't be using things like the regulator, reverser etc, so even if you can affect them I do not anticipate it having any impact on the train itself.
Interfacing with signals is not, as far as I am aware, possible.
Matt.
Interfacing with signals is not, as far as I am aware, possible.
Matt.
-
tnleeuw01
- Very Active Forum Member
- Posts: 2493
- Joined: Sat Oct 08, 2011 11:17 am
- Location: Diemen, Netherlands
Re: LUA Scripting in Scenarios
Hi Matt,NeutronIC wrote:I'm going to do the next post all about weather systems and how to dynamically script their changes. You'll need to roll up your sleeves and get down and dirty with the blueprint editor, but i'll try and make it easy to follow
[...]
Matt.
I don't mind getting my hands dirty with the blueprint-editor, in fact that's kind of what I had expected, but I'd like to know two things about this:
1. How to package this as a standalone scenario, that can be installed with the correct blueprints
2. Can we then upload such scenario to the Steam Workshop? With the custom scripts and custom blueprints for special effects in the weather?
And another question about weather in scenarios:
- The scenario properties tab allows to choose weather, and it has a 2nd page where you can enter some weather-related properties from a drop-down (if I recall correctly). However, the drop down is always empty.
What can one do there? What is it intended for?
Kind regards,
--Tim
-
NeutronIC
- Atomic Systems Team

- Posts: 11085
- Joined: Fri Oct 05, 2001 12:00 am
- Location: E11, London, England
- Contact:
Re: LUA Scripting in Scenarios
Unfortunately if your scenario requires anything outside of the local scenario folder (which extended weather will) then it can't go up to steam workshop.
The workaround is NOT to use a custom weather blueprint, but to find one that already does what you want and simply reference it - in that case, it will work fine, but you're at the mercy of weather blueprints that have already defined, which may or may not do what you want.
In order to package them, you'd need to add the scenario plus the assets using the packager tool (part of utilities.exe) to create an RWP that contains what is needed.
If the weather tab drop down is empty, it means it can't find any extended weather blueprints in any of your enabled assets. There are some in RSC\ShermanHill, and keithmross\PortRoad for example - so if you add those to your scenario project you should find something appear in that drop down. Once you make your own, then they'll appear anyway of course.
Matt.
The workaround is NOT to use a custom weather blueprint, but to find one that already does what you want and simply reference it - in that case, it will work fine, but you're at the mercy of weather blueprints that have already defined, which may or may not do what you want.
In order to package them, you'd need to add the scenario plus the assets using the packager tool (part of utilities.exe) to create an RWP that contains what is needed.
If the weather tab drop down is empty, it means it can't find any extended weather blueprints in any of your enabled assets. There are some in RSC\ShermanHill, and keithmross\PortRoad for example - so if you add those to your scenario project you should find something appear in that drop down. Once you make your own, then they'll appear anyway of course.
Matt.
-
tnleeuw01
- Very Active Forum Member
- Posts: 2493
- Joined: Sat Oct 08, 2011 11:17 am
- Location: Diemen, Netherlands
Re: LUA Scripting in Scenarios
Hi Matt,NeutronIC wrote:Unfortunately if your scenario requires anything outside of the local scenario folder (which extended weather will) then it can't go up to steam workshop.
The workaround is NOT to use a custom weather blueprint, but to find one that already does what you want and simply reference it - in that case, it will work fine, but you're at the mercy of weather blueprints that have already defined, which may or may not do what you want.
In order to package them, you'd need to add the scenario plus the assets using the packager tool (part of utilities.exe) to create an RWP that contains what is needed.
If the weather tab drop down is empty, it means it can't find any extended weather blueprints in any of your enabled assets. There are some in RSC\ShermanHill, and keithmross\PortRoad for example - so if you add those to your scenario project you should find something appear in that drop down. Once you make your own, then they'll appear anyway of course.
Matt.
Thanks for the answers!!
I was afraid so, that it wouldn't be possible to publish such scenario to the Steam Workshop. It would be nice if in future such types of assets, scenarios could be published to the Workshop.
Still that's not the end-all, the scenarios for which right now I wish to play with the weather are anyways not publishable for the workshop since they're for a couple of routes that are not sold via Steam... But some of the ideas which I have, that a 3D cloud system could enable, would also be applicable to several 'official' Steam DLC routes.
For instance, in a mountain route, foggy or cloudy weather where you can adjust the altitude of the clouds so that they are in the valley below your train, and as you descend, you drive through and eventually below the clouds.
That would really show of added value of the new weather system, if that could be realized.
But I haven't managed (yet) to do anything like it with the weather blueprints which are currently installed on my installation.
Cheers,
--Tim
- AndiS
- Very Active Forum Member
- Posts: 6207
- Joined: Fri Sep 23, 2005 4:43 pm
- Location: Jester's cell in ivory tower
- Contact:
Re: LUA Scripting in Scenarios
Thanks for your swift reply. I will try and return to realist mode. Actually I shared your concerns which is why I never put too much energy into trying such things.
I would have loved to force the throttle open in any train that falls into a constant 1 mph crawl. But I still would depend on the dispatcher to set the switches, so restarting the train would only be half a success in these cases where the dispatcher gives up.
I would have loved to force the throttle open in any train that falls into a constant 1 mph crawl. But I still would depend on the dispatcher to set the switches, so restarting the train would only be half a success in these cases where the dispatcher gives up.
-
NeutronIC
- Atomic Systems Team

- Posts: 11085
- Joined: Fri Oct 05, 2001 12:00 am
- Location: E11, London, England
- Contact:
Re: LUA Scripting in Scenarios
Blog Article #10 - Dynamic Weather - now online, that was huge, longest blog post so far but it's great fun to play with!
Matt.
Matt.
-
clivejames1st
- Well Established Forum Member
- Posts: 570
- Joined: Sun Jun 22, 2008 7:57 pm
Re: LUA Scripting in Scenarios
Hi Matt.
I have only got to watch the tutorial tonight and found it very interesting indeed. I would like to see your .lua work a little slower as I have to keep replaying those parts. I am looking forward to your other tutorials and would like to see a tutorial on .lua with signalling too.
Many thanks for this, .lua is something I have looked at before but never understood.
Regards
Clive
I have only got to watch the tutorial tonight and found it very interesting indeed. I would like to see your .lua work a little slower as I have to keep replaying those parts. I am looking forward to your other tutorials and would like to see a tutorial on .lua with signalling too.
Many thanks for this, .lua is something I have looked at before but never understood.
Regards
Clive
- Juanillo99
- Well Established Forum Member
- Posts: 879
- Joined: Sat Oct 13, 2012 5:12 pm
- Location: Teruel - Spain
- Contact:
-
gougha
- Well Established Forum Member
- Posts: 543
- Joined: Tue Nov 16, 2010 1:38 pm
- Location: South Yorkshire
Re: LUA Scripting in Scenarios
Can I add my thanks for sharing your knowledge with regards to scripting. I for one intend to have a play while building my route.
Regards
Andy
Regards
Andy
-
NeutronIC
- Atomic Systems Team

- Posts: 11085
- Joined: Fri Oct 05, 2001 12:00 am
- Location: E11, London, England
- Contact:
Re: LUA Scripting in Scenarios
Part 12 is now up, talking about how to get videos playing as part of your scenarios - some really exciting possibilities here!
Matt.
Matt.
