Jump to content

Photo

Playsound


  • Please log in to reply
9 replies to this topic

#1 Joe123

Joe123

    Retired

  • Members

Posted 23 September 2007 - 06:14 AM

How does the Playsound command work? I've been messing with it for a while, but I can't seem to get it to compile, my syntax is terrible.

I want a script that plays the secret sound effect when you trigger a perm. trigger. I'm quite confident I'd be able to do it (I think), but I just can't get the command to work.

#2 NoeL

NoeL

    Legend

  • Members
  • Real Name:Jerram

Posted 23 September 2007 - 07:50 AM

Use:

Game -> PlaySound(n);

where n is the reference to the sound you want to play.

#3 Joe123

Joe123

    Retired

  • Members

Posted 23 September 2007 - 08:11 AM

Thankyou NoeL icon_smile.gif

And I wrote my first script icon_biggrin.gif
CODE
ffc script sound_effect{
    void run(int SFX){
        Game -> PlaySound(SFX);
    }
}


Rather basic icon_razz.gif but there we go

#4 NoeL

NoeL

    Legend

  • Members
  • Real Name:Jerram

Posted 23 September 2007 - 08:18 AM

... why did you make SFX a parameter though? As far as I'm aware no data is passed into the "run" function. icon_confused.gif

I would have used something like
CODE
ffc script sound_effect
{
    void run()
    {
        int SFX;

       // some code here to set the appropriate sound

        Game -> PlaySound(SFX);
    }
}

Edited by NoeL, 23 September 2007 - 08:20 AM.


#5 Joe123

Joe123

    Retired

  • Members

Posted 23 September 2007 - 08:23 AM

So that it's an argument in the FFC, so I don't have to rewrite the whole script if I want to use a different SFX. If you set integers in the void run command, they're variables that you define via the arguments in the FFC.

#6 NoeL

NoeL

    Legend

  • Members
  • Real Name:Jerram

Posted 23 September 2007 - 08:27 AM

Ah cool! Thanks, I was wondering how to access those arguments icon_heh.gif I feel silly now, I should have thought of that.

#7 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 23 September 2007 - 09:22 AM

Good job joe! It's not so bad, right!?

Here's one thing you should know. That ffc will run once and then stop.


CODE
ffc script playsound{
    void run(int sfx, int sfx2){
// here's one idea,
//in a boss battle play a sound if link gets hit or link hits the boss
        int boss = LoadNPC(1);
        int hurt = Link->HP;
        while (true){
            if( Link->HP<hurt){
                Game->PlaySound(0);
                hurt = Link->HP;
                }
            if(boss->HP<MaxHP){
                Game->PlaySound(0);
                boss->MaxHP = boss->HP;
                }
            Waitframe();
            }
        }
    }
}

//Loads of other cool ways to change what sound plays too. What'd you have in mind?
            


This one will keep playing the sound whenever conditions are met. Although you're going to have to change it a bit.
And post some script stuff at AGN, the scripting forum needs some livening up! icon_razz.gif

#8 Joe123

Joe123

    Retired

  • Members

Posted 23 September 2007 - 01:07 PM

I have been! noone replies icon_frown.gif

And thanks for that, but I only needed a SFX to play when I entered the screen anyway. And you can change the noise that a boss makes when it gets hurt via the SFX editor nowadays without needing a script icon_wink.gif

#9 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 24 September 2007 - 01:07 AM

QUOTE(Joe123 @ Sep 23 2007, 12:07 PM) View Post

I have been! noone replies icon_frown.gif

And thanks for that, but I only needed a SFX to play when I entered the screen anyway. And you can change the noise that a boss makes when it gets hurt via the SFX editor nowadays without needing a script icon_wink.gif


Ah, but what about them ffc or custom bosses, plus I think a boss that says something everytime he hurts Link would be neat.

QUOTE
I have been! noone replies


Huh?! Maybe I missed it then...

#10 Joe123

Joe123

    Retired

  • Members

Posted 24 September 2007 - 10:46 AM

I'm the last person to post on two of the scripting forums over at AGN, and have been for 3 days on one of them and 4 on the other icon_razz.gif

Although I think scripting custom bosses is a little advanced for me...


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users