In deel 1 heb je kunnen lezen hoe koersborden in te stellen waren op diverse ChrisTrains treinen, voor zowel de speler als AI. Dit had echter lag tot gevolg tijdens het rijden. Veel lag wanneer het op veel treinen werd toegepast. NielsB_, de bouwer van route Apeldoorn – Deventer / Winterswijk, stuitte in een DTG handleiding van een heel andere trein op de oplossing! Deze tutorial zal de nieuwe manier van scripten uitleggen. |
In part 1 you've read how to set destinationsigns on several ChrisTrains trains, for the player as well as AI. But this caused lag when driving. A lot of lag when applied to manu trains. NielsB_, builder of route Apeldoorn – Deventer / Winterswijk, stumbled on the solution in a manual by DTG of a completely different train! This tutorial will explain the new way to script. |
Voor meer informatie over hoe en wat met LUA scripting verwijs ik je graag naar elders. Matt Paddlesden heeft een uitstekend filmpje op YouTube en daaruit gemaakte blogs voor degene die zich willen verdiepen in de beginselen van LUA scripting in scenario's. |
For more information about the basics of LUA scripting I'd like to point you to somewhere else. Matt Paddlesden has an excelent video on YouTube and created blogs from that for everyone who want to learn the basics of LUA scripting in scenarios. |
Ik beperkt me hier alleen specifiek op de LUA scripting voor de koersborden. | Here I'll confine myself only to LUA scripting for the destinationsigns. |
Deze tutorial is toe te toepassing op de volgende ChrisTrains treinen: | This tutorial can be applied to these ChrisTrains trains: |
- DD-AR (ook in combinatie met een 1700 loc!)
- DDZ
- DH1/2
- DM90
- GTW
- MAT64
- SGM(m)
Om in het scenario de bestemming op de koersborden te plaatsen moeten events worden aangemaakt. | To set the destination on the destinationsigns in the scenario events need to be created. |
Plaats in ieder LUA script voor het eerste event dit: | Place this in front of your first event in every LUA script: |
Code: Selecteer alles
function OnEvent(event)
_G["OnEvent" .. event]();
end
Maak vervolgens een event aan: | Then create an event: |
Code: Selecteer alles
function OnEvent[EventName]()
SysCall ( "[train ID]:SetControlValue", "DestinationBoards", 0, [destination ID] );
SysCall ( "[train ID]:SetControlTargetValue", "DestinationBoards", 0, [destination ID] );
end
Wat de destination ID is kan uit de handleiding van de trein gehaald worden. In alle handleidingen staan de mogelijke bestemmingen genoemd op volgorde. De eerste bestemming is ID 1 en zo tel je door. Geen bestemming is ID 0. |
The destination ID can be obtained from the train's manual. All manuals list every possible destination in order. The first destinatio is ID 1 and so on. No destination is ID 0. |
Gebruik als train ID de ID van de eerste bak. Met een DD-AR stam en 1700 loc, pak dan de ID van de DD-AR stuurstand. Alle andere bakken met een koersbord zullen vanzelf van dezelfde bestemming worden voorzien. Dit geldt ook wanneer er met meerdere gekoppelde treinen wordt gereden. |
Use as train ID the ID of the first carriage of the train. With a DD-AR and 1700 loco consist you use the ID of the DD-AR cab car. All other carriages with destinationsigns in the consist will display the same destination automatically. This goes for driving with multiple units too. |
Roep het event op in de scenario editor om de koersborden van de opgegeven trein te wijzigen naar de opgegeven bestemming. | Call the event in the scenario editor to change the destinationsigns of the given train to it's destination. |
Om de koersborden later in het scenario te wijzigen maak je een nieuw event aan die je in de scenario editor oproept op het moment dat je ze wil wijzigen. | To change the destinationsigns later on in the scenario you need to create a new event which you call in the scenario editor at the time you want to change them. |
Voorbeeldscript met een DDZ en Mat64: | Examplescript with a DDZ and Mat64: |
Code: Selecteer alles
-- Train ID's
TrainA_id = 12345 -- DDZ first carriage
TrainB_id = 09876 -- Mat64 first carriage
-- Destination ID's
BLANCO = 0 -- Blanco
DDZ_AH = 9 -- Arnhem
DDZ_ZL = 48 -- Zwolle
MAT64_N_I = 1 -- Niet Instappen
MAT64_DV = 16 -- Deventer
-- Events
function OnEvent(event)
_G["OnEvent" .. event]();
end
function OnEventTrainAdest1()
SysCall ( TrainA_id .. ":SetControlValue", "DestinationBoards", 0, DDZ_AH );
SysCall ( TrainA_id .. ":SetControlTargetValue", "DestinationBoards", 0, DDZ_AH );
end
function OnEventTrainAdest2()
SysCall ( TrainA_id .. ":SetControlValue", "DestinationBoards", 0, DDZ_ZL );
SysCall ( TrainA_id .. ":SetControlTargetValue", "DestinationBoards", 0, DDZ_ZL );
end
function OnEventTrainBdest1()
SysCall ( TrainB_id .. ":SetControlValue", "DestinationBoards", 0, MAT64_DV );
SysCall ( TrainB_id .. ":SetControlTargetValue", "DestinationBoards", 0, MAT64_DV );
end
function OnEventTrainBdest2()
SysCall ( TrainB_id .. ":SetControlValue", "DestinationBoards", 0, MAT64_N_I );
SysCall ( TrainB_id .. ":SetControlTargetValue", "DestinationBoards", 0, MAT64_N_I );
end
In het scenario worden de koersborden van de DDZ (TrainA) eerst ingesteld op "Arnhem" en staat op de Mat64 (TrainB) "Deventer". | In the scenario the destinationsigns of the DDZ (TrainA) will first display "Arnhem" and on the Mat64 (TrainB) they'll display "Deventer". |
Later in het scenario wordt voor iedere trein een 2e event aangeroepen. | Later on in the scenario a 2nd event will be called for both trains. |
Roep in de editor event "TrainAdest2" op om de koersborden van de DDZ in te stellen op "Zwolle". Event "TrainBdest2" stelt de Mat64 in op "Niet instappen". |
Call event "TrainAdest2" in the editor to change the destinationsigns of the DDZ to "Zwolle". Event "TrainBdest2" will change it into "Niet instappen" on the Mat64. |
Klik hier voor deel 2 van deze tutorial over andere treinen van ChrisTrains. | Click here for part 2 of this tutorial about other ChrisTrains trains. |