by Chacal » Sun Jun 01, 2014 1:03 am
That's a big question that I can't answer in a post.
Like asking "How do I do brain surgery?".
In short, scripts let you program what happens when a player interacts with the controls of an engine.
The engine blueprint lists the control values and links them to actions from the player (e.g. pulling the horn lever).
Default results are already built-in (e.g. sounding the horn), but you can add extra results (e.g. sounding the bell) by writing a script.
Have a look at the developer docs in the RWA file library. There is one about signals.
It is the basic reference for scripting in Railworks.
Then find some lua scripts in your Railworks engines, for example the Centipede or the recently published Alco RS1 for the RW&A route.
Open them in your favorite text editor and compare them with the docs, and read the comments in the scripts.
You will also find posts about this topic here at RWA, on the UKTrainsim forum and in various tutorials found with a Google search.
Here are a few examples of engine lua scripts:
Assets\Britkits\Alco\RailVehicles\Diesel\RS3\Default\Engine\RS3_EngineScript.lua
Assets\GreatNortherner\EMD-SD7-9\RailVehicles\Engines\SD7\Simulation\sd7 simulation.lua
Assets\Kuju\RailSimulatorUS\RailVehicles\Diesel\ES44AC\Black\Engine\ES44ACEngineScript.lua
Assets\Kuju\RailSimulatorUS\RailVehicles\Diesel\F7\Default\UPRR\F7A_EngineScript.lua
Assets\Kuju\RailSimulatorUS\RailVehicles\Diesel\SD40-2\Black\Engine\SD40-2EngineScript.lua
You can find all of them by opening a command window in your railworks\assets folder and typing this command:
dir /B /W /S *.lua > lua.txt
Then open lua.txt and you'll see a list of all your scripts. Several hundreds of them.
Hope this helps.
Have fun.
Over the hill and gathering speed