HowTo/WagonX - Traincar Tutorial
Document Structure
- HowTo/Use the WagonX Library
- HowTo/WagonX - Technical Reference
- HowTo/WagonX - Browser Properties Examples and Basic Tutorials
- HowTo/WagonX - Locomotive Tutorial
Contents |
Adding WagonX to a Traincar
Setting the scene
A traincar can have different purposes such as a passenger vehicle such as a car or carriage, or as a wagon carrying, loading and unloading goods. WagonX can assist with both of those so two examples are included here. The first example is of a GWR carriage made by Andi Smith and repaired by the CRG. The second example will likely be a coal vehicle by Ben Dorsey. That example will follow later. For the GWR carriage we will add the Automated Coupling System (ACS), texture swapping, and attachments that can be shown or hidden. All of this is defined in the config. Some of the config tag set up is rather complicated so rather than describe here the tutorial frequently refers to the Technical Reference. It would be useful to keep a brower tab open on that page. Mesh libraries used in these examples are available on the DLS however they may not be suitable for your application so please use whatever is appropriate for your situation.
Setting up the config for the script, class and script-include-table
The script
You need a simple script called ref.gs that is in the WagonX asset. Alternatively you can easily create it yourself in any plain text editor. The contents are:
include "locowagonx.gs" class eRef isclass WagonX {};
The class and script-include table
Include these tags in the config, where <kuid:661805:500008> is the WagonX library.
class "eRef" script-include-table { 0 <kuid:661805:500008> }
Setting up the extensions container
The extensions container contains sub containers for ACS, if used, and WagonX. So, the general format, with no tags yet, is:
extensions { active-coupling-standard-60850 { } wagon-x { } }
The ACS container
The ACS container is fully described at ACS_Coupling_System, but for our purposes we will use the following as an example. Add/change/remove as required for your vehicle.
active-coupling-standard-60850 { version-major "2" version-minor "0" brakes "vac" front { coupler "screwlink|hook" vacbrake "single" heating-type "steam" gangway "gangway" } back { coupler "screwlink|hook" vacbrake "single" heating-type "steam" gangway "gangway" }
The Wagon-X Container
The WagonX ACS sub-container
See the WagonX ACS Technical Reference for details of tag usage.
WagonX needs information about ACS that isn't defined in the ACS container so, within the wagon-x sub container include an acs sub container that has three tags: animate, use-jbv-animation, and duration.
Animated and use-jbv-animation are self explanatory and duration is the fade time.
extensions { active-coupling-standard-60850 { ... } wagon-x { acs { animated 1 use-jbv-animation 0 duration 1.0 } } }
The Misc sub-container
See the WagonX Misc Technical Reference for details of tag usage.
The Misc sub-container includes times, in seconds, for loads and unloads at industries. This can be useful for effects such as smoke or dust. Since this is a passenger vehicle we will just set all values to zero.
extensions { active-coupling-standard-60850 { ... } wagon-x { acs { ... } misc { begin-load-time 0 begin-unload-time 0 end-load-time 0 end-unload-time 0 } } }
Marker Lights
See the WagonX Marker Lights Technical Reference for details of tag usage.
The marker-lights sub container is required even if you are not using them. If you don't need it then just set enabled to 0 and the mesh values to null.
The name "front" indicates the physical front of the vehicle. i.e. where a.limfront is located. "Back" is the physical back of the vehicle.
"Head" is the direction of train travel, and "tail" is the direction from which the train has come. In other words the tail of the train. Note that Trainz always has a nominal train direction of travel even if it is stopped.
If you don't need a lamp at a position then just use "null". There are some conditions on when lights are shown.
The head and tail meshes are lamp meshes in the mesh-table.
extensions { active-coupling-standard-60850 { ... } wagon-x { acs { ... } misc { ... } marker-lights { enabled 1 car-minimum-count 2 require-locomotive 1 night-only 0 front { head { mesh "lamp-front-white" } tail { mesh "lamp-front-red" } } back { head { mesh "lamp-back-white" } tail { mesh "lamp-back-red" } } } } }
Browser-Properties
See the Browser Properties Technical Reference for details of tag usage.
The example that follows is a relatively simple browser setup to control:
- Texture swapping
- Control of the marker lights
- Control of an interior night mesh
- Control of a "front" indicator
Each property has a number of control tags that are located in a property container and each container has a simple number id. The number of tags in a container depends on the property type. Not all properties are subject to user control and can be triggered by other events, such as changing from day to night. Each property can be disabled, however this can only be done in the config.
Texture Swapping
Texture swapping is controlled in the Properties Browser and can be configured by the user. There are six possible textures including a blank which like an underpaint coat. The default livery is number 1 which is not the first in the list as the list starts with 0 (zero). Since the number of texture effects is 4, and the number of different textures is 6, then the values tag must contain 24 values that are indices to the actual textures in the relevant texture library.
Marker Lights
The marker lights is quite simple and just controls whether they are used only at night or also during the day as well.
Front Indicator
The front indicator is a simple tool provided by the original creator, Andi Smith, to show which end of the car is the physical front. The property is visible in the Properties Browser as a simple show or hide option.
Interior Lighting
This is an example of a property triggered by an external event. In this case changing from day to night, and night to day. WagonX intercepts the message posted on these events and that triggers a mesh swap using the event type and the values to show the correct mesh.
extensions { active-coupling-standard-60850 { ... } wagon-x { acs { ... } misc { ... } marker-lights { ... } browser-properties { 0 { consist-property-sync 1 property-sync-id "GWRsynctexture" enabled 1 property-visibility 1 name "Current traincar livery: " property-id "p_livery" description "Sets the livery for the carriage" kind "fx-replacement" fx-replacement-type "texture-replacement" effects "livery-main,livery-leftdoor,livery-rightdoor,livery-crest" asset "liveries" values "0;0;0;0,1;1;1;5,2;2;2;6,2;2;2;7,3;3;3;8,4;4;4;8" default-index 1 trigger "user" display-type "link" display-values "Blank,GWR 1922,GWR 1930,GWR 1934,Crimson Cream,Maroon" } 1 { enabled 1 property-visibility 1 name "Night Only: " property-id "p_cfg" description "Sets the Day Night" kind "config-edit" paths "marker-lights/night-only" values "0,1" default-index 0 trigger "user" display-type "link" display-values "False,True" } 2 { enabled 1 property-visibility 1 name "Front Indicator: " property-id "p_front" description "Large F character showing front of carriage" kind "mesh-attachment" mesh-attachment-type "mesh-toggle" meshes "front" values "0,1" default-index 0 duration 2 trigger "user" display-type "link" display-values "Hidden, Visible" } 3 { enabled 1 property-visibility 0 name "Interior lighting: " property-id "p_interior_lighting" kind "mesh-attachment" mesh-attachment-type "mesh-toggle" meshes "day-interior,night-interior" values "1;0,0;1" default-index 0 duration 2 trigger "event" events "world-day,world-night" } } } }
Adding other effects
You can easily add other mesh effects using the front indicator in the example above as a template. For example, some versions of a traincar may have a real life structure for different versions of the same basic car. For that just copy the front indicator container and change the tag contents as necessary.
The final config.txt (relevant parts)
Here is the completed config.txt for those parts covered by the example including the mesh-table:
script-include-table { 0 <kuid:661805:500008> } script "ref" class "eRef" extensions { active-coupling-standard-60850 { version-major "2" version-minor "0" brakes "vac" front { coupler "screwlink|hook" vacbrake "single" heating-type "steam" gangway "gangway" } back { coupler "screwlink|hook" vacbrake "single" heating-type "steam" gangway "gangway" } } wagon-x { acs { animated 1 use-jbv-animation 0 duration 5 } marker-lights { enabled 1 car-minimum-count 2 require-locomotive 1 night-only 0 front { head { mesh "lamp-front-white" } tail { mesh "lamp-front-red" } } back { head { mesh "lamp-back-white" } tail { mesh "lamp-back-red" } } } misc { begin-load-time 0 begin-unload-time 0 end-load-time 0 end-unload-time 0 } browser-properties { 0 { consist-property-sync 1 property-sync-id "GWRsynctexture" enabled 1 property-visibility 1 name "Current traincar livery: " property-id "p_livery" description "Sets the livery for the carriage" kind "fx-replacement" fx-replacement-type "texture-replacement" effects "livery-main,livery-leftdoor,livery-rightdoor,livery-crest" asset "liveries" values "0;0;0;0,1;1;1;5,2;2;2;6,2;2;2;7,3;3;3;8,4;4;4;8" default-index 1 trigger "user" display-type "link" display-values "Blank,GWR 1922,GWR 1930,GWR 1934,Crimson Cream,Maroon" } 1 { enabled 1 property-visibility 1 name "Night Only: " property-id "p_cfg" description "Sets the Day Night" kind "config-edit" paths "marker-lights/night-only" values "0,1" default-index 0 trigger "user" display-type "link" display-values "False,True" } 2 { enabled 1 property-visibility 1 name "Front Indicator: " property-id "p_front" description "Large F character showing front of carriage" kind "mesh-attachment" mesh-attachment-type "mesh-toggle" meshes "front" values "0,1" default-index 0 duration 2 trigger "user" display-type "link" display-values "Hidden, Visible" } 3 { enabled 1 property-visibility 0 name "Interior lightingr: " property-id "p_interior_lighting" kind "mesh-attachment" mesh-attachment-type "mesh-toggle" meshes "day-interior,night-interior" values "1;0,0;1" default-index 0 duration 2 trigger "event" events "world-day,world-night" } } } } fonts 0 mesh-table { default { mesh "default.lm" auto-create 1 effects { livery-main { kind "texture-replacement" texture "livery.texture" } livery-crest { kind "texture-replacement" texture "crest-crest.texture" } } } day-interior { mesh "interior.lm" auto-create 1 does-cast-shadows 0 lod-level 0 } night-interior { mesh "interior-night.lm" auto-create 0 does-cast-shadows 0 lod-level 0 } coupler-front { mesh-asset <kuid:186372:900007> mesh "screwlink.lm" anim "screwlink.kin" auto-create 1 att "a.couple0" att-parent "default" } coupler-back { mesh-asset <kuid:186372:900007> mesh "screwlink.lm" anim "screwlink.kin" auto-create 1 att "a.couple1" att-parent "default" } vacbrake-front { mesh-asset <kuid:186372:900007> mesh "vac_low_low.lm" anim "vac_low_low.kin" auto-create 1 att "a.couple0" att-parent "default" } vacbrake-back { mesh-asset <kuid:186372:900007> mesh "vac_low_low.lm" anim "vac_low_low.kin" auto-create 1 att "a.couple1" att-parent "default" } heating-front { mesh-asset <kuid:186372:900007> mesh "steamheat.lm" anim "steamheat.kin" auto-create 1 att "a.couple0" att-parent "default" } heating-back { mesh-asset <kuid:186372:900007> mesh "steamheat.lm" anim "steamheat.kin" auto-create 1 att "a.couple1" att-parent "default" } gangway-front { mesh-asset <kuid:186372:900007> mesh "gangway.lm" anim "gangway.kin" auto-create 1 att "a.couple0" att-parent "default" } gangway-back { mesh-asset <kuid:186372:900007> mesh "gangway.lm" anim "gangway.kin" auto-create 1 att "a.couple1" att-parent "default" } lamp-front-red { mesh-asset <kuid:661805:500003> mesh "oil_lamp_red.lm" auto-create 0 att "a.taillamp0" att-parent "default" } lamp-front-white { mesh-asset <kuid:661805:500003> mesh "oil_lamp_white.lm" auto-create 0 att "a.taillamp0" att-parent "default" } lamp-back-red { mesh-asset <kuid:661805:500003> mesh "oil_lamp_red.lm" auto-create 0 att "a.taillamp1" att-parent "default" } lamp-back-white { auto-create 0 mesh-asset <kuid:661805:500003> mesh "oil_lamp_white.lm" att "a.taillamp1" att-parent "default" } front { att-parent "default" att "a.limfront" auto-create 1 mesh "extra_meshes\front.lm" } }