Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stopping music, spawning objects. Help.
Shylia Offline
Junior Member

Posts: 14
Threads: 3
Joined: Jan 2015
Reputation: 0
#1
Wink  Stopping music, spawning objects. Help.

Hello! I've tried for a while to make this thing work. I want to stop a song that plays when you turn the crank on the Phonograph when I enter a Script Area. But no matter what I do or try I can't seem to make the song stop.

Here is my little script.

Spoiler below!
void OnStart()
{
AddEntityCollideCallback("Player", "Act1", "Welcome1", true, 1);
}

void OldMusicPlay1(string &in asEntity, int alState)
{
if(alState == 1)
{
PlaySoundAtEntity("", "OldMusic1.snt", "OldMusic1", 0, false);
}
}

void Welcome1(string &in asParent, string &in asChild, int alState)
{
StopSound("OldMusic1" 1.0);
}


Also when the music plays, it's not playing on the Phonograph itself, it's more like all over the place no matter how far I am from the Phonograph.
01-08-2015, 11:11 AM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#2
RE: Stopping music, spawning objects. Help.

(01-08-2015, 11:11 AM)Shylia Wrote: Hello! I've tried for a while to make this thing work. I want to stop a song that plays when you turn the crank on the Phonograph when I enter a Script Area. But no matter what I do or try I can't seem to make the song stop.

Here is my little script.

Spoiler below!
void OnStart()
{
AddEntityCollideCallback("Player", "Act1", "Welcome1", true, 1);
}

void OldMusicPlay1(string &in asEntity, int alState)
{
if(alState == 1)
{
PlaySoundAtEntity("", "OldMusic1.snt", "OldMusic1", 0, false);
}
}

void Welcome1(string &in asParent, string &in asChild, int alState)
{
StopSound("OldMusic1" 1.0);
}


Also when the music plays, it's not playing on the Phonograph itself, it's more like all over the place no matter how far I am from the Phonograph.

The way StopSound(); works is that you reference the internal name of the sound - which in this case, is undeclared in your PlaySoundAtEntity();, as the internal name is the first string parameter, which you have left null.

Changing those two lines to these should work:

PHP Code: (Select All)
PlaySoundAtEntity("old_music""OldMusic1.snt""OldMusic1"0false);

StopSound("old_music"1.0f); 

----------
The fact that you have loud music which "surrounds" the player is probably because of the way your .snt is - as the settings for such are located in there. Smile If you may, could you post the contents of your .snt here?

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 01-08-2015, 11:26 AM by Romulator.)
01-08-2015, 11:25 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#3
RE: Stopping music, spawning objects. Help.

Psst.
I couldn't help but notice. Just wanna point out that empty strings aren't null :>
Null is indeed undecleared, but "" is a decleared value of nothingness.

Angel

01-08-2015, 11:32 AM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#4
RE: Stopping music, spawning objects. Help.

(01-08-2015, 11:32 AM)Mudbill Wrote: Psst.
I couldn't help but notice. Just wanna point out that empty strings aren't null :>
Null is indeed undecleared, but "" is a decleared value of nothingness.

Angel

No problem! I enjoy learning more things. ^^
It's as close to null as you can get in HPL2 as far as I know though, as you cannot exactly declare or query IsNothing.

But that's for another topic!

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 01-08-2015, 11:36 AM by Romulator.)
01-08-2015, 11:34 AM
Find
Shylia Offline
Junior Member

Posts: 14
Threads: 3
Joined: Jan 2015
Reputation: 0
#5
RE: Stopping music, spawning objects. Help.

(01-08-2015, 11:25 AM)Romulator Wrote:
(01-08-2015, 11:11 AM)Shylia Wrote: Hello! I've tried for a while to make this thing work. I want to stop a song that plays when you turn the crank on the Phonograph when I enter a Script Area. But no matter what I do or try I can't seem to make the song stop.

Here is my little script.

Spoiler below!
void OnStart()
{
AddEntityCollideCallback("Player", "Act1", "Welcome1", true, 1);
}

void OldMusicPlay1(string &in asEntity, int alState)
{
if(alState == 1)
{
PlaySoundAtEntity("", "OldMusic1.snt", "OldMusic1", 0, false);
}
}

void Welcome1(string &in asParent, string &in asChild, int alState)
{
StopSound("OldMusic1" 1.0);
}


