UPDATE Deze tutorial is vervangen door deel 3 |
UPDATE This tutorial has been superseded by part 3 |
Tot nu toe konden koersborden alleen ingesteld worden op de player trein. Maar met LUA scripting kan het ook op AI treinen! |
Until now destinationsigns could only be set on the player train. But with LUA scripting you can set it on AI trains too! |
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. |
Koersborden van deze ChrisTrains treinen dienen reeds bij de start van het scenario ingesteld te worden om ze later te kunnen wijzigen: | Destinationsigns of these ChrisTrains trains need to be set at the start of the scenario to be able to change them later on: |
- DDZ DD-AR
- DM90
- GTW
- ICM(m)
- (V)IRM
- MAT64
- SGM(m)
- SLT
function initialise() is een functie dat als aller eerste wordt geladen wanneer een scenario gestart wordt. Koersborden van de opgegeven treinen (train IDx) zullen worden ingesteld op de opgegeven bestemming (destination ID). |
function initialise() is a function that loads as very first when a scenario is started. Destinationsigns of given train (train IDx) will be set to destination (destination ID). |
Plaats in ieder LUA script voor alle andere functies dit: | Place this in front of your first event in every LUA script: |
Code: Selecteer alles
function Initialise()
-- TrainA
SysCall ( "[train ID1]:SetControlValue", "DestinationBoards", 0, [destination ID] );
SysCall ( "[train ID2]:SetControlValue", "DestinationBoards", 0, [destination ID] );
-- TrainB
SysCall ( "[train ID3]:SetControlValue", "DestinationBoards", 0, [destination ID] );
SysCall ( "[train ID4]:SetControlValue", "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. Overigens werkt ID 0 niet op in ieder geval de SGM(m)! |
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. Although ID 0 doesn't work on at least the SGM(m)! |
Gebruik alleen train ID's van de eerste en laatste bak. Alle bakken ertussen met een koersbord zullen vanzelf van dezelfde bestemming worden voorzien. Dit geldt ook wanneer er met meerdere gekoppelde treinen wordt gereden. |
Use only train ID's of the first and last carriage of the train. All carriages with destinationsigns in between will display the same destination automatically. This goes for driving with multiple units too. |
De destination ID's voor de eerste en laatste bak moeten hetzelfde zijn. Anders springt het in het scenario terug naar de default destination ID van de trein. |
The destination ID's for the first and last carriage must be the same. Otherwise it will jump to the default destination ID of the train when the scenario starts. |
Om later in het scenario een andere bestemming op de koersborden te plaatsen kunnen events worden aangemaakt. Deze werken alleen voor treinen die ook in function initialise() gebruikt zijn! |
To change to another destination on the destinationsigns later on in the scenario events can be made. These will only work on trains that were also used in function initialise()! |
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 ID1]:SetControlValue", "DestinationBoards", 0, [destination ID] );
SysCall ( "[train ID2]:SetControlValue", "DestinationBoards", 0, [destination ID] );
end
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. |
Voorbeeldscript met een DDZ en Mat64: | Examplescript with a DDZ and Mat64: |
Code: Selecteer alles
-- Train ID's
TrainA_id1 = 12345 -- DDZ first carriage
TrainA_id2 = 67890 -- DDZ last carriage
TrainB_id1 = 09876 -- Mat64 first carriage
TrainB_id2 = 54321 -- Mat64 last carriage
-- Destination ID's
BLANCO = 0 -- Blanco
DDZ_N_I = 1 -- Niet Instappen
DDZ_AH = 9 -- Arnhem
DDZ_ZL = 48 -- Zwolle
MAT64_N_I = 1 -- Niet Instappen
MAT64_E_T = 2 -- Extra Trein
MAT64_DV = 16 -- Deventer
function Initialise()
-- TrainA
SysCall ( TrainA_id1 .. ":SetControlValue", "DestinationBoards", 0, BLANCO );
SysCall ( TrainA_id2 .. ":SetControlValue", "DestinationBoards", 0, BLANCO );
-- TrainB
SysCall ( TrainB_id1 .. ":SetControlValue", "DestinationBoards", 0, MAT64_N_I );
SysCall ( TrainB_id2 .. ":SetControlValue", "DestinationBoards", 0, MAT64_N_I );
end
-- Events
function OnEvent(event)
_G["OnEvent" .. event]();
end
function OnEventTrainAdest1()
SysCall ( TrainA_id1 .. ":SetControlValue", "DestinationBoards", 0, DDZ_AH );
SysCall ( TrainA_id2 .. ":SetControlValue", "DestinationBoards", 0, DDZ_AH );
end
function OnEventTrainAdest2()
SysCall ( TrainA_id1 .. ":SetControlValue", "DestinationBoards", 0, DDZ_ZL );
SysCall ( TrainA_id2 .. ":SetControlValue", "DestinationBoards", 0, DDZ_ZL );
end
function OnEventTrainBdest1()
SysCall ( TrainB_id1 .. ":SetControlValue", "DestinationBoards", 0, MAT64_DV );
SysCall ( TrainB_id2 .. ":SetControlValue", "DestinationBoards", 0, MAT64_DV );
end
function OnEventTrainBdest2()
SysCall ( TrainB_id1 .. ":SetControlValue", "DestinationBoards", 0, MAT64_E_T );
SysCall ( TrainB_id2 .. ":SetControlValue", "DestinationBoards", 0, MAT64_E_T );
end
Wanneer het scenario start zijn de koersborden van de DDZ (TrainA) blanco en staat op de Mat64 (TrainB) "Niet instappen". | The destinationsigns of the DDZ (TrainA) will be blanc and on the Mat64 (TrainB) they'll display "Niet instappen" when the scenario starts. |
Voor beide treinen zijn er 2 events die later in het scenario aangeroepen kunnen worden om een nieuwe bestemming in te stellen. | There are 2 events for both trains that can be called later on in the scenario to set new destinations in the displays. |
Roep in de editor event "TrainAdest1" op om de koersborden van de DDZ in te stellen op "Arnhem". Event "TrainAdest2" maakt er "Zwolle" van. |
Call event "TrainAdest1" in the editor to change the destinationsigns of the DDZ to "Arnhem". Event "TrainAdest2" will change it into "Zwolle". |
Met events "TrainBdest1" en "TrainBdest2" wordt de Mat64 ingesteld op "Deventer" en "Extra trein". | With events "TrainBdest1" and "TrainBdest2" the Mat64 will be set to "Deventer" and "Extra trein". |
Klik hier voor deel 2 van deze tutorial. | Click here for part 2 of this tutorial. |