Jump to content

Photo

Simple script request


  • Please log in to reply
7 replies to this topic

#1 Sephiroth

Sephiroth

    The Legendary Sephiroth

  • Members
  • Location:Somewhere... Lemme know if you find me :)

Posted 22 September 2008 - 11:16 PM

I'm looking for a way to make a sound effect play once I step on a certain tile (or group of tiles), so if anyone can help me with this, it would be greatly appreciated.

What I would like to do is have one FFC for this script, the FFC has one argument, being the SFX number to play once you step on it.

This should also work for 1x1 combo FFCs, and larger FFCs like 2x2, 3x3, 4x4. etc..

#2 Saffith

Saffith

    IPv7 user

  • Members

Posted 23 September 2008 - 12:43 AM

I'm just writing this here without testing it, but I expect it'll work.
This is assuming you're using a small Link and only want the sound to play once. Also, I'll give it a few pixels of leeway.

CODE
ffc script StepSound
{
    void run(int sound)
    {
        while(true)
        {
            if(Link->X>this->X-2 && Link->X<this->X+16*(this->TileWidth-1)+2 && Link->Y>this->Y-2 && Link->Y<this->Y+16*(this->TileHeight-1)+2)
            {
                Game->PlaySound(sound);
                Quit();
            }
            Waitframe();
        }
    }
}

Edited by Saffith, 23 September 2008 - 01:18 AM.


#3 Sephiroth

Sephiroth

    The Legendary Sephiroth

  • Members
  • Location:Somewhere... Lemme know if you find me :)

Posted 23 September 2008 - 08:28 AM

Yes, I am using small Link if that's what you're talking about.

I'm not too fond of big link to be honest, and I'll just be sticking with a 16x16 Link. icon_razz.gif

I checked it out, it works exactly what I wanted for my intro splash, however it only seems to work once per screen, I was hoping it would work infinitely per screen, but once per step onto the FFC. Kinda hard to explain really, but if you have played certain RPGs with Save Points, you would know that whenever you step onto the save point, a sound effect plays. I'm trying to achieve this same effect.

#4 Saffith

Saffith

    IPv7 user

  • Members

Posted 23 September 2008 - 09:06 AM

Ah, okay. Try this way, then.

CODE
ffc script StepSound
{
    void run(int sound)
    {
        bool alreadyOn=false;
        
        while(true)
        {
            if(!alreadyOn && Link->X>this->X-2 && Link->X<this->X+16*(this->TileWidth-1)+2 && Link->Y>this->Y-2 && Link->Y<this->Y+16*(this->TileHeight-1)+2)
            {
                alreadyOn=true;
                Game->PlaySound(sound);
            }
            else if(alreadyOn)
                alreadyOn=false
            
            Waitframe();
        }
    }
}


#5 Sephiroth

Sephiroth

    The Legendary Sephiroth

  • Members
  • Location:Somewhere... Lemme know if you find me :)

Posted 23 September 2008 - 10:17 AM

QUOTE(Saffith @ Sep 23 2008, 09:06 AM) View Post

Ah, okay. Try this way, then.

CODE
...snip...



Now it's to the point where I can stand JUST RIGHT on the FFC for a continous SFX stream.

#6 Saffith

Saffith

    IPv7 user

  • Members

Posted 23 September 2008 - 10:34 AM

D'oh. Well, let's see...

CODE
ffc script StepSound
{
    void run(int sound)
    {
        bool alreadyOn=false;
        
        while(true)
        {
            if(Link->X>this->X-2 && Link->X<this->X+16*(this->TileWidth-1)+2 && Link->Y>this->Y-2 && Link->Y<this->Y+16*(this->TileHeight-1)+2)
            {
                if(!alreadyOn)
                {
                    alreadyOn=true;
                    Game->PlaySound(sound);
                }
            }
            else if(alreadyOn)
                alreadyOn=false
            
            Waitframe();
        }
    }
}


#7 Joe123

Joe123

    Retired

  • Members

Posted 23 September 2008 - 10:40 AM

CODE
ffc script SavePointSFX{
    void run(int sfx){
    int X = this->TileWidth;
    int Y = this->TileHeight;
        while(true){
            while(Abs(Link->X - (this->X+8*(X-1))) > 8*X || Abs(Link->Y - (this->Y+8*(Y-1))) > 8*Y) Waitframe();
            Game->PlaySound(sfx);
            while(Abs(Link->X - (this->X+8*(X-1))) <= 8*X && Abs(Link->Y - (this->Y+8*(Y-1))) <= 8*Y) Waitframe();
        }
    }
}


EDIT:
Oh, oops >_<
I wasn't trying to one-up you there, I hadn't refreshed the thread since you posted. Sorry.

#8 Sephiroth

Sephiroth

    The Legendary Sephiroth

  • Members
  • Location:Somewhere... Lemme know if you find me :)

Posted 23 September 2008 - 11:20 AM

QUOTE(Joe123 @ Sep 23 2008, 10:40 AM) View Post

CODE
ffc script SavePointSFX{
    void run(int sfx){
    int X = this->TileWidth;
    int Y = this->TileHeight;
        while(true){
            while(Abs(Link->X - (this->X+8*(X-1))) > 8*X || Abs(Link->Y - (this->Y+8*(Y-1))) > 8*Y) Waitframe();
            Game->PlaySound(sfx);
            while(Abs(Link->X - (this->X+8*(X-1))) <= 8*X && Abs(Link->Y - (this->Y+8*(Y-1))) <= 8*Y) Waitframe();
        }
    }
}


EDIT:
Oh, oops >_<
I wasn't trying to one-up you there, I hadn't refreshed the thread since you posted. Sorry.


Works perfectly, Thanks Joe123! icon_biggrin.gif

On a side note, I'm still going to be using Saffith's original version for one-time sound effects for things like my intro. Thanks to the both of you. =)


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users