Jump to content

Recommended Posts

Posted

I have made a copy of an existing scenario and I would like to reduce the number of stations that the train stops at. In VS Code, I have been able to edit the timetable xml to remove a stop at a station but I need guidance as to what changes are required in the manifest.lua file to stop the senario setting the stop signal at a particular station.

Posted

You probaly need to adjest the code, that sets the exit signal for the removed platform  stops. Could you indicade, what scenario you are editing and what stops you want to taje out? Then I can give you an example on what to do.

Posted

The scenario is [IC] Warszawa-Katowice and I want to not stop at Warzsawa Wschnodia.

Here is the path

D:\SteamLibrary\steamapps\common\SimRail\SimRail_Data\StreamingAssets\Sceneries\1_KatowiceWarszawa\Scenarios\03_IC-WwaKato

 

Cheers

Posted

First you want to make a copy of the scenery folder and the scenario inside it. This does multiple things:

  1. You wan to keep an unaltered/safe copy of the in game files as a back up;
  2. The default in game sceneries/scenario's do not show up in the editor.

So go to D:\SteamLibrary\steamapps\common\SimRail\SimRail_Data\StreamingAssets\Sceneries. Their you can see a list of all Sceneries. Make a copy of 1_KatowiceWarszawa under a different name. Then go to the single player menu of the game (if you had already done that in the background, re open the SP menu to update the contents). Now you should see two versions of the same Katowice Warszawa scenery. That is not so handy. You can alter the name. To do this, you can use the editor, since it wont show the in game original anyways you are sure to alter the correct scenery. Or go to the new scenery and open the SceneryManifest.xml file, then alter the ThumbnailText or the translations for the ThumbnailText. Using the in game editor to change ThumbnailTextKey is the simplest.

 

Then you need to alter the schedule file, that is an xml file, they usually life inside the 'Timetables' folder, the file is in this case named 'M8.xml'. 

Look for the WayPointFromXml for the ph, Warszawa Wschodnia, you want out. Then change the StopType from 'commercialStop' to 'noStopover', then the WayPointFormXml for Wschodnia looks like this:


    <WayPointFromXml>
      <NameOfPoint>Warszawa Wschodnia</NameOfPoint>
      <DisplayName>Warszawa Wschodnia</DisplayName>
      <StopType>commercialStop</StopType>
      <Line>0</Line>
      <Mileage>0</Mileage>
      <TrainType>MPE</TrainType>
      <StationCategory>A</StationCategory>
      <StationSpeedLimit>0</StationSpeedLimit>
      <ArrivalTime>180</ArrivalTime>
      <DepartureTime>360</DepartureTime>
      <RadioChanels>
        <int>2</int>
      </RadioChanels>
      <plannedStop>0</plannedStop>
      <leftTrack>0</leftTrack>
      <track>0</track>
      <platform/>
    </WayPointFromXml>

Alternatively, you could simply delete the section where you want the stop to disappear, but that is a bit silly. You can change the 'paper' schedule too, that are the pictures displayed in cab, but those do not have any technical function and are more for show and roleplaying. This scenario does not have any.

If you would run the scenario now, you will see that the HUD shows Warszawa Wschodnia as a non stopping point where you loose 3 minutes, somehow. You can change the ArrivalTime and DepartureTime too, to the same value, for example 180 to 240 and 360 to 240. Timings further down the scenario will remain the same, so I suggest not change those, unless you want to shave off a few minutes of the whole scenario (which is a lot of work).

 

Now you can run the scenaario, prefarably using the editor, then you have access to the DEV tools (default key bind F8).

You will notice getting stuck at the platform signal, number J4 (you can see this on the number plate at the signal post), in code its called "WSD_J4". WSD is short for Warszawa Wschodnia.

Now open the mission.lua file in the scenario folder. Look for the following code, it is in the function called Triggers():

CreateSignalTrigger(FindSignal("WSD_J4"), 600, 
    {
        check = PlayerTrainsetCheck,
        result = function(trainset)
            CreateCoroutine(function ()
                coroutine.yield(CoroutineYields.WaitForTrainsetPassengerExchangeFinished, RailstockGetPlayerTrainset(), TimeSpanCreate(0, 0, 0, 30, 0))
                CreateRoute("WSD_J4", "WSD_Akps", VDOrderType.TrainRoute)
                CreateRoute("WDC_W", "WDC_J", VDOrderType.TrainRoute)
            end)
        end
    })

The code 'coroutine.yield' is used to wait/check for something, in this case 'oroutineYields.WaitForTrainsetPassengerExchangeFinished'. But since we have removed the ph, their is no passenger exchange to finish anymore. We need to alter this code. One could change the condition within the 'coroutine.yield', but that is complex. The code that starts with 'CreateRoute' is used to set the signals. Those two bits, are the thing we need. I recommend to comment out the whole signal trigger, put '--[[' before the first line of the signal trigger, and put ']]' after the list line (first and last line of the code snippet above). this causes the code to become inactive, but you can still see it in the file, so you have a reference to what it was and could easily revert back.

