01-09-2012, 07:16 PM
I have a ladder in the elevator shaft leading to the basement but I want to add an area at the bottom of the ladder where it will load the next map. How do I go about doing that?
void AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);
void ChangeMap(string& asMapName, string& asStartPos, string& asStartSound, string& asEndSound);
(01-09-2012, 07:45 PM)Inurias Wrote: [ -> ](I am assuming that you already created a working script file for the corresponding map. If this is not the case, google up the basics about scripting with hpl2, also, this link could help you a lot: [url]http://wiki.frictionalgames.com/hpl2/start[/url])I do have a working script file, yes. Could you make an example of the script I would need to make? Thank you.
First you add a ScriptArea to your desired location, after that, you add a "AddEntityCollideCallback" call into your initializing function (most likely "OnStart" in your case), you do this by using:
Code:void AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);
Callback syntax: void MyFunc(string &in asParent, string &in asChild, int alState)
alState: 1 = enter, -1 = leave
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
Then, in your CallBack function you use:
Code:void ChangeMap(string& asMapName, string& asStartPos, string& asStartSound, string& asEndSound);
asMapName - the file to load
asStartPos - the name of the StartPos on the next map
asStartSound - the sound that is played when the change starts
asEndSound - the sound that is played when the new map is loaded
void OnStart()
{
AddEntityCollideCallback("Player", "YourScriptArea", "YourCallBackFunction", true, 1);
}
void YourCallBackFunction(string &in asParent, string &in asChild, int alState)
{
ChangeMap("YourMapName", "YourStartPosName", "YourStartSound", "YourEndSound");
}
(01-09-2012, 07:53 PM)Inurias Wrote: [ -> ]Okay, but you should make sure to read through the little script and make sure that you understand what's going on. I hope that you'll learn from it.*facepalm* I should've learned that by now haha. I'm terribly sick today so my brains not working at full XP Thank you so much.
Code:void OnStart()
{
AddEntityCollideCallback("Player", "YourScriptArea", "YourCallBackFunction", true, 1);
}
void YourCallBackFunction(string &in asParent, string &in asChild, int alState)
{
ChangeMap("YourMapName", "YourStartPosName", "YourStartSound", "YourEndSound");
}
- Inurias