Outerra forum
Anteworld - Outerra Game => Modding: Importer, Tools & Utilities => Topic started by: bugsblake on June 22, 2013, 05:10:03 pm
-
ok ive had a look at http://xtrac.outerraworld.com/trac.fcgi/wiki/action_code (http://xtrac.outerraworld.com/trac.fcgi/wiki/action_code)
here i see "AHorn" action code and above i see "AOpen" and i know AOpen is working now!
the fact AHorn dose'nt say its not working, im guessing it is! other sounds work so why not!
anyway ive looked at the sounds in the vehicle script like start, stop and idle sounds and see how they work but a horn will be different!
with the horn it plays a sound for as long as you press it, so would this be better done with 3 sounds?
if you take a look at the sound (see pic) it starts and raises to a peak, plays a looping type sound and then fades out once the horn is released!
so i have all the sounds, a start, loop and end sound. had to get the loop just right to sound good!
but the problem is, i have not idea how to code this?
would someone be kind enough to show me how i am ment to code this right?
thanks
-
it's simple:
// ...
function init_vehicle() {
// ...
this.snd = this.sound();
this.horn_start_snd = this.snd.load_sound("horn-start.ogg");
this.horn_loop_snd = this.snd.load_sound("horn-loop.ogg");
this.horn_end_snd = this.snd.load_sound("horn-end.ogg");
// horn-pos - a bone where you should hear the signal
this.horn_snd_src = this.snd.create_source(this.get_geomob(0).get_joint('horn-pos'));
this.snd.set_ref_distance(this.horn_snd_src, 10.0);
this.horn = function(v) {
if (v > 0) {
this.snd.play_sound(this.horn_snd_src, this.horn_start_snd);
this.snd.enqueue_loop(this.horn_snd_src, this.horn_loop_snd);
} else {
this.snd.enqueue_sound(this.horn_snd_src, this.horn_end_snd);
}
}
// ...
}
// ...
function action(k, v, dt) {
switch (k) {
// ...
case AHorn: this.horn(v); break;
// ...
}
}
// ...
-
thank you mate! much appreciated! :D
-
im getting an error! my fault im sure but not sure what it means? or how to fix it!
ERROR: ground_vehicle: :update_frame: (my vehicle path) .js(95): TypeError: Object [object Object] has no method 'horn'
can you see where i screwed up?
-
this.horn = function(v) {...} must be inside init_vehicle().
move right brace from line 71 to 80, for example.
-
thank you! :D
-
works great! sounds great! :D thanks a lot!
while im here, do you also know how to get the handbreak working?
thats the last thing i need to know untill vehicle lights are added! cant wait for that! ;) hint hint, drop a bomb shell, cameni! :D