I'm looking for a full list on how to write lua scripts as well as other scripts within the blueprint editor. Fair enough, I've got no issues creating water blueprints, importing locomotives and rolling stock as well as scenery models into TS Classic. But I've got absolutely no knowledge how to write the scripts for locomotives and rolling stock such as the scripting required for pantographs, doors, mirrors and other things, yet alone I don't even know how to use TS Tools to open other scripts to learn from them. I really don't want to quit on the Australian locos and rolling stock, I have added in TS Classic Even though they do work in the sim but I've used the developer examples and need to know how exactly to write the scripts even one that I can somehow tell the game the locomotive is in kph and not mph, just an example!
Most stuff can be added without scripting. You can link any exterior animation to any control value in a blueprint. Its when you need advanced features scripting is needed. But when scripting you need to use virtual controls, or stay away from logic names that TS core uses to awoid conflicts. For speed in kph use "SpeedometerKPH" for the control value name, instead of SpeedometerMPH.
I have never found a guide. So your best bet is to grab an existing .lua file and look at what it does. The kuju Black5 provides a nice simple? example: Assets\Kuju\RailSimulator\RailVehicles\Steam\5MT_Black5\Default\Engine\Black5EngineScript.lua You will see: Some comments (use -- to designate a comment) function Initialise () - this code runs once when the loco is created into the game session - BUT there are some elements that don't work here and need to run as a one-time in the update section function OnControlValueChange ( name, index, value ) - this runs whenever a control value is changed (ie regulator is open/closed, horn sounded etc etc function Update ( time ) - runs once in every frame to allow processing through time (ie changing steam/smoke effects according to settings, load etc) You can define your own functions and refer to them in the code You can 'use' and existing script by using the 'include' statement before any functions This link shows all of the engine-related script elements: http://tscdevdocs.co.uk/reference-manual/scripting-function-reference/engine-function-reference.html Writing a half decent developer guide would be a large undertaking with considerable ongoing hassle - which maybe why no one has done it. Once you have the hang of the basics (try turning smoke on/off to start with) then you could look at more complicated scripts. A difficulty is that people tend to hide their cleverness behind compiled lua (.out files are compiled lua scripts). Since mine aren't clever I am happy to leave them in the open - when you feel brave you could look at this: https://drive.google.com/file/d/1hJZEPPrv9gpyqrUvv1XCx7pqQAVntoiB/view?usp=sharing This is from my J19 steam loco: https://sites.google.com/site/cambridgelinesrailworks/file-cabinet/locomotives?authuser=0 Please don't ask me to explain it - just work it through and then nick techniques that work for you (which is how I did it in the first place). There are, of course, several threads on UKTS forae... PS - if anyone knows of such a guide then please tell us - I'd love to have one!
Thanks Neil, I will have a look at some of yhe scrips as I want to create a lua script to match RPM to gear on a railbus I am making, it probably helps if you're already an experienced programmer as scripting in lua is similar to many other modern languages. It's the integration with the TSC functions that's the hard bit.
Agreed - the function list is a starter but there are often nuances that take some trial and error to understand (plus some undocumented stuff like the 'AddTenderWater' function that was specially added to enable Pete to do the Riviera line water troughs).
To be honest, I wouldn't had known scripting would be involved to add water to Steam locomotive tenders. After I got the NR, XPT, QR ICE, Adelaide Metro 3000/3100 and Adelaide Metro 4000 Class sorted with scripting I was going to add a first Australian Steam locomotive into TSC and I wasn't sure if the water for the tenders were scripted or just added to the blueprint. Thanks for letting me know
In normal usage the water in the tender isn't an issue - the game handles it for you (as long as you remember to fill up from a suitable water tower etc). That specific function is necessary to enable water troughs which were an innovation in the Riviera Line route when it was released a few years ago.
No scripting is required to make a train work in TSC with basic functions. Make a plan for what functions you want to have, then figure out what TSC can do and what needs to be scripted. If this is your first train for TSC I wouldn't bother with scripting anything unless you feel that a missing feature is very important to have. If you overcomplicate the project you will just end up never releasing it (speaking from experience )
Ah yes, I I originally contacted DTG for some issues I have with a pantograph, they told me that scripting is required as well as setting up the input mapper. They haven't gotten back to me yet as DTG was planning to send me examples of scripts for Steam, Electric 'Panto on trailer car, panto on driving car and electric locomotive dual panto and single panto and of course some scripting for diesels, doors and other stuff... I got impatient as I haven't heard back from DTG, so I thought about asking here It's not my first train I've imported into TSC! I originally imported my own NSW 86 Class Electric Locomotive, I couldn't get the thing to move at all HAHAHA But I never gave up trying, the first thing I was successful getting it to move is the NSW XPT engine itself followed by the NR Class locomotive. I also need scripting for setting up different liveries... I think? Not really sure!
I recommend the Train Sim Modding server on Discord, I don't have the direct invite link for it but you should be able to find it on the community site https://www.trainsimcommunity.com/ There are lots of helpful people on there that share their knowledge about TS modding, including script examples.
I don't have discord so that's not going to be much helpful! I'll just contact DTG and see if they could help.