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
Script Help i need some help
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#8
RE: i need some help

No. You need to learn how function parameters work.

When you add a function via AddEntityCollideCallback (in this case, we are creating a function called PlaySound), the callbacks will always be (string &in asParent, string &in asChild, int alState). Those parameters are what you'll see in the engine scripts wiki page: http://wiki.frictionalgames.com/hpl2/amn..._functions

Look at the entry for the collide callback:

void AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);

Calls a function when two entites collide.
Callback syntax: void MyFunc(string &in asParent, string &in asChild, int alState)

asParentName - internal name of main object
asChildName - internal name of object that collides with main object (asterix (*) NOT supported!)
asFunction - function to call
abDeleteOnCollide - determines whether the callback after it was called
alStates - 1 = only enter, -1 = only leave, 0 = both

See that callback syntax? That is what the new function's parameters will always be!

So in the end it should be:
void OnStart()
{
//the collide callback is pretty much always in void OnStart(), don't have it floating by itself.
AddEntityCollideCallback("Player", "popout1", "PlaySound", true, 0);
}


void PlaySound(string &in asParent, string &in asChild, int alState)
{
if(HasItem("scarykey_1") == false) return;

PlaySoundAtEntity("scream", "21_scream10.ogg", "popout1", 0, false);
}

Never change those parameters. If you wanted to effect something in the function, you could.

Let's say I wanted a sound to play at the parent entity. Now this function is called by two different collide callbacks, with two different parent entities, but I always want it to play at the parent entity, then inside the callback function, I would write something like:

PlaySoundAtEntity("sound", "sound.snt", asParent, 0, false); //asParent == the parent entity. It may be a chair, it may be a player, it will change depending on what you want it to do.

Hope this is clear for you.

(This post was last modified: 05-28-2012, 05:30 PM by Putmalk.)
05-28-2012, 05:29 PM
Find


Messages In This Thread
i need some help - by TheIcyPickle - 05-28-2012, 04:24 AM
RE: i need some help - by Putmalk - 05-28-2012, 04:34 AM
RE: i need some help - by TheIcyPickle - 05-28-2012, 06:12 AM
RE: i need some help - by Putmalk - 05-28-2012, 06:55 AM
RE: i need some help - by TheIcyPickle - 05-28-2012, 07:27 AM
RE: i need some help - by Putmalk - 05-28-2012, 04:23 PM
RE: i need some help - by TheIcyPickle - 05-28-2012, 05:13 PM
RE: i need some help - by Putmalk - 05-28-2012, 05:29 PM
RE: i need some help - by TheIcyPickle - 05-28-2012, 06:11 PM
RE: i need some help - by Putmalk - 05-28-2012, 06:21 PM
RE: i need some help - by TheIcyPickle - 05-28-2012, 06:53 PM
RE: i need some help - by Mine Turtle - 05-28-2012, 06:56 PM
RE: i need some help - by Putmalk - 05-28-2012, 07:06 PM



Users browsing this thread: 2 Guest(s)