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
goodcap Offline
Member

Posts: 193
Threads: 112
Joined: Jun 2012
Reputation: 3
#1
Activate intro on Scriptarea

Okay, so i'd like to say right of the bat that i'm absolutely horrid at scripting. YOU'VE BEEN WARNED!


Okay, so in my custom story i've created a road, and i've created a scriptarea at the end of the road. What I want is that as soon as the player walks on that scriptarea the screen fades out and starts the intro of my custom story.

My question is: How do I make it that when you walk over the scriptarea the intro starts
(I already have a full functioning intro script, but i'm only missing the scriptarea trigger script thingy)

I've checked the Scripting page and I found things such as "AddEntityCollideCallback". I was wondering if that'll do the trick?


Let me know!
Thanks


goodcap
02-23-2015, 03:24 PM
Find
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
Darkfire Offline
Senior Member

Posts: 371
Threads: 22
Joined: May 2014
Reputation: 15
#3
RE: Activate intro on Scriptarea

I know I'm saying this for hundredth time and some people prolly get bored of this, but if you have no idea what scripting is about, go and watch some Youtube tutorials (Mudbill's ?).
Then, when you know the basic stuff, come back to ask and learn new things Smile

Intros require quite lot of work, depending on what you want to include; banners, recordings or player walking by themself.

Ps. Sorry for not saying anything about your problem, but Romulator pretty much answered your question Wink

02-23-2015, 07:07 PM
Find




Users browsing this thread: 1 Guest(s)