Trying to improve my coding skills... I've never done much with vehicles in the past and I could never wrap my head around callbacks in NFO, but now I'm working in NML and it's time to have another go. Have taken my time working through the truck/tram/train tutorials and for the most part it seemed fairly straightforward(ish), so now I'm poking around with my own code and seeing if I can make stuff work the way I want it to.
What I'm struggling with at the moment is sound effects. I want to have a vehicle make a sound every now and then as it runs, kind of like how they do in the Generic Cars grf for example. Tried adding the soundeffect callback with the following switch:
Code: Select all
switch(FEAT_ROADVEHS, SELF, switchSoundEffect, getbits(extra_callback_info1, 0, 8)) {
SOUND_EVENT_RUNNING: SOUND_CAR_HORN_2;
}
That sort of worked in the sense that it plays the desired sound, except it does so continually. Then I tried combining this with a random switch which I hoped woud at least make the sound intermittant:
Code: Select all
random_switch(FEAT_ROADVEHS, SELF, switch_sounds_random) {
1: SOUND_CAR_HORN_2;
5: CB_RESULT_NO_SOUND;
}
But that just results in no running sound. Not entirely sure what I'm meant to be doing and I couldn't find any examples to guide me, so I'd be most grateful for any help steering me in the right direction! Calling it a day for now, will take another stab at this tomorrow.