Hey ! i'm experiencing a similar issue with a "load triggered" random switch.
I created a flatbed wagon using the following code : (i removed some repetitive parts as it has like 10 liveries and as many container variants)
Code: Select all
// CONTAINERS
spritegroup flatbed_container_spritegroup_a {
loading: [flatbed_empty, flatbed_container_1a, flatbed_container_1b];
loaded: [flatbed_empty, flatbed_container_1b]; }
spritegroup flatbed_container_spritegroup_h {
loading: [flatbed_empty_8, flatbed_container_8a, flatbed_container_8b];
loaded: [flatbed_empty_8, flatbed_container_8b, flatbed_container_8b]; }
random_switch (FEAT_TRAINS, SELF, flatbed_container_spritegroup_switch, bitmask(TRIGGER_VEHICLE_UNLOAD_ALL)) {
1: flatbed_container_spritegroup_a;
1: flatbed_container_spritegroup_h; }
// SWITCHES
random_switch(FEAT_TRAINS, SELF, flatbed_randomlivery_switch) {
1: flatbed_sprite_0;
1: flatbed_sprite_1;
}
switch(FEAT_TRAINS, SELF, flatbed_livery_switch, cargo_subtype) {
1: flatbed_sprite_0;
2: flatbed_sprite_1;
flatbed_randomlivery_switch;
}
// CARGO SUBTYPE CALLBACK
switch(FEAT_TRAINS, SELF, flatbed_subtype_text_switch, cargo_subtype) {
0: return string(STR_LIVERY_RND);
1: return string(STR_LIVERY_0);
return CB_RESULT_NO_TEXT;
}
switch(FEAT_TRAINS, SELF, flatbed_cargo_switch, cargo_type_in_veh) {
BATT: flatbed_container_spritegroup_switch;
BUBL: flatbed_rfpr_spritegroup;
[...]
WDPR: flatbed_wdpr_spritegroup;
WOOD: flatbed_wood_spritegroup_switch;
flatbed_container_spritegroup_switch;
}
switch (FEAT_TRAINS, SELF, flatbed_vehicle_switch, STORE_TEMP(CB_FLAG_MORE_SPRITES | PALETTE_USE_DEFAULT, 0x100)) {
return flatbed_livery_switch;
}
switch (FEAT_TRAINS, SELF, flatbed_load_switch, STORE_TEMP(PALETTE_USE_DEFAULT, 0x100)) {
return flatbed_cargo_switch;
}
switch (FEAT_TRAINS, SELF, flatbed_graphics_switch, getbits(extra_callback_info1, 8, 8)) {
0: return flatbed_vehicle_switch;
return flatbed_load_switch;
}
item(FEAT_TRAINS, flatbed_wagon) {
property {
name: string(STR_FLATBED_WAGON_NAME);
sprite_id: SPRITE_ID_NEW_TRAIN;
cargo_capacity: 32;
loading_speed: 8;
cost_factor: 216;
running_cost_factor: 0;
running_cost_base: RUNNING_COST_NONE;
power: 0;
weight: 19 ton;
bitmask_vehicle_info: 0;
misc_flags: bitmask(TRAIN_FLAG_2CC, TRAIN_FLAG_SPRITE_STACK); // We use special sprites for passenger and mail wagons
introduction_date: date(1995,1,1);
climates_available: ALL_CLIMATES;
model_life: VEHICLE_NEVER_EXPIRES;
track_type: ELRL;
refittable_cargo_classes: bitmask(CC_PIECE_GOODS, CC_EXPRESS, CC_OVERSIZED);
non_refittable_cargo_classes: bitmask(CC_PASSENGERS, CC_REFRIGERATED);
cargo_allow_refit: [BATT, BDMT, BRCK, BUBL, COPR, DYES, ENSP, FERT, FMSP, FZDR, GLAS, GOOD, MNSP, PAPR, PETR, PLAS, PLST, RFPR, STEL, SWET, TWOD, VEHI, WDPR, WOOD, JAVA, YETI];
cargo_disallow_refit: [PASS, [...] , URAN];
default_cargo_type: WOOD;
}
graphics {
cargo_capacity: flatbed_capacity_switch;
cargo_subtype_text: flatbed_subtype_text_switch;
flatbed_graphics_switch;
}
}
Everything is working as expected but the random switch with bitmask(TRIGGER_VEHICLE_UNLOAD_ALL ..
The switch seems to be triggered at the purchase but not when loading/unloading. I tried using others triggers bitmaks like TRIGGER_VEHICLE_ANY_LOAD but none of them worked.
Is it possible that the switch isn't triggered because of the stacked sprite ?
I can't figure out how "independent:" parameter has to be used, can someone explain a little more about it ?
Thanks !
EDIT :
I found out about
random_trigger callback. Now the random switch works but still not as expected.
When the switch is triggered, the load gets randomized but its the same value for every single wagon of the train.
I think there is something to do with the
independent: param but i still dont understand how it works.