To clear the signal, you have multiple options:

  • Make your own signal trigger (or use a track trigger of radio call, but that is more complex).
  • Put the code to clear the signal with the code that clears the signal before.

I will first explain the first option, making your own signal trigger, since you can do that almost everywhere.

Open the scenario using the editor, so you can use DEV tools. Open them (probably press F8) and look for the 'LUA developer', then click on 'track details'. You should see a part 'SIGNALS'. If you click on those buttons, the game will spit out a ready made signal trigger you your clipboard, which you can past directly inside the mission.lua file. Now go to the location where you like the trigger to be, for example, at some distance before the J4 signal, you can drive or walk their, but their is a very handy freefly option under the main camera menu (which does not work if you where not in a train before, so use it after leaving your train, in this scenario you spawn inside the drivers seat so this can not go wrong). Past it below the old signal trigger, that you commented out.

image.thumb.png.c20cd4ebc7a0e1c03ec8c5514fdf8bd6.png

I copied the following signal trigger, which I pasted below the old one:

function Triggers()

    --[[CreateSignalTrigger(FindSignal("WSD_J4"), 600, 
    {
        check = PlayerTrainsetCheck,
        result = function(trainset)
            CreateCoroutine(function ()
                coroutine.yield(CoroutineYields.WaitForTrainsetPassengerExchangeFinished, RailstockGetPlayerTrainset(), TimeSpanCreate(0, 0, 0, 30, 0))
                CreateRoute("WSD_J4", "WSD_Akps", VDOrderType.TrainRoute)
                CreateRoute("WDC_W", "WDC_J", VDOrderType.TrainRoute)
            end)
        end
    })]]

    CreateSignalTrigger(FindSignal("WSD_J4"), 136, 
{
	check = function (trainset)
		return true
	end,
	result = function(trainset)
	end
})

Now in-between the line 'result = function(trainset)'  and 'end', make some working space for yourself by inserting some blank lines. Then you can copy the 'CreateRoute' commands from the old trigger. But I will explain how to make your own ones too, so you can make it however your like it. Open the 'routes' tab in the LUA developer. The game will, after some time or walking if it does not work, show a list of routes the game can set. maneuver is used for shunting or train for train movements (you can manually change the 'VDOrderType' to 'VDOrderType.Substitute' if you want to show an Sz signal).

Click the checkbox for the route you want to set and then on enable selected route now. Their is a release option below the lift if you do not like the route. If you like it, use 'copy command to enable selected' and paste it into the mission.lua file. For example:

--[[CreateSignalTrigger(FindSignal("WSD_J4"), 600,
    {
        check = PlayerTrainsetCheck,
        result = function(trainset)
            CreateCoroutine(function ()
                coroutine.yield(CoroutineYields.WaitForTrainsetPassengerExchangeFinished, RailstockGetPlayerTrainset(), TimeSpanCreate(0, 0, 0, 30, 0))
                CreateRoute("WSD_J4", "WSD_Akps", VDOrderType.TrainRoute)
                CreateRoute("WDC_W", "WDC_J", VDOrderType.TrainRoute)
            end)
        end
    })]]

    CreateSignalTrigger(FindSignal("WSD_J4"), 136,
        {
            check = function(trainset)
                return true
            end,
            result = function(trainset)
                VDSetRouteWithVariant("WSD_J4", "WSD_Akps", VDOrderType.TrainRoute, {
                    GetMidPointVariant("z1335", false),
                    GetMidPointVariant("WSD_11cd", true),
                    GetMidPointVariant("WSD_11ab", false),
                    GetMidPointVariant("WSD_7cd", false),
                    GetMidPointVariant("WSD_7ab", false),
                    GetMidPointVariant("z1333", false)
                })
            end
        })

