Loading

Paste #pntip1imo

  1. /*
  2.  * This file is aimed to provide an example on how to code a basic industry in NML.
  3.  * To keep the code readable, not every property or variable is documented in
  4.  * detail, refer to the object-specific reference in the documentation.
  5.  *
  6.  * This version shows only how to modify a built-in industry.
  7.  *
  8.  * Apart from this file, you will also need the following
  9.  * - Language files, to be placed in the 'lang' folder.
  10.  *      Currently english.lng is supplied.
  11.  */
  12.  
  13. /**********************************************
  14.  * Header, containing some general stuff:
  15.  **********************************************/
  16.  
  17.  /*
  18.  * First, define a grf block. This defines some basic properties of the grf,
  19.  * which are required for the grf to be valid and loadable.
  20.  */
  21. grf {
  22.     /* This grf is part of NML, therefore "NML" is chosen as the first three
  23.      * characters of the GRFID. It is the third real grf defined as part of
  24.      * NML, therefore the last character is set to 2. Successive grfs will
  25.      * have 3, 4, etc. there, to make sure each example grf has a unique GRFID.
  26.      */
  27.     grfid : "NML\04";
  28.     name : string(STR_GRF_NAME);
  29.     desc : string(STR_GRF_DESCRIPTION);
  30.     version : 0; // must be numeric
  31.     min_compatible_version : 0;
  32. }
  33.  
  34.  
  35. /* this example assumes we're just matching to the default temperate cargos, this wouldn't be the usual case
  36. cargotable {
  37.     PASS, COAL, MAIL, OIL_, LVST, WOOD, GRAI, WOOD, IORE, STEL, VALU
  38. }
  39.  
  40. /*
  41. * This example extends the cargos accepted and produce by the default temperate factory.
  42. */
  43. item(FEAT_INDUSTRIES, factory) {
  44.     property {
  45.         substitute: INDUSTRYTYPE_TEMPERATE_FACTORY;
  46.         override: INDUSTRYTYPE_TEMPERATE_FACTORY;
  47.         accept_cargo_types: [cargotype("COAL"), cargotype("OIL_"),
  48.                              cargotype("LVST"), cargotype("WOOD"),
  49.                              cargotype("IORE"), cargotype("GRAI")]; // prop 25 (tested working)
  50.         prod_cargo_types: [cargotype("MAIL"), cargotype("GOOD"),
  51.                            cargotype("STEL"), cargotype("VALU")];  // prop 26 (tested working)
  52.         input_multiplier: [               // prop 28 (tested working)
  53.             [1  , 1, 1, 1  ], // 1st input cargo produces one of each output
  54.             [1  , 1, 0, 0  ], // 2nd input cargo produces only first two outputs
  55.             [0  , 0, 4, 0  ], // 3rd input cargo produces third output four times the input amount
  56.             [0.5, 0, 0, 0.5]  // 4th input cargo produces each of first and fourth output cargo in half the input amount (2 in => 1 of first and 1 of fourth out)
  57.         ];
  58.     }
  59. }
  60.  
  61. item(FEAT_INDUSTRYTILES, factory_tile_1) {
  62.     property {
  63.         substitute:        39;
  64.         override:          39;
  65.         special_flags: bitmask(INDTILE_FLAG_ACCEPT_ALL);
  66.     }
  67. }
  68. item(FEAT_INDUSTRYTILES, factory_tile_2) {
  69.     property {
  70.         substitute:        40;
  71.         override:          40;
  72.         special_flags: bitmask(INDTILE_FLAG_ACCEPT_ALL);
  73.     }
  74. }
  75. item(FEAT_INDUSTRYTILES, factory_tile_3) {
  76.     property {
  77.         substitute:        41;
  78.         override:          41;
  79.         special_flags: bitmask(INDTILE_FLAG_ACCEPT_ALL);
  80.     }
  81. }
  82. item(FEAT_INDUSTRYTILES, factory_tile_4) {
  83.     property {
  84.         substitute:        42;
  85.         override:          42;
  86.         special_flags: bitmask(INDTILE_FLAG_ACCEPT_ALL);
  87.     }
  88. }
  89.  
  90. /*
  91. * This example causes the default farm to produce livestock, grain, and wood.
  92. */
  93. item(FEAT_INDUSTRIES, farm) {
  94.     property {
  95.         substitute: INDUSTRYTYPE_TEMPERATE_ARCTIC_FARM;
  96.         override: INDUSTRYTYPE_TEMPERATE_ARCTIC_FARM;
  97.         prod_cargo_types: [4, 6, 7];
  98.         prod_multiplier: [8, 12, 4]; // prop 27 (tested working)
  99.     }
  100. }

Comments