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
Door problem?(NOOB)
Stenkilde Offline
Junior Member

Posts: 24
Threads: 4
Joined: Jul 2012
Reputation: 0
#1
Door problem?(NOOB)

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.



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!
(This post was last modified: 07-15-2012, 06:29 PM by Stenkilde.)
07-15-2012, 06:22 PM
Find
Ongka Offline
Member

Posts: 225
Threads: 3
Joined: Nov 2010
Reputation: 20
#2
RE: Door problem?(NOOB)

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.

[Image: 18694.png]
07-15-2012, 06:34 PM
Find
Stenkilde Offline
Junior Member

Posts: 24
Threads: 4
Joined: Jul 2012
Reputation: 0
#3
RE: Door problem?(NOOB)

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) ?
07-15-2012, 06:37 PM
Find
Ongka Offline
Member

Posts: 225
Threads: 3
Joined: Nov 2010
Reputation: 20
#4
RE: Door problem?(NOOB)

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.

[Image: 18694.png]
07-15-2012, 06:42 PM
Find
Stenkilde Offline
Junior Member

Posts: 24
Threads: 4
Joined: Jul 2012
Reputation: 0
#5
RE: Door problem?(NOOB)

Okay, i see.

So you want me to open the HPS files from FC and just look around at them?
07-15-2012, 06:46 PM
Find
Ongka Offline
Member

Posts: 225
Threads: 3
Joined: Nov 2010
Reputation: 20
#6
RE: Door problem?(NOOB)

Exactly, here are some examples:
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.

[Image: 18694.png]
07-15-2012, 06:55 PM
Find
drunkmonk Offline
Member

Posts: 109
Threads: 7
Joined: Jun 2012
Reputation: 4
#7
RE: Door problem?(NOOB)

(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
07-15-2012, 06:56 PM
Find
Stenkilde Offline
Junior Member

Posts: 24
Threads: 4
Joined: Jul 2012
Reputation: 0
#8
RE: Door problem?(NOOB)

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!
07-15-2012, 06:58 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#9
RE: Door problem?(NOOB)

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);
}

Trying is the first step to success.
(This post was last modified: 07-15-2012, 08:10 PM by FlawlessHappiness.)
07-15-2012, 08:09 PM
Find
Stenkilde Offline
Junior Member

Posts: 24
Threads: 4
Joined: Jul 2012
Reputation: 0
#10
RE: Door problem?(NOOB)

That made me understand ALOT!

Thank you Beecake! Alot of helpfull people here! Smile
07-15-2012, 08:13 PM
Find




Users browsing this thread: 3 Guest(s)