A vehicle (NFO)

From PikkaWiki
(Difference between revisions)
Jump to: navigation, search
Line 19: Line 19:
 
*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://wiki.ttdpatch.net/tiki-index.php?page=Action2Vehicles 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 [[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://wiki.ttdpatch.net/tiki-index.php?page=Action3 the wiki page].
Line 26: Line 26:
  
 
*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://wiki.ttdpatch.net/tiki-index.php?page=Action0General the wiki page].
 +
 +
==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.
 +
 +
<pre> 
 +
// My Locomotive (0C) ---------------------------------------------------------------------------------------------
 +
 +
1290 * 4 01 00 01 08
 +
1291 SPRITES\myloco.pcx 2 280 01 24 8 -3 -12
 +
1292 SPRITES\myloco.pcx 12 283 09 18 22 -15 -9
 +
1293 SPRITES\myloco.pcx 36 283 01 12 32 -16 -8
 +
1294 SPRITES\myloco.pcx 69 283 09 17 22 -6 -9
 +
1295 SPRITES\myloco.pcx 94 280 01 24 8 -3 -12
 +
1296 SPRITES\myloco.pcx 105 283 09 17 22 -14 -9
 +
1297 SPRITES\myloco.pcx 128 283 01 12 32 -16 -8
 +
1298 SPRITES\myloco.pcx 161 283 09 18 22 -6 -9
 +
1299 * 9 02 00 AA 01 01 00 00 00 00
 +
 +
1303 * 10 03 00 01 0C 00 AA
 +
 +
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            // diesel engine
 +
  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
 +
  05 00
 +
  06 04
 +
  13 00
 +
  14 00
 +
  15 00
 +
  08 00 // AI passenger
 +
  18 20 // AI rank
 +
</pre>

Revision as of 23:54, 11 May 2007

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

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.

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
 1291 SPRITES\myloco.pcx 2 280 01 24 8 -3 -12
 1292 SPRITES\myloco.pcx 12 283 09 18 22 -15 -9
 1293 SPRITES\myloco.pcx 36 283 01 12 32 -16 -8
 1294 SPRITES\myloco.pcx 69 283 09 17 22 -6 -9
 1295 SPRITES\myloco.pcx 94 280 01 24 8 -3 -12
 1296 SPRITES\myloco.pcx 105 283 09 17 22 -14 -9
 1297 SPRITES\myloco.pcx 128 283 01 12 32 -16 -8
 1298 SPRITES\myloco.pcx 161 283 09 18 22 -6 -9
 1299 * 9	 02 00 AA 01 01 00 00 00 00

 1303 * 10	 03 00 01 0C 00 AA

 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            // diesel engine
  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 
  05 00 
  06 04 
  13 00 
  14 00 
  15 00
  08 00 // AI passenger
  18 20 // AI rank
Personal tools