Loading
#openttdcoop - Paste
Archives
Trending
Docs
Login
ABAP
ActionScript
ActionScript 3
Ada
AIMMS3
ALGOL 68
Apache configuration
AppleScript
Apt sources
ARM ASSEMBLER
ASM
ASP
asymptote
Autoconf
Autohotkey
AutoIt
AviSynth
awk
BASCOM AVR
Bash
Basic4GL
BibTeX
BlitzBasic
bnf
Boo
Brainfuck
C
C#
C (LoadRunner)
C (Mac)
C (WinAPI)
C++
C++ (Qt)
C++ (WinAPI)
CAD DCL
CAD Lisp
CFDG
ChaiScript
Chapel
CIL
Clojure
CMake
COBOL
CoffeeScript
ColdFusion
CSS
Cuesheet
D
Dart
DCL
DCPU-16 Assembly
DCS
Delphi
Diff
DIV
DOS
dot
E
ECMAScript
Eiffel
eMail (mbox)
EPC
Erlang
Euphoria
EZT
F#
Falcon
FO (abas-ERP)
Formula One
Fortran
FreeBasic
FreeSWITCH
GADV 4CS
GAMBAS
GDB
genero
Genie
glSlang
GML
GNU/Octave
GNU Gettext
GNU make
Gnuplot
Go
Groovy
GwBasic
Haskell
Haxe
HicEst
HQ9+
HTML
HTML5
Icon
INI
Inno
INTERCAL
Io
ISPF Panel
J
Java
Java(TM) 2 Platform Standard Edition 5.0
Javascript
JCL
jQuery
KiXtart
KLone C
KLone C++
LaTeX
LDIF
Liberty BASIC
Lisp
LLVM Intermediate Representation
Locomotive Basic
Logtalk
LOLcode
Lotus Notes @Formulas
LotusScript
LScript
LSL2
Lua
MagikSF
MapBasic
Matlab M
Microchip Assembler
Microsoft Registry
mIRC Scripting
MMIX
Modula-2
Modula-3
MOS 6502 (6510) ACME Cross Assembler format
MOS 6502 (6510) Kick Assembler format
MOS 6502 (6510) TASM/64TASS 1.46 Assembler format
Motorola 68000 - HiSoft Devpac ST 2 Assembler format
Motorola 68000 Assembler
MXML
MySQL
Nagios
NetRexx
newlisp
nginx
Nimrod
NML NewGRF Meta Language
NSIS
Oberon-2
Objeck Programming Language
Objective-C
OCaml
OCaml (brief)
ooRexx
OpenBSD Packet Filter
OpenOffice.org Basic
Oracle 8 SQL
Oracle 11 SQL
Oxygene
OZ
ParaSail
PARI/GP
Pascal
PCRE
per
Perl
Perl 6
PHP
PHP (brief)
PIC16
Pike
Pixel Bender 1.0
PL/I
PL/SQL
PostgreSQL
PostScript
POVRAY
PowerBuilder
PowerShell
ProFTPd configuration
Progress
Prolog
PROPERTIES
ProvideX
Puppet
PureBasic
Python
Python for S60
q/kdb+
QBasic/QuickBASIC
QML
R / S+
Racket
Rails
RBScript
REBOL
rexx
robots.txt
RPM Specification File
Ruby
Rust
SAS
Scala
Scheme
SciLab
SCL
sdlBasic
Smalltalk
Smarty
SPARK
SPARQL
SQL
Squirrel Script
Squirrel Script with OpenTTD AI/GS
StandardML
StoneScript
SystemVerilog
T-SQL
TCL
Tera Term Macro
Text
thinBasic
TypoScript
Unicon (Unified Extended Dialect of Icon)
Uno Idl
Unreal Script
UPC
Urbi
Vala
vb.net
VBScript
Vedit macro language
Verilog
VHDL
Vim Script
Visual Basic
Visual Fox Pro
Visual Prolog
Whitespace
Whois (RPSL format)
Winbatch
X++
XBasic
XML
Xorg configuration
YAML
ZiLOG Z80 Assembler
ZXBasic
/* * This file is aimed to provide an example on how to code a vehicle in NML * In this case a road vehicle is coded, other vehicle types work in a similar fashion. * To keep the code readable, not every property or variable is documented in * detail, refer to the vehicle-specific reference in the documentation. * The coded vehicle is relatively simple. Apart from the minimum required, * it has cargo-specific capacaity and graphics. For a more advanced example, * refer to the train example. * * The vehicle coded here is a first-generation flatbed truck. * It is taken from OpenGFX+ Road Vehicles, with some modifications * to provide a better example. Original graphics are by DanMack and Zephyris, * coding by Terkhen and planetmaker. * * Apart from this file, you will also need the following * - Graphics, found in 'gfx' folder. * - Language files, to be placed in the 'lang' folder. * Currently only english.lng is supplied. */ /* * First, define a grf block. This defines some basic properties of the grf, * which are required for the grf to be valid and loadable. Additionally, * user-configurable parameters are defined here also. */ grf { /* This grf is part of NML, therefore "NML" is chosen as the first three * characters of the GRFID. It is the fourth real grf defined as part of * NML, therefore the last character is set to 3 as numbering is zero-based. * Successive grfs will have 4, 5, etc., to make sure each example grf has * a unique GRFID. */ grfid: "NML\03"; /* GRF name and description strings are defined in the lang files */ name: string(STR_GRF_NAME); desc: string(STR_GRF_DESC); /* This is the first version, start numbering at 0. */ version: 0; min_compatible_version: 0; } /* Check for engine pool */ if (!dynamic_engines) { error(ERROR, USED_WITH, string(STR_ERROR_ENGINE_POOL)); } /* Define a cargo translation table * All cargo types that need any special treatment must be included here * Add cargos used in the refit mask first, as those are limited to 32 bits * so these cargos must be within the first 32 entries */ cargotable { /* Used in refit mask */ LVST, // Livestock (piece goods) WOOL, // Wool (piece goods, covered) SCRP, // Scrap metal (bulk) FICR, // Fibre crops (bulk, piece goods) PETR, // Petrol / fuel oil (liquid) RFPR, // Refined products (liquid) /* Not used in refit mask */ GOOD, // Goods (express) ENSP, // Engineering supplies (express, piece goods) FMSP, // Farm supplies (express, piece goods) MNSP, // Manufacturing supplies (express, piece goods) PAPR, // Paper (piece goods) STEL, // Steel (piece goods) VEHI, // Vehicles (piece goods, oversized) COPR, // Copper (piece goods) WOOD, // Wood (piece goods) } roadtypetable { ROAD, BLUE, YELL, RED_TEST: [RED_, BLUE, ROAD] } /* Sprite template for a truck */ template tmpl_truck(x) { [ 0 + x, 0, 8, 18, -3, -10] [ 16 + x, 0, 20, 16, -14, -7] [ 48 + x, 0, 28, 12, -14, -6] [ 96 + x, 0, 20, 16, -6, -7] [ 128 + x, 0, 8, 18, -3, -10] [ 144 + x, 0, 20, 16, -14, -7] [ 176 + x, 0, 28, 12, -14, -6] [ 224 + x, 0, 20, 16, -6, -7] } /* Define various cargo-specific graphics */ /* Paper */ spriteset(flatbed_truck_1_paper_empty, "gfx/flatbed_truck_1_paper.png") { tmpl_truck(0) } spriteset(flatbed_truck_1_paper_full, "gfx/flatbed_truck_1_paper.png") { tmpl_truck(260) } spritegroup flatbed_truck_1_paper { loaded: [flatbed_truck_1_paper_empty, flatbed_truck_1_paper_full]; loading: [flatbed_truck_1_paper_empty, flatbed_truck_1_paper_full]; } /* Steel */ spriteset(flatbed_truck_1_steel_empty, "gfx/flatbed_truck_1_steel.png") { tmpl_truck(0) } spriteset(flatbed_truck_1_steel_full, "gfx/flatbed_truck_1_steel.png") { tmpl_truck(260) } spritegroup flatbed_truck_1_steel { loaded: [flatbed_truck_1_steel_empty, flatbed_truck_1_steel_full]; loading: [flatbed_truck_1_steel_empty, flatbed_truck_1_steel_full]; } /* Wood */ spriteset(flatbed_truck_1_wood_empty, "gfx/flatbed_truck_1_wood.png") { tmpl_truck(0) } spriteset(flatbed_truck_1_wood_full, "gfx/flatbed_truck_1_wood.png") { tmpl_truck(260) } spritegroup flatbed_truck_1_wood { loaded: [flatbed_truck_1_wood_empty, flatbed_truck_1_wood_full]; loading: [flatbed_truck_1_wood_empty, flatbed_truck_1_wood_full]; } /* Copper */ spriteset(flatbed_truck_1_copper_empty, "gfx/flatbed_truck_1_copper.png") { tmpl_truck(0) } spriteset(flatbed_truck_1_copper_full, "gfx/flatbed_truck_1_copper.png") { tmpl_truck(260) } spritegroup flatbed_truck_1_copper { loaded: [flatbed_truck_1_copper_empty, flatbed_truck_1_copper_full]; loading: [flatbed_truck_1_copper_empty, flatbed_truck_1_copper_full]; } /* Goods */ spriteset(flatbed_truck_1_goods_empty, "gfx/flatbed_truck_1_goods.png") { tmpl_truck(0) } spriteset(flatbed_truck_1_goods_full, "gfx/flatbed_truck_1_goods.png") { tmpl_truck(260) } spritegroup flatbed_truck_1_goods { loaded: [flatbed_truck_1_goods_empty, flatbed_truck_1_goods_full]; loading: [flatbed_truck_1_goods_empty, flatbed_truck_1_goods_full]; } /* Decide capacity based on cargo type (cargo_capacity callback) * cargo_type_in_veh is available in the purchase list also, * so a separate CB for in the purchase list is not needed */ switch (FEAT_ROADVEHS, SELF, flatbed_truck_1_capacity_switch, cargo_type_in_veh) { GOOD: return 14; ENSP: return 14; FMSP: return 14; MNSP: return 14; PAPR: return 15; PETR: return 10; RFPR: return 10; STEL: return 15; VEHI: return 12; return 20; } /* Define the road vehicle */ item(FEAT_ROADVEHS, flatbed_truck_1) { property { /* Properties common to all vehicle types */ name: string(STR_NAME_FLATBED_TRUCK_1); climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL); road_type: ROAD; introduction_date: date(1926,01,01); model_life: 65; /* retire_early not set, use default retirement behaviour */ vehicle_life: 15; reliability_decay: 20; refittable_cargo_classes: bitmask(CC_PIECE_GOODS, CC_EXPRESS); non_refittable_cargo_classes: bitmask(CC_PASSENGERS, CC_REFRIGERATED); /* Livestock, wool and fibre crops can be transported acc. cargo classes * But we don't want that, so disable refitting for them. * Scrap metal, petrol and refined products cannot be transported acc. cargo classes * We do want to transport those, so enable refitting for them. */ cargo_allow_refit: [LVST, WOOL, SCRP, FICR, PETR, RFPR]; cargo_disallow_refit: []; // we allow other cargoes, if class matches loading_speed: 5; cost_factor: 108; running_cost_factor: 90; /* cargo_age_period is left at default */ /* RV-specific properties */ sprite_id: SPRITE_ID_NEW_ROADVEH; speed: 48 km/h; misc_flags: bitmask(ROADVEH_FLAG_2CC); refit_cost: 0; // Refitting is free /* callback_flags are not set, no need to manually enable callbacks */ running_cost_base: RUNNING_COST_ROADVEH; power: 120 hp; weight: 9.5 ton; /* TE and air drag coefficient is left at default */ cargo_capacity: 20; // Changed by callback sound_effect: SOUND_BUS_START_PULL_AWAY; /* Visual effect is left at default (no effect) */ } /* Define graphics for various cargo types, as well as the capacity callback */ graphics { cargo_capacity: flatbed_truck_1_capacity_switch; PAPR: flatbed_truck_1_paper; STEL: flatbed_truck_1_steel; COPR: flatbed_truck_1_copper; WOOD: flatbed_truck_1_wood; default: flatbed_truck_1_goods; // Default to Goods. } } /* Define the road vehicle */ item(FEAT_ROADVEHS, flatbed_truck_2) { property { /* Properties common to all vehicle types */ name: string(STR_NAME_FLATBED_TRUCK_2); climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL); road_type: BLUE; introduction_date: date(1926,01,01); model_life: 65; /* retire_early not set, use default retirement behaviour */ vehicle_life: 15; reliability_decay: 20; refittable_cargo_classes: bitmask(CC_PIECE_GOODS, CC_EXPRESS); non_refittable_cargo_classes: bitmask(CC_PASSENGERS, CC_REFRIGERATED); /* Livestock, wool and fibre crops can be transported acc. cargo classes * But we don't want that, so disable refitting for them. * Scrap metal, petrol and refined products cannot be transported acc. cargo classes * We do want to transport those, so enable refitting for them. */ cargo_allow_refit: [LVST, WOOL, SCRP, FICR, PETR, RFPR]; cargo_disallow_refit: []; // we allow other cargoes, if class matches loading_speed: 5; cost_factor: 108; running_cost_factor: 90; /* cargo_age_period is left at default */ /* RV-specific properties */ sprite_id: SPRITE_ID_NEW_ROADVEH; speed: 48 km/h; misc_flags: bitmask(ROADVEH_FLAG_2CC); refit_cost: 0; // Refitting is free /* callback_flags are not set, no need to manually enable callbacks */ running_cost_base: RUNNING_COST_ROADVEH; power: 120 hp; weight: 9.5 ton; /* TE and air drag coefficient is left at default */ cargo_capacity: 20; // Changed by callback sound_effect: SOUND_BUS_START_PULL_AWAY; /* Visual effect is left at default (no effect) */ } /* Define graphics for various cargo types, as well as the capacity callback */ graphics { cargo_capacity: flatbed_truck_1_capacity_switch; PAPR: flatbed_truck_1_paper; STEL: flatbed_truck_1_steel; COPR: flatbed_truck_1_copper; WOOD: flatbed_truck_1_wood; default: flatbed_truck_1_goods; // Default to Goods. } } /* Define the road vehicle */ item(FEAT_ROADVEHS, flatbed_truck_3) { property { /* Properties common to all vehicle types */ name: string(STR_NAME_FLATBED_TRUCK_3); climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL); road_type: RED_TEST; introduction_date: date(1926,01,01); model_life: 65; /* retire_early not set, use default retirement behaviour */ vehicle_life: 15; reliability_decay: 20; refittable_cargo_classes: bitmask(CC_PIECE_GOODS, CC_EXPRESS); non_refittable_cargo_classes: bitmask(CC_PASSENGERS, CC_REFRIGERATED); /* Livestock, wool and fibre crops can be transported acc. cargo classes * But we don't want that, so disable refitting for them. * Scrap metal, petrol and refined products cannot be transported acc. cargo classes * We do want to transport those, so enable refitting for them. */ cargo_allow_refit: [LVST, WOOL, SCRP, FICR, PETR, RFPR]; cargo_disallow_refit: []; // we allow other cargoes, if class matches loading_speed: 5; cost_factor: 108; running_cost_factor: 90; /* cargo_age_period is left at default */ /* RV-specific properties */ sprite_id: SPRITE_ID_NEW_ROADVEH; speed: 48 km/h; misc_flags: bitmask(ROADVEH_FLAG_2CC); refit_cost: 0; // Refitting is free /* callback_flags are not set, no need to manually enable callbacks */ running_cost_base: RUNNING_COST_ROADVEH; power: 120 hp; weight: 9.5 ton; /* TE and air drag coefficient is left at default */ cargo_capacity: 20; // Changed by callback sound_effect: SOUND_BUS_START_PULL_AWAY; /* Visual effect is left at default (no effect) */ } /* Define graphics for various cargo types, as well as the capacity callback */ graphics { cargo_capacity: flatbed_truck_1_capacity_switch; PAPR: flatbed_truck_1_paper; STEL: flatbed_truck_1_steel; COPR: flatbed_truck_1_copper; WOOD: flatbed_truck_1_wood; default: flatbed_truck_1_goods; // Default to Goods. } }
Mark as private
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
forever