You have probably noticed, that the LUA developer tool spits out a 'VDSetRouteWithVariant()' or 'VDSetRoute()' command, not a 'CreateRoute()' command. That is because the 'CreateRoute()' is made to work using a libary, not standard present in a scenario. But Eridor (SimKol's magical scenario making dragon) has made those library's and the CreateRoute thingy inside them to provide more flexibility and especially reliability then the game had before (the VDSetRoute will only attempt to set the route once, while CreateRoute will by deafalut try 10 times. This can come in vary handy when you have bot trains driving in the way of the player). You can use one of both. Keep in mind, that CreateRoute will only work inside a the Coroutine. If its already inside a Coroutine, its usually very simple, you can replace the work 'VDSetRoute' with CreateRoute and 'VDSetRouteWithVariant' with 'CreateRouteVariant'.

If its not in a Coroutine yet, put 'CreateCoroutine(function ()' before the CreateRoute command(s) and then 'end)' behind it, to end the Coroutine.

If you use CreateRoute, make sure the Eridor library is included in the mission.lua file, it is most likely already their if its an in game scenario (Eridor has put in the work to update the old scneario's), its 
'require("../../libs/EridorCommon")'.

 

Or simply use the VDSetRoute that the LUA developer spits out. Easy coding but more debugging, which can be annoying with long scenario's. But this example is at the very start.

 

This is what I made, with first commened out the VDSetRouteWithVariant, and then CreateRouteVariant inside a Coroutine:

CreateSignalTrigger(FindSignal("WSD_J4"), 136,
        {
            check = function(trainset)
                return true
            end,
            result = function(trainset)
                --[[VDSetRouteWithVariant("WSD_J4", "WSD_Akps", VDOrderType.TrainRoute, {
                    GetMidPointVariant("z1335", false),
                    GetMidPointVariant("WSD_11cd", true),
                    GetMidPointVariant("WSD_11ab", false),
                    GetMidPointVariant("WSD_7cd", false),
                    GetMidPointVariant("WSD_7ab", false),
                    GetMidPointVariant("z1333", false)
                })
            ]]
            
            CreateCoroutine(function()
                CreateRouteVariant("WSD_J4", "WSD_Akps", VDOrderType.TrainRoute, {
                    GetMidPointVariant("z1335", false),
                    GetMidPointVariant("WSD_11cd", true),
                    GetMidPointVariant("WSD_11ab", false),
                    GetMidPointVariant("WSD_7cd", false),
                    GetMidPointVariant("WSD_7ab", false),
                    GetMidPointVariant("z1333", false)
                })
            end)
            end
        })

You can adjust the distance to the signal by changing the number behind 'CreateSignalTrigger(FindSignal("WSD_J4"),', since 136 m is a bit late.

Now if you would like to clear the signal, when you call the dispatcher at scenario start. You can simply cut the CreateRoute from the old signal trigger, and paste them in the code that clears the signal at the spawn point. You can find that code by looking up the start signal or the signal where you end up (since you set a route from aa signal to a signal or to the free track), please use a program where you can look for a specific word (the wiki has instructions on how to setup Viusal Studio Code, which is great and recommended by the dev team). You spawn at signal L16, which is called in code "WSD_L16". You can find it here:

function OnPlayerRadioCall(trainsetInfo, radio_SelectionCall)
    Log("Call pressed in " ..
        trainsetInfo.name .. ". Call type: " .. tostring(radio_SelectionCall) .. ", Step: " .. tostring(ScenarioStep))

    if (ScenarioStep == "Start") then
        if (RailstockGetPlayerTrainset().GetCurrentlyUsedChannel() == 2) then
            ScenarioStep = 0
            CreateCoroutine(function()
                CommsOldJson("#Caller_You", "Check_train_radio_Lua", "Warszawa Wschodnia", "14103")
                CommsOldJson("WSD", "Rec_loudnclear_Lua", "Warszawa Wschodnia")
                CommsOldJson("#Caller_You", "Ready_2_go_Lua", "Warszawa Wschodnia", "14103")
                CommsOldJson("WSD", "Thanku_semaph")

                coroutine.yield(CoroutineYields.WaitUntil, function()
                    return VDLoaded
                end)

                CreateRoute("WSD_L16", "WSD_J4", VDOrderType.TrainRoute)
            end)
        else
            CreateCoroutine(function()
                coroutine.yield(CoroutineYields.WaitForSeconds, 0.1)
                ShowUseRadioNotification()
                Comms(false, "StaticNoise")
            end)
        end
    end

You command we are looking for is 'CreateRoute("WSD_L16", "WSD_J4", VDOrderType.TrainRoute)'. Paste the  before it, so you get this:

function OnPlayerRadioCall(trainsetInfo, radio_SelectionCall)
    Log("Call pressed in " ..
        trainsetInfo.name .. ". Call type: " .. tostring(radio_SelectionCall) .. ", Step: " .. tostring(ScenarioStep))

    if (ScenarioStep == "Start") then
        if (RailstockGetPlayerTrainset().GetCurrentlyUsedChannel() == 2) then
            ScenarioStep = 0
            CreateCoroutine(function()
                CommsOldJson("#Caller_You", "Check_train_radio_Lua", "Warszawa Wschodnia", "14103")
                CommsOldJson("WSD", "Rec_loudnclear_Lua", "Warszawa Wschodnia")
                CommsOldJson("#Caller_You", "Ready_2_go_Lua", "Warszawa Wschodnia", "14103")
                CommsOldJson("WSD", "Thanku_semaph")

                coroutine.yield(CoroutineYields.WaitUntil, function()
                    return VDLoaded
                end)

                CreateRoute("WSD_J4", "WSD_Akps", VDOrderType.TrainRoute)
                CreateRoute("WDC_W", "WDC_J", VDOrderType.TrainRoute)
                CreateRoute("WSD_L16", "WSD_J4", VDOrderType.TrainRoute)
            end)
        else
            CreateCoroutine(function()
                coroutine.yield(CoroutineYields.WaitForSeconds, 0.1)
                ShowUseRadioNotification()
                Comms(false, "StaticNoise")
            end)
        end
    end

 

And you are done! I hope I have not overwhelmed you but all my extra stuff you do not strictly need, for what could be a very simple change.

Example is attached 9where I put in the signal trigger thing and, as an example but commented out, the CreateRoute at the radio call code.

If you have further questions, please do not hesitate to ask.

03_IC-WwaKatoSkipPhWSD.zip

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

Terms of Use Privacy Policy