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
Scripting mess!
jens Offline
Frictional Games

Posts: 4,093
Threads: 199
Joined: Apr 2006
Reputation: 202
#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
Website Find


Messages In This Thread
Scripting mess! - by CapnJimmy - 01-20-2011, 08:05 PM
RE: Scripting mess! - by jens - 01-20-2011, 08:48 PM
RE: Scripting mess! - by CapnJimmy - 01-20-2011, 08:50 PM
RE: Scripting mess! - by CapnJimmy - 01-20-2011, 11:40 PM
RE: Scripting mess! - by Vradcly - 01-21-2011, 12:07 AM
RE: Scripting mess! - by CapnJimmy - 01-21-2011, 06:22 PM
RE: Scripting mess! - by CapnJimmy - 01-22-2011, 09:48 PM
RE: Scripting mess! - by Oscar House - 01-23-2011, 12:54 AM
RE: Scripting mess! - by CapnJimmy - 01-23-2011, 01:35 AM



Users browsing this thread: 1 Guest(s)