A vehicle (NFO)

From PikkaWiki
(Difference between revisions)
Jump to: navigation, search
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This is an explanation of how to code a vehicle.  You should have the [http://wiki.ttdpatch.net/tiki-index.php?page=NewGraphicsSpecs wiki] open while you read this, and refer to it.  I will gloss over a lot of things that are explained in detail there.
+
This is an explanation of how to code a vehicle.  You should have the [http://newgrf-specs.tt-wiki.net/wiki/Main_Page wiki] open while you read this, and refer to it.  I will gloss over a lot of things that are explained in detail there.
  
 
__TOC__
 
__TOC__
Line 15: Line 15:
 
</pre>
 
</pre>
  
*The real sprites are the graphics your vehicle will use.  See [http://wiki.ttdpatch.net/tiki-index.php?page=Action1 the wiki page].
+
*The real sprites are the graphics your vehicle will use.  See [http://newgrf-specs.tt-wiki.net/wiki/Action1 the wiki page].
  
*The action 2 gives the graphics a label (a "cargoID", although I prefer to think of it as an Action 2 ID).  See [http://wiki.ttdpatch.net/tiki-index.php?page=Action2Vehicles the wiki page].
+
*The action 2 gives the graphics a label (a "cargoID", although I prefer to think of it as an Action 2 ID).  See [http://newgrf-specs.tt-wiki.net/wiki/Action2/Vehicles the wiki page].
  
 
*The [[VarAction2]]s are decision-making code between the action 3 and the action 2 (nb: ''you read action 2 chains from the bottom up, starting with the action 3 and ending with a "real" action 2!'').  They can also be used to do all kinds of cool tricks with the use of callbacks.  Your first vehicle will probably not have any of these at all, but will simply have an action 3 pointing directly to a "real" action 2.
 
*The [[VarAction2]]s are decision-making code between the action 3 and the action 2 (nb: ''you read action 2 chains from the bottom up, starting with the action 3 and ending with a "real" action 2!'').  They can also be used to do all kinds of cool tricks with the use of callbacks.  Your first vehicle will probably not have any of these at all, but will simply have an action 3 pointing directly to a "real" action 2.
  
*The action 3 is where you tell the vehicle what sprites to use.  See [http://wiki.ttdpatch.net/tiki-index.php?page=Action3 the wiki page].
+
*The action 3 is where you tell the vehicle what sprites to use.  See [http://newgrf-specs.tt-wiki.net/wiki/Action3 the wiki page].
  
*The action 4 sets the name of the vehicle.  See [http://wiki.ttdpatch.net/tiki-index.php?page=Action4 the wiki page].
+
*The action 4 sets the name of the vehicle.  See [http://newgrf-specs.tt-wiki.net/wiki/Action4 the wiki page].
  
*The action 0 sets the properties for the vehicle.  See [http://wiki.ttdpatch.net/tiki-index.php?page=Action0General the wiki page].
+
*The action 0 sets the properties for the vehicle.  See [http://newgrf-specs.tt-wiki.net/wiki/Action0/Vehicles the wiki page].
  
 
==An example==
 
==An example==
Line 31: Line 31:
  
 
<pre>   
 
<pre>   
// My Locomotive (0C) ---------------------------------------------------------------------------------------------
+
// My Locomotive (0C) -----------------------------------------------------------------
  
 
  1290 * 4 01 00 01 08
 
  1290 * 4 01 00 01 08
  1291 SPRITES\myloco.pcx 2 280 01 24 8 -3 -12
+
  1604 SPRITES\myloco.pcx 0 0 01 24 8 -3 -12
  1292 SPRITES\myloco.pcx 12 283 09 18 22 -15 -9
+
  1605 SPRITES\myloco.pcx 16 0 09 17 22 -14 -9
  1293 SPRITES\myloco.pcx 36 283 01 12 32 -16 -8
+
  1606 SPRITES\myloco.pcx 48 0 01 12 32 -16 -8
  1294 SPRITES\myloco.pcx 69 283 09 17 22 -6 -9
+
  1607 SPRITES\myloco.pcx 96 0 09 17 22 -6 -9
  1295 SPRITES\myloco.pcx 94 280 01 24 8 -3 -12
+
  1608 SPRITES\myloco.pcx 128 0 01 24 8 -3 -12
  1296 SPRITES\myloco.pcx 105 283 09 17 22 -14 -9
+
  1609 SPRITES\myloco.pcx 144 0 09 17 22 -14 -9
  1297 SPRITES\myloco.pcx 128 283 01 12 32 -16 -8
+
  1610 SPRITES\myloco.pcx 176 0 01 12 32 -16 -8
  1298 SPRITES\myloco.pcx 161 283 09 18 22 -6 -9
+
  1611 SPRITES\myloco.pcx 224 0 09 17 22 -6 -9
 +
 
 
  1299 * 9 02 00 AA 01 01 00 00 00 00
 
  1299 * 9 02 00 AA 01 01 00 00 00 00
  
  1303 * 10 03 00 01 0C 00 AA
+
  1303 * 10 03 00 01 0C 00 AA 00
  
 
  1304 * 23 04 00 1F 01 0C "My Locomotive (Diesel)" 00
 
  1304 * 23 04 00 1F 01 0C "My Locomotive (Diesel)" 00
Line 55: Line 56:
 
   0D 88            // running cost
 
   0D 88            // running cost
 
   17 25            // purchase cost
 
   17 25            // purchase cost
   19 08            // diesel engine
+
   19 08            // engine type
 
   09 85 00        // speed
 
   09 85 00        // speed
 
   16 \b98          // weight
 
   16 \b98          // weight
Line 63: Line 64:
 
   27 02            // flags
 
   27 02            // flags
 
   21 00            // shortened
 
   21 00            // shortened
   0E 30 4C 00 00  
+
   0E 30 4C 00 00   // run cost base
   05 00  
+
   05 00           // rail type
   06 04  
+
   06 04           // climate
   13 00  
+
   13 00           // doublehead
   14 00  
+
   14 00           // capacity
   15 00
+
   15 00           // cargo
 
   08 00 // AI passenger
 
   08 00 // AI passenger
 
   18 20 // AI rank
 
   18 20 // AI rank
 
</pre>
 
</pre>
 +
[[category:NFO]]

Latest revision as of 13:50, 8 August 2011

This is an explanation of how to code a vehicle. You should have the wiki open while you read this, and refer to it. I will gloss over a lot of things that are explained in detail there.

Contents

[edit] Basic layout

The basic code structure for a vehicle in NFO is as follows:

Real sprites (Action 1)
Action 2
VarAction 2s
Action 3

Action 4
Action 0s
  • The real sprites are the graphics your vehicle will use. See the wiki page.
  • The action 2 gives the graphics a label (a "cargoID", although I prefer to think of it as an Action 2 ID). See the wiki page.
  • The VarAction2s are decision-making code between the action 3 and the action 2 (nb: you read action 2 chains from the bottom up, starting with the action 3 and ending with a "real" action 2!). They can also be used to do all kinds of cool tricks with the use of callbacks. Your first vehicle will probably not have any of these at all, but will simply have an action 3 pointing directly to a "real" action 2.
  • The action 3 is where you tell the vehicle what sprites to use. See the wiki page.
  • The action 0 sets the properties for the vehicle. See the wiki page.

[edit] An example

Here is an example of a simple train locomotive. As you can see, it's quite heavily commented. Don't be afraid to use a lot of comments to remind yourself what's where in your NFO.

  
// My Locomotive (0C) -----------------------------------------------------------------

 1290 * 4	 01 00 01 08
 1604 SPRITES\myloco.pcx 0 0 01 24 8 -3 -12
 1605 SPRITES\myloco.pcx 16 0 09 17 22 -14 -9
 1606 SPRITES\myloco.pcx 48 0 01 12 32 -16 -8
 1607 SPRITES\myloco.pcx 96 0 09 17 22 -6 -9
 1608 SPRITES\myloco.pcx 128 0 01 24 8 -3 -12
 1609 SPRITES\myloco.pcx 144 0 09 17 22 -14 -9
 1610 SPRITES\myloco.pcx 176 0 01 12 32 -16 -8
 1611 SPRITES\myloco.pcx 224 0 09 17 22 -6 -9

 1299 * 9	 02 00 AA 01 01 00 00 00 00

 1303 * 10	 03 00 01 0C 00 AA 00

 1304 * 23	 04 00 1F 01 0C "My Locomotive (Diesel)" 00
 1305 * 57	 00 00 17 01 0C
  12 FD
  00 \w1-1-1960    // introdate
  02 14            // reliability
  03 \b20          // vehicle life
  04 \b40          // class life
  0D 88            // running cost
  17 25            // purchase cost
  19 08            // engine type
  09 85 00         // speed
  16 \b98          // weight
  0B \w2000        // power
  1F 41            // Tractive effort
  1E 00            // callbacks
  27 02            // flags
  21 00            // shortened
  0E 30 4C 00 00   // run cost base
  05 00            // rail type
  06 04            // climate
  13 00            // doublehead
  14 00            // capacity
  15 00            // cargo
  08 00 // AI passenger
  18 20 // AI rank
Personal tools