Also when the music plays, it's not playing on the Phonograph itself, it's more like all over the place no matter how far I am from the Phonograph.

The way StopSound(); works is that you reference the internal name of the sound - which in this case, is undeclared in your PlaySoundAtEntity();, as the internal name is the first string parameter, which you have left null.

Changing those two lines to these should work:

PHP Code: (Select All)
PlaySoundAtEntity("old_music""OldMusic1.snt""OldMusic1"0false);

StopSound("old_music"1.0f); 

----------
The fact that you have loud music which "surrounds" the player is probably because of the way your .snt is - as the settings for such are located in there. Smile If you may, could you post the contents of your .snt here?

Alright I will show you the SNT.

Spoiler below!
<SOUNDENTITY>
<SOUNDS>
<Main>
<Sound File="OldMusic1" />
</Main>
</SOUNDS>
<PROPERTIES Volume="0.1" MinDistance="1" MaxDistance="10" Random="0" Interval="0" FadeEnd="False" FadeStart="False" Stream="False" Loop="False" Use3D="false" Blockable="False" BlockVolumeMul="0.7" Priority="0" />
</SOUNDENTITY>

Also let's say I wanted to play the sound from the amnesia game called: ambience_haunting.snt when I enter the script area, how would I do that?

I've tried
Spoiler below!
PlaySoundAtEntity("", "ambience_haunting.snt", "Player", 0, false);

But it didn't work, so there must be some magic performed before it allows itself to.
(This post was last modified: 01-08-2015, 12:21 PM by Shylia.)
01-08-2015, 12:00 PM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#6
RE: Stopping music, spawning objects. Help.

Try lowering the MaxDistance. Making it lower will decrease the radius in which the sound can be heard. I forget exactly how far away it equates to, so you may have to do a little bit of testing and changing to alter it.

Edit:
Have you also got the .ogg file(s) for the ambience_haunting.snt somewhere in your custom story directory (preferably your own)?

In terms of the scripting aspect, it should be the same as colliding with a normal script area, provided it is tall/thick/wide enough for the Player to not miss it. As such, you would use an AddEntityCollideCallback like the one above, and like Mudbill below me says, to use PlayGuiSound(); if it should be around the Player.

If it still does not work, recheck the names of your script areas.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 01-08-2015, 12:39 PM by Romulator.)
01-08-2015, 12:29 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#7
RE: Stopping music, spawning objects. Help.

I believe you should also set Use3D="True"

If you want to play a sound on the player itself, I recommend using PlayGuiSound instead of PlaySoundAtEntity. It plays a sound without 3D directly in the player's face (practically speaking). It's very useful for player sound effects or other ambient sounds that should not have a specific source in the level.

01-08-2015, 12:36 PM
Find
Shylia Offline
Junior Member

Posts: 14
Threads: 3
Joined: Jan 2015
Reputation: 0
#8
RE: Stopping music, spawning objects. Help.

Could you give me a link on how to apply text to things? Like if I walk into a script area I want some text to pop up, or if I want to make a note and stuff. That would be great.
01-08-2015, 03:09 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#9
RE: Stopping music, spawning objects. Help.

Are you referring to the extra_english.lang in general or just those specific things? I've got a video here explaining the lang file if you want to check it out, but it is fairly lengthy.

Notes are added through the entity tab of the item itself. In there you define the note's entry in the lang file (within the Journal category). As for script areas, using SetMessage should be used in the collision callback. In SetMessage, you can define the category and entry yourself. Both are present in the lang file.

(This post was last modified: 01-08-2015, 03:16 PM by Mudbill.)
01-08-2015, 03:15 PM
Find
Shylia Offline
Junior Member

Posts: 14
Threads: 3
Joined: Jan 2015
Reputation: 0
#10
RE: Stopping music, spawning objects. Help.

I followed your video which was super helpful, but when I tried to apply the text to a level door, I could not see it in the game. And I did it exactly like you did.

Spoiler below!
<LANGUAGE>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description">Welcome, fine Resident. We hope you enjoy your stay.</Entry>
</CATEGORY>

<CATEGORY Name="Levels">
<Entry Name="TheUnderbelly">To The Underbelly</Entry>
</CATEGORY>

</LANGUAGE>

Anything wrong? Because I can't see it.
01-08-2015, 04:22 PM
Find




Users browsing this thread: 1 Guest(s)