Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support | Shelf | Store

Privacy Policy


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripting mess!
Author Message
CapnJimmy Offline
Junior Member

Posts: 9
Joined: Jan 2011
Reputation: 0
Post: #1
Scripting mess!
Edit:

First problem solved now the key cannot be used with the door.

Here's the script:

void OnStart()
{
AddUseItemCallback("", "Key1", "Door_1", "KeyOnDoor", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Door_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "Door_1", 0.0f, true);
}


Also if you know how to add momentos that'd be cool too! =D
(This post was last modified: 01-22-2011 10:07 PM by CapnJimmy.)
01-20-2011 08:05 PM
Find all posts by this user Quote this message in a reply
jens Offline
Frictional Games

Posts: 3,111
Joined: Apr 2006
Reputation: 108
Post: #2
RE: Scripting mess!
it should be, you only use { } to encapsulate functions (everything in your script that begins with a void). You also had some ; after AddUseItemCallback that should not be there. I did not try the script so not sure it works, but I think I fixed all the errors.

void Onstart()
{
AddUseItemCallback("", "Stair_Key", "Stair_Door", "KeyOnDoor", TRUE);
AddUseItemCallback("", "Guest_Room_Key", "Guest_Room_Door", "UsedKeyOnGuestRoomDoor", TRUE);
AddUseItemCallback("", "Secret_Key", "Secret_Door", "UsedKeyOnSecretDoor", TRUE);
}


void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Stair_door", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "Stair_door", 0.0f, false);
RemoveItem("Stair_Key");
}

void UsedKeyOnGuestRoomDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Guest_Room_Door", false, true);
PlaySoundAtEntity("", "unlock_door", "Guest_Room_Door", 0, false);
RemoveItem("Guest_Room_Key");
}

void UsedKeyOnSecretDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Secret_Door", false, true);
PlaySoundAtEntity("", "unlock_door", "Secret_Door", 0, false);
RemoveItem("Secret_Key");
}


You can rewrite it like this and only use one function:

void Onstart()
{
AddUseItemCallback("", "Stair_Key", "Stair_Door", "KeyOnDoor", TRUE);
AddUseItemCallback("", "Guest_Room_Key", "Guest_Room_Door", "KeyOnDoor", TRUE);
AddUseItemCallback("", "Secret_Key", "Secret_Door", "KeyOnDoor", TRUE);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0.0f, false);
RemoveItem(asItem);
}

See all the use item on an entity that you setup in OnStart calls the same function (KeyOnDoor). Then by using asEntity and asItem, it will work for all doors and keys as the value of those variables are what you specified them to be in the AddUseItemCallback.
01-20-2011 08:48 PM
Visit this user's website Find all posts by this user Quote this message in a reply
CapnJimmy Offline
Junior Member

Posts: 9
Joined: Jan 2011
Reputation: 0
Post: #3
RE: Scripting mess!
Legend! Cheers mate, I'll try it as soon as I'm back on the PC!
01-20-2011 08:50 PM
Find all posts by this user Quote this message in a reply
CapnJimmy Offline
Junior Member

Posts: 9
Joined: Jan 2011
Reputation: 0
Post: #4
RE: Scripting mess!
Okay, so now it's saying that:

TRUE is not declared (But it's written in the code? :/ )

And that there's no matching signatures for line 4,1 and 5,1 .

Problem.

Do I have to change anything on the map other than the Entity names? I've tried adding connected props to no avail. Anything else?

Or is it just script based problems?

Solution?
(This post was last modified: 01-20-2011 11:48 PM by CapnJimmy.)
01-20-2011 11:40 PM
Find all posts by this user Quote this message in a reply
Vradcly Offline
Member

Posts: 100
Joined: Jan 2011
Reputation: 0
Post: #5
RE: Scripting mess!
Quote:

AddUseItemCallback("", "Stair_Key", "Stair_Door", "KeyOnDoor", TRUE);
AddUseItemCallback("", "Guest_Room_Key", "Guest_Room_Door", "UsedKeyOnGuestRoomDoor", TRUE);
AddUseItemCallback("", "Secret_Key", "Secret_Door", "UsedKeyOnSecretDoor", TRUE);


Try changeing TRUE to true...
01-21-2011 12:07 AM
Find all posts by this user Quote this message in a reply
CapnJimmy Offline
Junior Member

Posts: 9
Joined: Jan 2011
Reputation: 0
Post: #6
RE: Scripting mess!
Okay I can now get into the story. But now it says I can't use the key that way =(
01-21-2011 06:22 PM
Find all posts by this user Quote this message in a reply
CapnJimmy Offline
Junior Member

Posts: 9
Joined: Jan 2011
Reputation: 0
Post: #7
RE: Scripting mess!
Anyone know the solution to my problem (As stated above)?

Here's the script:

void OnStart()
{
AddUseItemCallback("", "Key1", "Door_1", "KeyOnDoor", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Door_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "Door_1", 0.0f, true);
}


Also if you know how to add momentos that'd be cool too! =D
(This post was last modified: 01-22-2011 10:07 PM by CapnJimmy.)
01-22-2011 09:48 PM
Find all posts by this user Quote this message in a reply
Oscar House Offline
Member

Posts: 218
Joined: Nov 2010
Reputation: 5
Post: #8
RE: Scripting mess!
If it says you can't use the key that way, the problem is probably with the names of your keys/doors. Check if the key and door names in the map match the ones in your code.

[Image: 2exldzm.png]
01-23-2011 12:54 AM
Find all posts by this user Quote this message in a reply
CapnJimmy Offline
Junior Member

Posts: 9
Joined: Jan 2011
Reputation: 0
Post: #9
RE: Scripting mess!
Key_1 on the map is Key_1 in the script

same with Door_1 =/
01-23-2011 01:35 AM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)