Frictional Games Forum (read-only)

Full Version: Expected Identifier Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I think I'll be making a lot of these tonight..I'm getting so frustrated with coding that I want to pull my hair out ;_;

//AddUseItemCallback
AddUseItemCallback("", "Key_1", "firstdoor1", "UsedKeyOnDoor", true);
{
void UsedKeyOnDoor(string &in asItem, string &in asEntity){
SetSwingDoorLocked("firstdoor1", false, true);
PlaySoundAtEntity("", "unlock_door", "firstdoor1", 0, false);
RemoveItem("Key_1");
}


Can someone tell me what I've done wrong here?

(05-02-2012, 02:18 AM)bkrstirregular Wrote: [ -> ]I think I'll be making a lot of these tonight..I'm getting so frustrated with coding that I want to pull my hair out ;_;

//AddUseItemCallback
AddUseItemCallback("", "Key_1", "firstdoor1", "UsedKeyOnDoor", true);
{
void UsedKeyOnDoor(string &in asItem, string &in asEntity){
SetSwingDoorLocked("firstdoor1", false, true);
PlaySoundAtEntity("", "unlock_door", "firstdoor1", 0, false);
RemoveItem("Key_1");
}


Can someone tell me what I've done wrong here?
You hid a { bracket at the end of a line, and that made you forgot to write a } bracket. Smile

Actually, no: You just wrote the wrong kind of bracket after OnStart(): { should be }

.. I'm still confused ;_; Can I just copy the entire code that I have onto here?
(05-02-2012, 03:03 AM)bkrstirregular Wrote: [ -> ].. I'm still confused ;_; Can I just copy the entire code that I have onto here?
Are you just confused about how it should look, or is the code still not working after you corrected it?
The corrected code should look like this:
Code:
OnStart()
{
  //AddUseItemCallback
  AddUseItemCallback("", "Key_1", "firstdoor1", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("firstdoor1", false, true);
    PlaySoundAtEntity("", "unlock_door", "firstdoor1", 0, false);
    RemoveItem("Key_1");
}

What if I have a wake up script already underneath the OnStart? Where do I put this?
(05-02-2012, 03:11 AM)bkrstirregular Wrote: [ -> ]What if I have a wake up script already underneath the OnStart? Where do I put this?
Even if you cut and paste together a script, you'll need to understand at least the basics about function syntax. ThisIsYourComputer has made a good video tutorial on YouTube.

Hmm..I think I figured it out..but now I can't figure out how to get the key to unlock the door x_X Ughh..so many things tonight ;_;
(05-02-2012, 03:46 AM)bkrstirregular Wrote: [ -> ]Hmm..I think I figured it out..but now I can't figure out how to get the key to unlock the door x_X Ughh..so many things tonight ;_;
Have you named the key entity "Key_1" in the level editor?
Edit: ...and named the door as well?
Yep Sad

The key vanishes so I guess the action works, but the door stays locked.

I do have this code in my script which tells the player that the door is locked

void DoorLockedPlayer(string &in entity)
{
if(GetSwingDoorLocked("firstdoor1") == true)
{

SetMessage("Messages", "msgname", 0);

}

do I need something to alter/cancel it out?


(05-02-2012, 03:55 AM)bkrstirregular Wrote: [ -> ]Yep Sad

The key vanishes so I guess the action works, but the door stays locked.

I do have this code in my script which tells the player that the door is locked

void DoorLockedPlayer(string &in entity)
{
if(GetSwingDoorLocked("firstdoor1") == true)
{

SetMessage("Messages", "msgname", 0);

}

do I need something to alter/cancel it out?
Question 1: Does the sound play?
Question 2: Is the door a normal swing door, or is it a level door that isn't supposed to move at all, or is it some weird special door that slides to the side or up?

Pages: 1 2