Hi,
You are having so much fun, so I thought it nice to show how to code a vehicle. Below is the NML code of the engine:
Code: Select all
grf {
grfid: "HK\01\01";
name: string(STR_GRF_NAME);
desc: string(STR_GRF_DESCRIPTION);
version: 0; // Version of this grf, increase with every release.
min_compatible_version: 0; // This grf can be used as replacement for which older grfs?
}
spriteset(spriteset_HK_type_default, "BerlinUbahnHKset_20130809T1055_8bppDOS.png") {
//left_x, upper_y, width, height, offset_x, offset_y
[ 82, 2, 88- 82, 25-2, -3, -11 ] // 2nd 4 images
[ 89, 2, 110- 89, 18-2, -10, -8 ]
[ 111, 2, 140-111, 10-2, -14, -4 ]
[ 141, 2, 162-141, 18-2, -10, -8 ]
[ 1, 2, 7- 1, 25-2, -3, -11 ] // 1st 4 images
[ 8, 2, 29- 8, 18-2, -10, -8 ]
[ 30, 2, 59- 30, 10-2, -14, -4 ]
[ 60, 2, 81- 60, 18-2, -10, -8 ]
}
spritegroup spritegroup_HK_type_default {
loaded: [spriteset_HK_type_default];
loading: [spriteset_HK_type_default];
}
item (FEAT_TRAINS, item_HK_type) {
property {
name: string(STR_HK_TYPE_ENGINE);
climates_available: bitmask(CLIMATE_TEMPERATE);
introduction_date: date(1975, 1, 1);
model_life: 20;
reliability_decay: 20;
refittable_cargo_classes: bitmask(CC_PASSENGERS);
loading_speed: 5;
cost_factor: 1;
running_cost_factor: 1;
cargo_age_period: 185;
sprite_id: SPRITE_ID_NEW_TRAIN;
speed: 80 km/h;
track_type: RAIL;
ai_special_flag : AI_FLAG_PASSENGER;
power: 50;
running_cost_base: RUNNING_COST_ELECTRIC;
default_cargo_type: DEFAULT_CARGO_FIRST_REFITTABLE;
cargo_capacity: 50;
weight: 10 ton;
engine_class: ENGINE_CLASS_DIESEL;
tractive_effort_coefficient: 0.3;
air_drag_coefficient: 0.1;
length: 8;
visual_effect_and_powered: VISUAL_EFFECT_DIESEL;
}
graphics {
default: spritegroup_HK_type_default;
}
}
and the text strings:
Code: Select all
##grflangid 0
STR_GRF_NAME :Berlin U-Bahn grf
STR_GRF_DESCRIPTION :Berlin U-Bahn train vehicles
STR_HK_TYPE_ENGINE :HK-type
I never coded a vehicle, it was easier than expected
I only coded the engine, and invented most of the statistics, so they need adapting a bit.
Also, the x-offset and y-offset are rough guesses, and seem to need some more careful consideration.
Your original image was an RGB image (ie a 24-bit colour image) instead of a 8-bit (256 colours) indexed image, so I converted it to the DOS palette, and attached it again for you. While testing I had to swap the first 4 images and the 2nd 4 images to get it right, perhaps you want to swap direction of your graphics.