User Tools

Site Tools

Urban Games

modding:railroadcrossings

Railroad Crossings

Railroad Crossings are defined in .lua configuration files in the res/config/railroad_crossing/ folder. They use models that can have certain animation events.

Configuration

The configuration file of a railroad crossing has several properties:

function data()
return {
  name = _("Half-barrier crossing"),
  yearFrom = 1925,
  yearTo = 1975,
  cost = 16000,
  speedLimit = 160.0 / 3.6,
  soundFileName = "railroad_crossing.wav",
  crossingMaterial = "street/railroad_crossing.mtl",
  trafficDelay = 3500,
 
  config = {
    { 
      modelLeft = "railroad/crossing/eu_a_simple.mdl", 
      modelRight = "railroad/crossing/eu_b_barrier_small.mdl", 
      streetWidth = 12.0
    },
  },
}
end

The properties in detail:

  • name is the name of the railroad crossing type that is used in the tooltip. It can be translated in a strings.lua file.
  • yearFrom is the year from when the railroad crossing should be available. Unset or values below 1851 mean from start.
  • yearTo is the year until when the railroad crossing should be available. Unset or value 0 means unlimited availability, values below 1850 result in a never available bridge.
  • cost is the cost for a railroad crossing.
  • speedLimit is the maximum speed in meter per second. If the track has a lower speed restriction, the railroad crossing speed limit is ignored.
  • soundFileName is a reference to a sound effect file relative to the res/audio/effects/ folder that is played while the railroad crossing is closing or closed.
  • crossingMaterial is a material reference for the shape that lays between the two rails of the track. If unset, street/railroad_crossing.mtl is used as fallback .
  • trafficDelay is the time in milliseconds between the begin of the open animation and the point where the road traffic starts to move again. If unset, the animation length is used.

The config block is a list with one or more configuration blocks. Each of the configuration blocks has three properties:

  • modelLeft is the model that is used at the left side of the street in direction towards the crossing.
  • modelRight is the model that is used at the right side of the street in direction towards the crossing.
  • streetWidth is the street width for which the configuration is suited best.

If there is more than one configuration available, the one that matches the actual street width best is chosen.

Events


railroad crossing animations

Railroad crossings support some animation events that are triggered depending on their state. They can be used in mesh nodes of their models to support the visualisation of the two states 'open' and 'closed':

  • forever animation is used for any permanently looped animation.
  • idle_open animation is used as a loop while the railroad crossing is in 'open' state.
  • close animation is used when the railroad crossing switches from 'open' to 'close'.
  • idle_closed animation is used as a loop while the railroad crossing is in 'closed' state.
  • open animation is used when the railroad crossing switches from 'closed' to 'open'.

While the forever animation runs constantly, the other four events form a loop. Usually a railroad crossing is in 'open' state and the idle_open animation is performed. As soon as a train is approaching the close animation is performed once. Then idle_closed is looped as long as the railroad crossing stays closed. When the train is through and the railroad crossing turns back to open, open is performed once before idle_open is looped again.

The idle animations could be used e.g. for blinking lights.

UI icons

The icons for railroad crossings lay in the res/textures/ui/railroad_crossing/ folder and have the same name as the .lua file. It is recommended that the railroad crossing icons have a resolution of 60×38 pixels.

modding/railroadcrossings.txt · Last modified: 2021/06/25 10:08 by yoshi