Frictional Games Forum (read-only)
Help - Play Music when I touch an object - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Help - Play Music when I touch an object (/thread-22090.html)

Pages: 1 2


RE: Help - Play Music when I touch an object - iLucian - 07-11-2013

(07-11-2013, 07:32 PM)The chaser Wrote: Then you are using the wrong code. The violin isn't an item, is an entity. To make that work, simply put this anywhere in your script, but not in void OnStart(). Put this:

void Touch(string &in asEntity)
{
PlayMusic("music.ogg", false, 1, 1, 1, false);
}



Now, select the violin and go to the entity panel. Go down, where it says "PlayerInteractCallback" and put "Touch". Now it should work.

that worked, but the song is only 7 seconds long, and i want the music that was originally playing to start playing again, cuz the song that plays when i touch the violin loops and i dont want it to, even though i put false.

(07-11-2013, 07:32 PM)The chaser Wrote: Then you are using the wrong code. The violin isn't an item, is an entity. To make that work, simply put this anywhere in your script, but not in void OnStart(). Put this:

void Touch(string &in asEntity)
{
PlayMusic("music.ogg", false, 1, 1, 1, false);
}



Now, select the violin and go to the entity panel. Go down, where it says "PlayerInteractCallback" and put "Touch". Now it should work.

that worked, but the song is only 7 seconds long, and i want the music that was originally playing to start playing again, cuz the song that plays when i touch the violin loops and i dont want it to, even though i put false.


RE: Help - Play Music when I touch an object - The chaser - 07-11-2013

Use this one instead:



void Touch(string &in asEntity)

{

PlayMusic("music.ogg", true, 1, 0.1, 1, false);

}

That'll make the song loop Wink


RE: Help - Play Music when I touch an object - iLucian - 07-12-2013

(07-11-2013, 10:55 PM)The chaser Wrote: Use this one instead:



void Touch(string &in asEntity)

{

PlayMusic("music.ogg", true, 1, 0.1, 1, false);

}

That'll make the song loop Wink

No, i don't want it to loop, when you touch the violin i want the song to play once and then i want the music that was playing before you touched it to begin playing again. My problem is that the music when you touch the violin is looping even though i put false on the loop.


RE: Help - Play Music when I touch an object - The chaser - 07-12-2013

Oh, I see. Then, do this:

void Touch(string &in asEntity)



{

PlayMusic("music.ogg", false, 1, 0.1, 1, false);

AddTimer("", 7, "Replay");

}

void Replay (string &in asTimer)
{
PlayMusic("yourlevelmusic.ogg", true, 1, 1, 1, true);
}

That will make the music play, and, in 7 seconds, it will resume your level song. I think this should fix you error now Wink


RE: Help - Play Music when I touch an object - iLucian - 07-13-2013

(07-12-2013, 12:45 PM)The chaser Wrote: Oh, I see. Then, do this:

void Touch(string &in asEntity)



{

PlayMusic("music.ogg", false, 1, 0.1, 1, false);

AddTimer("", 7, "Replay");

}

void Replay (string &in asTimer)
{
PlayMusic("yourlevelmusic.ogg", true, 1, 1, 1, true);
}

That will make the music play, and, in 7 seconds, it will resume your level song. I think this should fix you error now Wink

thanks for your help! Everything works fine now! thank you Big Grin