(02-05-2013, 04:11 PM)The Rock Worm Wrote: Now let's see if I understand this correctly. Let's say we have a script coding called "RandomNotes". I then make a the script area in the LevelEditor (represented by a red box) also called "RandomNotes". Would this mean the coding knows to start once you enter the script area of the same name?
Ohhh, thats what you meant by script box
Ignore what I said then.
There are two ways of 'connecting' a script area to a piece of code.
Lets say you have a function called 'RandomNotes', and the script area called 'SA_RandomNotes' (the SA stands for 'script area', to make it obvious what it is)
For me, the simplest way to connect these two is like this...
void OnStart()
{
AddEntityCollideCallback("Player", "SA_RandomNotes", "RandomNotes", true, 0);
}
void RandomNotes(string &in strParent, string &in strChild, int inState)
{
// stuff happens when you go into script area
}
The line in OnStart, 'AddEntityCollideCallback', basically means that when the first item on the list ("Player") comes into contact with the second ("SA_RandomNotes"), it 'activates' (or, 'calls') the function named in the third ("RandomNotes").
The other way of doing it is within the level editor, if you select the script area and go to the 'Area' tab (think its called area, sorry at work at the moment so can't check!), you can add the collide callback by writing the function name that you want to activate into the appropriate box. This I don't personally like, as it makes things more complicated if you want to change the function names (you'll need to remember to change them in the level editor too, rather than just the hps)