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
Keys & Doors
Sinth Offline
Junior Member

Posts: 2
Threads: 1
Joined: Sep 2012
Reputation: 0
#1
Keys & Doors

I'm fairly certain this topic has been discussed very often but I've searched through the recent threads involving this issue and I still haven't found a solution to my problem.

Here's the scripts:

EXTRA_ENGLISH.LANG:
<LANGUAGE>
<RESOURCES>
</RESOURCES>
<CATEGORY Name="Absinthe Dreams">
<Entry Name="Description">This is just a test. Enjoy.</Entry>
</CATEGORY>
<CATEGORY Name="Inventory">
<Entry Name="ItemName_salvationkey">Key of Salvation</Entry>
<Entry Name="ItemDesc_salvationkey">A Key to your Salvation.</Entry>
</CATEGORY>
</LANGUAGE>



TEST1.HPS FILE:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "key_1", "LockedDoor1", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("LockedDoor1", false, true);
PlaySoundAtEntity("", "unlock_door", "LockedDoor1", 0.0f, false);
RemoveItem("key_1");
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}


------------------

The Key's name is "key_1", with the custom key name being "salvationkey".
The Door's name is "LockedDoor1", and has the "Locked" box checked.

When I pick up the key, the name and the description works fine. But the key doesn't work on the door. I just get the "The item cannot be used this way!" message.


I've been fiddling with this for hours trying to get it to work but to no avail. I've watched probably 5 video tutorials and I'm starting to feel like an idiot. :\

Anyone know what the problem could be? Is it my scripting?
It's my first map and my first script, so be gentle! ;u;


Thanks!
09-24-2012, 07:22 AM
Find
KH55 Offline
Junior Member

Posts: 10
Threads: 0
Joined: May 2012
Reputation: 0
#2
RE: Keys & Doors

AddEntityCollideCallback("key_1", "LockedDoor1", "UsedKeyOnDoor", true, 1);


void UsedKeyOnDoor(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorLocked("LockedDoor1", false, true);
PlaySoundAtEntity("doorunlock", "unlock_door.snt", "LockedDoor1", 0.0f, false);
RemoveItem("key_1");
}


This should work, I think.
09-24-2012, 08:53 AM
Find
Sinth Offline
Junior Member

Posts: 2
Threads: 1
Joined: Sep 2012
Reputation: 0
#3
RE: Keys & Doors

(09-24-2012, 08:53 AM)KH55 Wrote: AddEntityCollideCallback("key_1", "LockedDoor1", "UsedKeyOnDoor", true, 1);


void UsedKeyOnDoor(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorLocked("LockedDoor1", false, true);
PlaySoundAtEntity("doorunlock", "unlock_door.snt", "LockedDoor1", 0.0f, false);
RemoveItem("key_1");
}


This should work, I think.
That didn't seem to work. :C
09-24-2012, 09:04 AM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#4
RE: Keys & Doors

you're using the wrong callback

it should be

AddUseItemCallback(string& asName, string& asItem, string& asEntity, string& asFunction, bool abAutoDestroy);

asName - internal name
asItem - internal name of the item
asEntity - entity to be able to use the item on
asFunction - function to call
abAutoDestroy - determines whether the item is destroyed when used


void MyFunc(string &in asItem, string &in asEntity)

"What you think is irrelevant" - A character of our time

A Christmas Hunt
(This post was last modified: 09-24-2012, 09:40 AM by i3670.)
09-24-2012, 09:39 AM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#5
RE: Keys & Doors

////////////////////////////

// Run first time starting map

void OnStart()

{

AddUseItemCallback("", "key_1", "LockedDoor1", "UsedKeyOnDoor", true);

}



void UsedKeyOnDoor(string &in asItem, string &in asEntity)

{

SetSwingDoorLocked("asEntity", false, true);

PlaySoundAtEntity("", "unlock_door", "LockedDoor1", 0.0f, false);

RemoveItem("asItem");

}



////////////////////////////

// Run when leaving map

void OnLeave()

{



}

Maybe this works.

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
09-24-2012, 01:34 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#6
RE: Keys & Doors

Maybe you should see this. You might understand the callbacks then, if it isn't too confusing: http://www.frictionalgames.com/forum/thread-18368.html

Because it is: (string &in asItem, string &in asEntity)

Trying is the first step to success.
09-24-2012, 03:32 PM
Find




Users browsing this thread: 1 Guest(s)