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 Activate intro on Scriptarea
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#2
RE: Activate intro on Scriptarea

Yep, an AddEntityCollideCallback is what you want:

AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);
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

So based on this, we can make one.

The parent is the Player, so we use "Player".
The child is what the Player collides with, so the name of your Script Area.
The function is the name of the function. For now, let's call it IntroFunc.
We delete on collide because this happens once, so True.
It happens when we enter, so the alState will be 1.

Thus, we put this information into OnStart() in our hps file.
PHP Code: (Select All)
void OnStart()
{
AddEntityCollideCallback("Player""ScriptArea""IntroFunc"true1);


And the Function name will be IntroFunc, which we also apply to our Callback Syntax (see the code snippet above). Then we get this:

PHP Code: (Select All)
void IntroFunc(string &in asParentstring &in asChildint alState)
{
//Intro script


And that's it! Just put whatever you want to happen in the intro between the Braces of the IntroFunc.

Thus, we get a code block which looks like this:

PHP Code: (Select All)
void OnStart()
{
AddEntityCollideCallback("Player""ScriptArea""IntroFunc"true1);
}

void IntroFunc(string &in asParentstring &in asChildint alState)
{
//Intro script


Just make sure the "ScriptArea" line in the AddEntityCollideCallback matches your Script Area name which you have defined in the Level Editor!

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 02-23-2015, 03:43 PM by Romulator.)
02-23-2015, 03:42 PM
Find


Messages In This Thread
Activate intro on Scriptarea - by goodcap - 02-23-2015, 03:24 PM
RE: Activate intro on Scriptarea - by Romulator - 02-23-2015, 03:42 PM
RE: Activate intro on Scriptarea - by Darkfire - 02-23-2015, 07:07 PM



Users browsing this thread: 1 Guest(s)