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
Whats wrong with my script?
Sennep Offline
Junior Member

Posts: 47
Threads: 6
Joined: Apr 2011
Reputation: 0
#1
Whats wrong with my script?

Hi!

This is a part of my script:

void OnStart()
{
AddUseItemCallback("", "bedroomkey", "mansion_1", "UsedKeyOnDoor", true);
AddEntityCollideCallback("player", "area_darkmusic", "PlayDarkMusic", true, 1);
}

void PlayDarkMusic(string &in asParent, string &in asChild, int alState)
{
PlayMusic("04_amb.ogg", true, 1.0f, 0, 0, true);
SetEntityActive("servant_grunt_1", true);
}

But there's something wrong with it. What happens is, the Grunt stays inactive and the music doesn't play.

Can you spot the bug?

Oh, and ignore the AddUseItemCallback.
05-16-2011, 02:24 PM
Find
Roenlond Offline
Senior Member

Posts: 331
Threads: 3
Joined: Apr 2011
Reputation: 0
#2
RE: Whats wrong with my script?

AddEntityCollideCallback("Player", "area_darkmusic", "PlayDarkMusic", true, 1);

There's your issue. It should be capitalized.
05-16-2011, 02:31 PM
Find
Sennep Offline
Junior Member

Posts: 47
Threads: 6
Joined: Apr 2011
Reputation: 0
#3
RE: Whats wrong with my script?

Oh.. Well that was pretty simple.

Thanks for the help!
05-16-2011, 02:33 PM
Find
Roenlond Offline
Senior Member

Posts: 331
Threads: 3
Joined: Apr 2011
Reputation: 0
#4
RE: Whats wrong with my script?

Most errors are simple to solve once you spot them Smile
05-16-2011, 02:34 PM
Find
Sennep Offline
Junior Member

Posts: 47
Threads: 6
Joined: Apr 2011
Reputation: 0
#5
RE: Whats wrong with my script?

heh yeah Big Grin
05-16-2011, 02:43 PM
Find
Sennep Offline
Junior Member

Posts: 47
Threads: 6
Joined: Apr 2011
Reputation: 0
#6
RE: Whats wrong with my script?

Again i have a script question (is there a thread for that?).

void OnStart()
{
AddUseItemCallback("", "bedroomkey", "mansion_1", "UsedKeyOnDoor", true);
AddEntityCollideCallback("Player", "area_darkmusic", "PlayDarkMusic", false, 1);
AddEntityCollideCallback("Player", "area_darkmusic", "StopDarkMusic", false, -1);
}

void StopDarkMusic(string &in asParent, string &in asChild, int alState)
{
StopMusic(3, 0);
}

void PlayDarkMusic(string &in asParent, string &in asChild, int alState)
{
PlayMusic("04_amb.ogg", true, 1.0f, 3, 0, true);
}

That is the beginning of my script. The point is that i want to have music, but only when you are in a special area. The music doesn't go away when you exit area.
05-16-2011, 04:28 PM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#7
RE: Whats wrong with my script?

I assume the script area is large and takes up the whole room? Actually, you can't set the callback for the same area twice. Make two separate areas.
(This post was last modified: 05-16-2011, 08:04 PM by MrBigzy.)
05-16-2011, 08:02 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#8
RE: Whats wrong with my script?

You could do this, but put the area at where the player will enter/exit the room:

void OnStart()
{
     AddEntityCollideCallback("Player", "area_darkmusic", "PlayDarkMusic", false, 1);
}
void PlayDarkMusic(string &in asParent, string &in asChild, int alState)
{
     PlayMusic("04_amb.ogg", true, 1, 3, 0, true);
     AddTimer("", 2, "Func01");
}
void Func01(string &in asTimer)
{
     AddEntityCollideCallback("Player", "area_darkmusic", "StopDarkMusic", false, 1);
}
void StopDarkMusic(string &in asParent, string &in asChild, int alState)
{
     StopMusic(3, 0);
}

You can further modify the script to where it is impossible for the music to still play when the player leaves the area.

05-16-2011, 11:03 PM
Find
Sennep Offline
Junior Member

Posts: 47
Threads: 6
Joined: Apr 2011
Reputation: 0
#9
RE: Whats wrong with my script?

Hm. Didn't know you couldn't set two callbacks for one area. But its working now. Thanks!
(This post was last modified: 05-17-2011, 12:44 PM by Sennep.)
05-17-2011, 12:44 PM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#10
RE: Whats wrong with my script?

Instead, you can use 'alState's to determine when player enters or escapes from the area and use them as intended.

if( alState == 1) -> This is for entering
if( alState == -1) -> This is for escaping
if( alState == 0) -> This is for both

05-17-2011, 12:50 PM
Website Find




Users browsing this thread: 1 Guest(s)