This template accepts cost data for an item in the TrainStation game (usually in the Shop) in text form.
It then returns the item's cost in a consistent order, using formatted numbers and the appropriate graphic for each resource.


  • {{Cost|<resource1=amount1>|<resource2=amount2>|<resource3=amount3>|<discount=type>|<line=y>|<cont=y>|<qty=#>}}
    • resource1, resource2, resource3 = the names of the 18 different resources in the TrainStation game: gems, gold, and the 16 materials. (Each material can be abbreviated to its first 4 characters)
      amount1, amount2, amount3 = the amounts required of resource1, resource2, and resource3, respectively, to purchase an item. Always use plain numbers with no formatting, e.g. 1000000 (NOT 1,000,000 or 1.000.000 or 1 000 000).
      resource2, and resource3, and their corresponding values, are optional. If the item requires only one or two resources, simply close the {{braces}}. DO NOT add extra pipes (|) for the unnecessary parameters.
      Gems (Gems) always appear alone in an item's cost. No item in the game has a cost that includes gems plus another resource.
    • Optional parameter discount, if present, will calculate a discount on each cost. For a complete list of features, visit Discounts
      • The following discounts are available:
      To reverse the discount, place a minus sign (-) before the discount type
    • Optional parameter line, if present, will cause the output to display on one line, horizontally.
    • The parameters below should be used only within a contract list on a contractor's page.
      • Optional parameter cont, if present, will format the output for display in a contract list on a contractor's page: horizontally as with line, preceded by a bullet and the word "Cost", all in italics.
      • Optional parameter qty, if present, will multiply each resource amount by the quantity specified. This allows for easy input when contractors require two or more identical buildings or decorations in a contract objective, while producing accurate and consistent cost totals.
        To use this parameter, enter resource amounts for one of the item, then add |qty=# to the template call, where #= the quantity of the item required by the contract objective.
NOTE: The parameters can be in any order.

Sample output

  • {{Cost|gold=100000000}}
    • 100,000,000 Gold
  • {{Cost|gold=100000000|disc=flag}}
    • 75,000,000 Gold
  • {{Cost|gold=100000000|wood=46581}}
    • 100,000,000 Gold
      46,581 Wood
  • {{Cost|gold=100000000|steel=485452|wood=46581}}
    • 100,000,000 Gold
      46,581 Wood
      485,452 Steel
  • {{Cost|gold=100000000|steel=485452|wood=46581|disc=building}}
    • 90,000,000 Gold
      41,923 Wood
      436,907 Steel
  • {{Cost}}
    • Free
  • {{Cost|}}
    • Free

  • Example inside a shop table:
    • {{ShopTable}}
Name Contract Cost Buy XP Pass. Inc. Space Income/Space
Test 12,345 Gold
4 Silicon
99 1 12 1 1.00
Test 9,876 Gold
3 Silicon
99 1 12 1 1.00

  • Example inside a contract list:
    • {|
      | Build 1 [[Pony Express Office]] <br> {{cost|wood=100|nail=100|cont=y}}
      | Build 1 [[Pony Express Office]] <br> {{cost|wood=100|nail=100|cont=y|disc=building}}
Build 1 Pony Express Office
• Cost: 100 Wood; 100 Nails
Build 1 Pony Express Office
• Cost: 90 Wood; 90 Nails

  • Example inside a contract list, with multiple quantity:
    • {|
      | Build 3 [[Eiffel Monument]] <br> {{cost|gold=30000|stee=45000|grav=30000|cont=y|qty=3}}
Build 3 Eiffel Monument
• Cost: 90,000 Gold; 135,000 Steel; 90,000 Gravel

About the template

The structure of the template is in four parts:

  1. The discount framework, where the optional discount are implemented
    • If the discount parameter isn’t used then all costs are multiplied with 1
    • If the discount parameter contains a typed discount, a set value corresponding to the typed discount is multiplied with all costs.
    • If the discount parameter contains a minus sign (-), then the inverse of the value is multiplied with all costs.
  2. The Material framework
    • The code in this framework checks for which materials are used as a cost, calculates a total price if needed, with discount, if required, and preformats the output text
    • The code support at least one 4 character abbreviation for each type of material
  3. The result
    • The final formatting of the text is done here
    • If no parameters are fed to the template, it will return the text Free
  4. The documentation


This template was created by Koppa Dasao.
Although the TrainStation Wiki community have improved the original template, it still uses Koppa Dasao's logic and structure.

Community content is available under CC-BY-SA unless otherwise noted.