Outerra forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Outerra Tech Demo download. Help with graphics driver issues

Author Topic: car horn?  (Read 4423 times)

bugsblake

  • Sr. Member
  • ****
  • Posts: 255
  • jedi master
car horn?
« on: June 22, 2013, 05:10:03 pm »

ok ive had a look at 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
Logged
Intel 6 core i7 Xeon - 4930k @3.40 GHz
GTX 770 4GB X2 in SLI
Asus P9X79 Extreme MOBO
Patriot 16GB DDR3 1600MHz
SSD 250GB + SATA 500GB + SATA 1TB

hhrhhr

  • Member
  • **
  • Posts: 60
Re: car horn?
« Reply #1 on: June 22, 2013, 11:59:57 pm »

it's simple:
Code: [Select]
// ...
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;
// ...
    }
}
// ...
Logged

bugsblake

  • Sr. Member
  • ****
  • Posts: 255
  • jedi master
Re: car horn?
« Reply #2 on: June 23, 2013, 02:40:29 am »

thank you mate! much appreciated! :D
Logged
Intel 6 core i7 Xeon - 4930k @3.40 GHz
GTX 770 4GB X2 in SLI
Asus P9X79 Extreme MOBO
Patriot 16GB DDR3 1600MHz
SSD 250GB + SATA 500GB + SATA 1TB

bugsblake

  • Sr. Member
  • ****
  • Posts: 255
  • jedi master
Re: car horn?
« Reply #3 on: June 23, 2013, 03:47:23 am »

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?
Logged
Intel 6 core i7 Xeon - 4930k @3.40 GHz
GTX 770 4GB X2 in SLI
Asus P9X79 Extreme MOBO
Patriot 16GB DDR3 1600MHz
SSD 250GB + SATA 500GB + SATA 1TB

hhrhhr

  • Member
  • **
  • Posts: 60
Re: car horn?
« Reply #4 on: June 23, 2013, 03:55:42 am »

this.horn = function(v) {...} must be inside init_vehicle().

move right brace from line 71 to 80, for example.
« Last Edit: June 23, 2013, 04:01:25 am by hhrhhr »
Logged

bugsblake

  • Sr. Member
  • ****
  • Posts: 255
  • jedi master
Re: car horn?
« Reply #5 on: June 23, 2013, 04:13:09 am »

thank you! :D
Logged
Intel 6 core i7 Xeon - 4930k @3.40 GHz
GTX 770 4GB X2 in SLI
Asus P9X79 Extreme MOBO
Patriot 16GB DDR3 1600MHz
SSD 250GB + SATA 500GB + SATA 1TB

bugsblake

  • Sr. Member
  • ****
  • Posts: 255
  • jedi master
Re: car horn?
« Reply #6 on: June 23, 2013, 04:37:54 am »

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
Logged
Intel 6 core i7 Xeon - 4930k @3.40 GHz
GTX 770 4GB X2 in SLI
Asus P9X79 Extreme MOBO
Patriot 16GB DDR3 1600MHz
SSD 250GB + SATA 500GB + SATA 1TB