I am now doing some small NewGRF, and have run into problem. I can't seem to be able to make an user parameter switch work. At this moment it does not even compile. Compiler says, that there is an unrecognized identifier at line 143. At that line is an if switch, which I want to use to disable some stuff, if boolean parameter is set at "1". Exactly at that line is some literal train id from my code, which I want to disable if user decides to do so. Here is the code:
Code: Select all
grf {
grfid: "MG\04\01";
name: string(STR_GRF_NAME);
desc: string(STR_GRF_DESCRIPTION);
version: 0;
min_compatible_version: 0;
param 1{
metro {
type: bool;
name: string(STR_PARAM1_NAME);
desc: string(STR_PARAM1_DESC);
def_value: 0;
bit: 0;
names: {
0: string(STR_PARAM1_ON);
1: string(STR_PARAM1_OFF);
};
}
}
}
railtypetable {
RAIL, SAAN, SAA3
}
spriteset (spriteset_MUV_off, "gfx/muv.png") {
//left_x, upper_y, width, height, offset_x, offset_y
[ 0, 0, 8, 14, -3, -7]
[50, 0, 11, 12, -5, -7]
[100, 0, 16, 11, -8, -5]
[150, 0, 11, 12, -5, -7]
[200, 0, 8, 14, -3, -7]
[250, 0, 11, 12, -5, -7]
[300, 0, 16, 11, -8, -5]
[350, 0, 11, 12, -5, -7]
}
spriteset (spriteset_MUV_on, "gfx/muv.png") {
//left_x, upper_y, width, height, offset_x, offset_y
[ 0, 50, 8, 14, -3, -7]
[50, 50, 11, 12, -5, -7]
[100, 50, 16, 11, -8, -5]
[150, 50, 11, 12, -5, -7]
[200, 50, 8, 14, -3, -7]
[250, 50, 11, 12, -5, -7]
[300, 50, 16, 11, -8, -5]
[350, 50, 11, 12, -5, -7]
}
spriteset (spriteset_MUV_VV, "gfx/muv.png") {
//left_x, upper_y, width, height, offset_x, offset_y
[ 0, 100, 8, 10, -3, -7]
[50, 100, 11, 6, -5, -7]
[100, 100, 11, 16, -8, -5]
[150, 100, 11, 6, -5, -7]
[200, 100, 8, 10, -3, -7]
[250, 100, 11, 6, -5, -7]
[300, 100, 11, 16, -8, -5]
[350, 100, 11, 6, -5, -7]
}
/* lights on only, if running */
switch(FEAT_TRAINS, SELF, sw_MUV_graphics, vehicle_is_stopped) {
0: spriteset_MUV_on;
spriteset_MUV_off;
}
item(FEAT_TRAINS, item_MUV) {
property {
name: string(STR_NAME_MUV);
climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL, CLIMATE_TOYLAND);
introduction_date: date(1969, 1, 1);
model_life: VEHICLE_NEVER_EXPIRES;
vehicle_life: 255;
reliability_decay: 255;
refittable_cargo_classes: bitmask();
non_refittable_cargo_classes: bitmask();
loading_speed: 12;
cost_factor: 0;
running_cost_factor: 0;
sprite_id: SPRITE_ID_NEW_TRAIN;
speed: 40 km/h;
misc_flags: bitmask();
refit_cost: 0;
track_type: RAIL;
ai_special_flag: AI_FLAG_PASSENGER;
power: 81 kW;
running_cost_base: RUNNING_COST_NONE;
dual_headed: 0;
cargo_capacity: 0;
weight: 9 ton;
ai_engine_rank: 0; // not intended to be used by the ai
engine_class: ENGINE_CLASS_DIESEL;
extra_power_per_wagon: 0 kW;
tractive_effort_coefficient: 0.5 / 3;
air_drag_coefficient: 0.2;
visual_effect_and_powered: visual_effect_and_powered(VISUAL_EFFECT_DIESEL, 2, DISABLE_WAGON_POWER);
extra_weight_per_wagon: 0 ton;
bitmask_vehicle_info: 0;
length: 4;
}
graphics {
default: sw_MUV_graphics;
}
}
item(FEAT_TRAINS, item_MUV_VV) {
property {
name: string(STR_NAME_MUV_VV);
climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL, CLIMATE_TOYLAND);
introduction_date: date(1969, 1, 1);
model_life: VEHICLE_NEVER_EXPIRES;
vehicle_life: 255;
reliability_decay: 255;
refittable_cargo_classes: bitmask();
non_refittable_cargo_classes: bitmask();
loading_speed: 0;
cost_factor: 0;
running_cost_factor: 0;
sprite_id: SPRITE_ID_NEW_TRAIN;
speed: 40 km/h;
misc_flags: bitmask();
refit_cost: 0;
track_type: RAIL;
ai_special_flag: AI_FLAG_PASSENGER;
running_cost_base: RUNNING_COST_NONE;
dual_headed: 0;
cargo_capacity: 0;
weight: 2 ton;
extra_power_per_wagon: 0 kW;
air_drag_coefficient: 0.26;
extra_weight_per_wagon: 0 ton;
bitmask_vehicle_info: 0;
length: 4;
}
graphics {
default: spriteset_MUV_VV;
}
}
if (param [metro] == 1) {
disable_item (FEAT_TRAINS, item_MUV_METRO) ;
} else {
}
if (param [metro] == 1) {
disable_item (FEAT_TRAINS, item_MUV_VV_METRO) ;
} else {
}
/* lights on only, if running */
switch(FEAT_TRAINS, SELF, sw_MUV_METRO_graphics, vehicle_is_stopped) {
0: spriteset_MUV_on;
spriteset_MUV_off;
}
item(FEAT_TRAINS, item_MUV_METRO) {
property {
name: string(STR_NAME_MUV_METRO);
climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL, CLIMATE_TOYLAND);
introduction_date: date(1969, 1, 1);
model_life: VEHICLE_NEVER_EXPIRES;
vehicle_life: 255;
reliability_decay: 255;
refittable_cargo_classes: bitmask();
non_refittable_cargo_classes: bitmask();
loading_speed: 12;
cost_factor: 0;
running_cost_factor: 0;
sprite_id: SPRITE_ID_NEW_TRAIN;
speed: 40 km/h;
misc_flags: bitmask();
refit_cost: 0;
track_type: SAA3;
ai_special_flag: AI_FLAG_PASSENGER;
power: 81 kW;
running_cost_base: RUNNING_COST_NONE;
dual_headed: 0;
cargo_capacity: 0;
weight: 9 ton;
ai_engine_rank: 0; // not intended to be used by the ai
engine_class: ENGINE_CLASS_DIESEL;
extra_power_per_wagon: 0 kW;
tractive_effort_coefficient: 0.5 / 3;
air_drag_coefficient: 0.2;
visual_effect_and_powered: visual_effect_and_powered(VISUAL_EFFECT_DIESEL, 2, DISABLE_WAGON_POWER);
extra_weight_per_wagon: 0 ton;
bitmask_vehicle_info: 0;
length: 4;
}
graphics {
default: sw_MUV_METRO_graphics;
}
}
item(FEAT_TRAINS, item_MUV_VV_METRO) {
property {
name: string(STR_NAME_MUV_VV_METRO);
climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL, CLIMATE_TOYLAND);
introduction_date: date(1969, 1, 1);
model_life: VEHICLE_NEVER_EXPIRES;
vehicle_life: 255;
reliability_decay: 255;
refittable_cargo_classes: bitmask();
non_refittable_cargo_classes: bitmask();
loading_speed: 0;
cost_factor: 0;
running_cost_factor: 0;
sprite_id: SPRITE_ID_NEW_TRAIN;
speed: 40 km/h;
misc_flags: bitmask();
refit_cost: 0;
track_type: SAA3;
ai_special_flag: AI_FLAG_PASSENGER;
running_cost_base: RUNNING_COST_NONE;
dual_headed: 0;
cargo_capacity: 0;
weight: 2 ton;
extra_power_per_wagon: 0 kW;
air_drag_coefficient: 0.26;
extra_weight_per_wagon: 0 ton;
bitmask_vehicle_info: 0;
length: 4;
}
graphics {
default: spriteset_MUV_VV;
}
}
Thanks for help!