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
Phonograph Scripting Help
HoyChampoy Offline
Junior Member

Posts: 43
Threads: 16
Joined: Jun 2012
Reputation: 0
#1
Phonograph Scripting Help

Hey guys. I was thinking about doing a little phonograph scare. What i wanted was that when a player winded up a phonograph, it would start playing a minute and 12 second song. I was wondering if this was possible. I tried scripting numerous times but i just can't get it to work. Would anyone know how to script this right? It would be very appreciated. Thanks! Smile
06-15-2012, 04:42 AM
Find
Pigsareit Offline
Junior Member

Posts: 15
Threads: 2
Joined: Jun 2012
Reputation: 0
#2
RE: Phonograph Scripting Help

Try opening one of the justine maps and see how the devs did it.

|| Pigsareit - Egan || My YouTube Channel ||
06-15-2012, 02:02 PM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#3
RE: Phonograph Scripting Help

Music is terrifying!

*Ahem* It appears the devs used entirely new functions for the Phonograph in Justine, most notably:

PlayPhono(int iLevel, int iSet, int iPart, string &in asEntity)

Sadly, this function doesn't even appear in the Engine Scripts wiki Page, and I have no clue what it does. If my assumption is correct, the crank for the phonograph works like a spinning wheel crank (meaning it has 3 main int states, -1 as closed, 0 as between and 1 as open). Here's what I can come up with (assuming that I'm correct about it acting like a crank).

Before writing out this script, go into your level editor, then find and select the phonograph that you want to play music at; next, click the "Entity" tab on the right hand side of the screen (next to "General" tab). Third from the top, there should be a line that says "ConnectionStateChangeCallback" with a white box under it; in this white box, copy and paste: "PhonographScare". Good, now we can script!

void PhonographScare(string &in EntityName, int aIState)
{
if(alCount == 1)
{
PlaySoundAtEntity("", NAMEOFSOUND, "Phonograph", 5.0f, false);
SetPropStaticPhysics("Phonograph", true);
}
}

In layman's terms, if the player turns the crank all the way, sound will play at the phonograph and the phonograph crank will become stuck in place, and can no longer be interacted with.

Change "Phonograph" to the exact name of your phonograph in game;
Also, change NAMEOFSOUND to the name of the song*

*The song MUST be in .ogg format; you must use a sound editor like Audacity to properly convert it.

SetPropStaticPhysics will make the phonograph act like a static object, preventing the player from further interaction with it after the sound is playing.

Note: I have not tested this in game, but it should work properly. If a more advanced/educated Scripter would like to revise this, feel free.

Hope that helped!

I rate it 3 memes.
06-15-2012, 02:39 PM
Find
HoyChampoy Offline
Junior Member

Posts: 43
Threads: 16
Joined: Jun 2012
Reputation: 0
#4
RE: Phonograph Scripting Help

(06-15-2012, 02:39 PM)andyrockin123 Wrote: Music is terrifying!

*Ahem* It appears the devs used entirely new functions for the Phonograph in Justine, most notably:

PlayPhono(int iLevel, int iSet, int iPart, string &in asEntity)

Sadly, this function doesn't even appear in the Engine Scripts wiki Page, and I have no clue what it does. If my assumption is correct, the crank for the phonograph works like a spinning wheel crank (meaning it has 3 main int states, -1 as closed, 0 as between and 1 as open). Here's what I can come up with (assuming that I'm correct about it acting like a crank).

Before writing out this script, go into your level editor, then find and select the phonograph that you want to play music at; next, click the "Entity" tab on the right hand side of the screen (next to "General" tab). Third from the top, there should be a line that says "ConnectionStateChangeCallback" with a white box under it; in this white box, copy and paste: "PhonographScare". Good, now we can script!

void PhonographScare(string &in EntityName, int aIState)
{
if(alCount == 1)
{
PlaySoundAtEntity("", NAMEOFSOUND, "Phonograph", 5.0f, false);
SetPropStaticPhysics("Phonograph", true);
}
}

In layman's terms, if the player turns the crank all the way, sound will play at the phonograph and the phonograph crank will become stuck in place, and can no longer be interacted with.

Change "Phonograph" to the exact name of your phonograph in game;
Also, change NAMEOFSOUND to the name of the song*

*The song MUST be in .ogg format; you must use a sound editor like Audacity to properly convert it.

SetPropStaticPhysics will make the phonograph act like a static object, preventing the player from further interaction with it after the sound is playing.

Note: I have not tested this in game, but it should work properly. If a more advanced/educated Scripter would like to revise this, feel free.

Hope that helped!
thanks for the help, but I've ran into a problem. I tried doing the scripting but i always run into an error. Heres what my script looks like:


void PhonographScare(string &in EntityName, int aIState)


{
if(alCount == 1)
{

PlaySoundAtEntity("", "TipToeSong.ogg", "phonograph_1", 5.0f, false);
SetPropStaticPhysics("phonograph_1", true);

}
}

Here are the errors i'm getting:
main (115,1) : INFO : Compiling void PhonographScare(string&in, int)
main (119,5) : ERR : 'alCount' is not declared
main (119,5) : ERR : Expression must be of boolean type

I don't know whats happening Sad
06-18-2012, 07:30 AM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#5
RE: Phonograph Scripting Help

My apologies; most of that was off the top of my head, which apparently isn't as reliable as I once thought : /

This will work, tested 100% (note, this still requires the step mentioned about the level editor):


void PhonographScare(string &in EntityName, int alState)
{
if(alState == 1) ///revised int alCount to int alState
{

PlaySoundAtEntity("", "TipToeSong.ogg", "phonograph_1", 5.0f, false);
SetPropStaticPhysics("phonograph_1", true);

}
}

That will fix your error. I noticed you have a .ogg file though I think PlaySound requires a .snt file. Make sure you converted it to a .ogg properly by using a program such as Audacity and didn't just rename an mp3 file; anyways, I'm pretty sure you will need to make a .snt file for it to work properly; then again, its 6:11 am here and that could be the sleep deprivation talking Tongue Here's the easiest way to make your own:

-Choose any .snt file from the sounds folder (I suggest 00_creak.snt, found in the 00 sound folder)
-Open it with NotePad++ or Geany
-Change the sound file under "Main" from "00_creak" to the corresponding name of your .ogg file.

Next, you may want to fix some of the properties; most notably, you will want to set**:

"Volume="float" volume, I believe max is 1.0f
MinDistance="int" an integer (not decimal) is the minimum distance you must be to hear it
MaxDistance="Int" an integer the max distance to hear it; this should be at least 20/30
Loop="bool" loop means replay, true will replay, false will not

You can explore some of the other settings, most of which won't have major effects on the sound; I just went over the most basic properties.

**Change int to corresponding integers (i.e. 1,2,3,4), floats to corresponding decimal values (i.e. 1.0, 0.76, 0.245), and bool to true or false values.

I rate it 3 memes.
06-18-2012, 11:27 AM
Find
HoyChampoy Offline
Junior Member

Posts: 43
Threads: 16
Joined: Jun 2012
Reputation: 0
#6
RE: Phonograph Scripting Help

(06-18-2012, 11:27 AM)andyrockin123 Wrote: My apologies; most of that was off the top of my head, which apparently isn't as reliable as I once thought : /

This will work, tested 100% (note, this still requires the step mentioned about the level editor):


void PhonographScare(string &in EntityName, int alState)
{
if(alState == 1) ///revised int alCount to int alState
{

PlaySoundAtEntity("", "TipToeSong.ogg", "phonograph_1", 5.0f, false);
SetPropStaticPhysics("phonograph_1", true);

}
}

That will fix your error. I noticed you have a .ogg file though I think PlaySound requires a .snt file. Make sure you converted it to a .ogg properly by using a program such as Audacity and didn't just rename an mp3 file; anyways, I'm pretty sure you will need to make a .snt file for it to work properly; then again, its 6:11 am here and that could be the sleep deprivation talking Tongue Here's the easiest way to make your own:

-Choose any .snt file from the sounds folder (I suggest 00_creak.snt, found in the 00 sound folder)
-Open it with NotePad++ or Geany
-Change the sound file under "Main" from "00_creak" to the corresponding name of your .ogg file.

Next, you may want to fix some of the properties; most notably, you will want to set**:

"Volume="float" volume, I believe max is 1.0f
MinDistance="int" an integer (not decimal) is the minimum distance you must be to hear it
MaxDistance="Int" an integer the max distance to hear it; this should be at least 20/30
Loop="bool" loop means replay, true will replay, false will not

You can explore some of the other settings, most of which won't have major effects on the sound; I just went over the most basic properties.

**Change int to corresponding integers (i.e. 1,2,3,4), floats to corresponding decimal values (i.e. 1.0, 0.76, 0.245), and bool to true or false values.
Thanks so much! Glad i am able to add this in. Smile
06-19-2012, 07:27 AM
Find




Users browsing this thread: 2 Guest(s)