Frictional Games Forum (read-only)

Full Version: Door problem?(NOOB)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello!

Here i am with my first noob problem! Yes i'm a noob.

So i'm trying to make these "normal" doors work. Or Swings doors to work.

I have this door which i want to stay locked, and then you pick up a key and you can unlock a door.



Code:
void UnlockLevelDoor(string &in item, string &in entity)
{    
void SetSwingDoorLocked(string& asName);
}


heres my script, i hope you guys can tell me what insane noob mistake i'm making.

Thank you!
Code:
void OnStart()
{
    AddUseItemCallback("UnlockDoor", "ENTER_KEY_NAME_HERE", "ENTER_DOOR_NAME_HERE","UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
            SetSwingDoorLocked("ENTER_DOOR_NAME_HERE", false, false);
}
This should work.
Hello Ongka!

Thanks for the SUPER quick answer!
A second question, could you try to explain to me why it has to be the specific "input" (string &in asItem) ?
If I remember correctly these are the values the function gets delivered. In this case it's the name of the item you're using and the name of the entity you're using it on.
Depends on what you try to achieve whit each function.
If you don't use an item from your inventory to call a function, you don't have to add string &in asItem.

For the beginning you should just look up functions from the original maps and copy their header.
Okay, i see.

So you want me to open the HPS files from FC and just look around at them?
Exactly, here are some examples:
Code:
void TimerXyz(string &in asTimer)
void CollideWithAnArea(string &in asParent, string &in asChild, int alState) //You use this most of the time
void InteractEntity(string &in asEntity)
void LeverChange(string &in asEntity, int alState) //Function that gets called if you change the state of a certain lever
There are some more, but you can do most of the things with these.
You can name the function how you'd like them to be, but you should use some kind of system to make it more clear.
(07-15-2012, 06:37 PM)Stenkilde Wrote: [ -> ]Hello Ongka!

Thanks for the SUPER quick answer!
A second question, could you try to explain to me why it has to be the specific "input" (string &in asItem) ?
The reason for the (string &in asItem) and what not is this is the function that is being called when you declared it earlier in your script. So what I mean is in your void OnStart you have a AddUseItemCallback("UnlockDoor", "ENTER_KEY_NAME_HERE", "ENTER_DOOR_NAME_HERE","UseKeyOnDoor", true); everything inside the brackets is all the information the script needs to be able to call the function. So the first quotes is the name of the callback(this is optional) the second is the name of the key that you want to use, the third is the name of the door you want the key to work with, and finally the fourth is the name of the function to call when you use the key on the specific door. Now for the (string &in asItem), this is the function that is being called when you use the key on the door, basically what is happening here is your telling that script that once you have used the key on the door you want it to unlock for example
I hope this helped
Thank you both Ongka and Drunkmonk!

I thank you guys so much for helping a noob like me out! Smile

Drunkmonk it did made sense to me!
The FC's Hps can look a little bit wild with a lot of differen scripting stuff, like variables and such.

http://wiki.frictionalgames.com/hpl2/amn..._functions

Use the wiki too! It works!

As soon as you know how scripting works then you will find it easy.

Quick tutorial:

void OnStart()
{
AddUseItemCallback("UnlockDoor", "KEY_NAME", "DOOR_NAME","UseKeyOnDoor", true);
The whole line allows the function to work.

///The red one is the name of the allowing. Usually you don't put anything here. Only if you f.x. want to ///delete a timer.

///The blue one is the name of the function, that happens when you use the item.
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
///This is the line that specifies that you are using and ITEM on an ENTITY.
{
SetSwingDoorLocked("DOOR_NAME", false, true);
}
That made me understand ALOT!

Thank you Beecake! Alot of helpfull people here! Smile
Pages: 1 2