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 Where is a key usually hidden? [Solved]
ethics Offline
Member

Posts: 51
Threads: 18
Joined: Jan 2014
Reputation: 0
#1
Where is a key usually hidden? [Solved]

So I had the idea to create a puzzle, where you encounter a locked door, then you have to backtrack to search for the key. It should be hidden in a closet, inside a white shirt.
Now I wanted the shirt to be interactable, so if you click on it, you get the key.
How do I do that?
I know the crator of "Deterioration" did it, I looked through the script, but it confused me.
Can you kind people out there help me?

(This post was last modified: 05-10-2014, 10:28 AM by ethics.)
04-17-2014, 01:30 PM
Find Reply
Romulator Offline
Not Tech Support ;-)

Posts: 3,626
Threads: 62
Joined: Jan 2013
Reputation: 195
#2
RE: Where is a key usually hidden?

I can help :3

The way I see it, you can do this one of two ways Smile You can give the item directly from the code, or you can make it drop from the shirt, preferably underneath it.

The first one, which you get directly from the shirt:
Spoiler below!

PHP Code: (Select All)
void OnStart()
{
SetEntityPlayerInteractCallback("<your_shirt_name>""your_function"true);
}

void your_function(string &in asEntity)
{
GiveItem("<the_key_name>""Puzzle""<itemname_in_lang_file>""key_study.tga"1);



That, I BELIEVE would work, but you would have to just test it to make sure you receive a key at all. Change the appropriate stuff that you need to (anything enclosed in a <> but don't delete the "" marks). The thing in the lang file is ItemName_<itemname> and ItemDesc_<itemname>. You can change the graphical image to whatever is in the redist/graphics/item/ folder.

The other method, which is make a key appear from underneath and fall to the ground is this:
Spoiler below!

PHP Code: (Select All)
void OnStart()
{
SetEntityPlayerInteractCallback("<your_shirt_name>""your_function"true);
}

void your_function(string &in asEntity)
{
SetEntityActive("<name_of_key"true);



This one, you have to place the appropriate key underneath the shirt, name it whatever the name of the key is in the Level Editor, and untick "Active" from the Level Editor.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
04-17-2014, 02:03 PM
Find Reply
ethics Offline
Member

Posts: 51
Threads: 18
Joined: Jan 2014
Reputation: 0
#3
RE: Where is a key usually hidden?

(04-17-2014, 02:03 PM)Romulator Wrote: I can help :3

The way I see it, you can do this one of two ways Smile You can give the item directly from the code, or you can make it drop from the shirt, preferably underneath it.

The first one, which you get directly from the shirt:
Spoiler below!

PHP Code: (Select All)
void OnStart()
{
SetEntityPlayerInteractCallback("<your_shirt_name>""your_function"true);
}

void your_function(string &in asEntity)
{
GiveItem("<the_key_name>""Puzzle""<itemname_in_lang_file>""key_study.tga"1);



That, I BELIEVE would work, but you would have to just test it to make sure you receive a key at all. Change the appropriate stuff that you need to (anything enclosed in a <> but don't delete the "" marks). The thing in the lang file is ItemName_<itemname> and ItemDesc_<itemname>. You can change the graphical image to whatever is in the redist/graphics/item/ folder.

The other method, which is make a key appear from underneath and fall to the ground is this:
Spoiler below!

PHP Code: (Select All)
void OnStart()
{
SetEntityPlayerInteractCallback("<your_shirt_name>""your_function"true);
}

void your_function(string &in asEntity)
{
SetEntityActive("<name_of_key"true);



This one, you have to place the appropriate key underneath the shirt, name it whatever the name of the key is in the Level Editor, and untick "Active" from the Level Editor.

Didn't knew it was that easy!
But I tried this script once for a locked door, I should interact with it and a message should be displayed. Didn't work.
I think ''SetEntityPlayerInteractionCallback'' works only for pickable items, like notes or oil.
But i'm gonna try it anyway.
Thanks! Big Grin

EDIT: As I said, didn't work. I think you ave to place a script area in front of the shirt to be able to interact with it.

ANOTHER EDIT: This time, I looked through the map of "Deterioration", and skimmed to the place, where I found the key in the shirt and indeed, you have to place a script area.
Thanks for your help, but now, I know the FULL TRUTH! Smile

(This post was last modified: 04-17-2014, 04:30 PM by ethics.)
04-17-2014, 04:19 PM
Find Reply
Mudbill Offline
Muderator

Posts: 3,877
Threads: 59
Joined: Apr 2013
Reputation: 178
#4
RE: Where is a key usually hidden?

Yeah, some entities don't work because they are static. If they can't be disabled in the level editor, I don't think you can interact with them either. Use script areas with ItemInteraction box checked instead.

04-17-2014, 05:17 PM
Find Reply
SSEAlexander Offline
Senior Member

Posts: 422
Threads: 26
Joined: Feb 2014
Reputation: 1
#5
RE: Where is a key usually hidden?

(04-17-2014, 05:17 PM)Mudbill Wrote: Yeah, some entities don't work because they are static. If they can't be disabled in the level editor, I don't think you can interact with them either. Use script areas with ItemInteraction box checked instead.

Ya,thats right.Object CANNOT be as "StaticProp" or else it will be static.It can be : "Object : Static". (Change in user defined variabled)
04-19-2014, 02:00 PM
Find Reply




Users browsing this thread: 1 Guest(s)