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
Expected Identifier Error
Author Message
bkrstirregular Offline
Junior Member

Posts: 17
Threads: 2
Joined: May 2012
Reputation: 0
#1
Expected Identifier Error

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
Find Reply
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#2
RE: Expected Identifier Error

(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 }


Noob scripting tutorial: From Noob to Pro

(This post was last modified: 05-02-2012, 02:48 AM by Cranky Old Man.)
05-02-2012, 02:47 AM
Find Reply
bkrstirregular Offline
Junior Member

Posts: 17
Threads: 2
Joined: May 2012
Reputation: 0
#3
RE: Expected Identifier Error

.. I'm still confused ;_; Can I just copy the entire code that I have onto here?
05-02-2012, 03:03 AM
Find Reply
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#4
RE: Expected Identifier Error

(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:
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");
}


Noob scripting tutorial: From Noob to Pro

(This post was last modified: 05-02-2012, 03:09 AM by Cranky Old Man.)
05-02-2012, 03:08 AM
Find Reply
bkrstirregular Offline
Junior Member

Posts: 17
Threads: 2
Joined: May 2012
Reputation: 0
#5
RE: Expected Identifier Error

What if I have a wake up script already underneath the OnStart? Where do I put this?
05-02-2012, 03:11 AM
Find Reply
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#6
RE: Expected Identifier Error

(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.


Noob scripting tutorial: From Noob to Pro

05-02-2012, 03:42 AM
Find Reply
bkrstirregular Offline
Junior Member

Posts: 17
Threads: 2
Joined: May 2012
Reputation: 0
#7
RE: Expected Identifier Error

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
Find Reply
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#8
RE: Expected Identifier Error

(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?

Noob scripting tutorial: From Noob to Pro

(This post was last modified: 05-02-2012, 03:52 AM by Cranky Old Man.)
05-02-2012, 03:51 AM
Find Reply
bkrstirregular Offline
Junior Member

Posts: 17
Threads: 2
Joined: May 2012
Reputation: 0
#9
RE: Expected Identifier Error

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
Find Reply
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#10
RE: Expected Identifier Error

(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?


Noob scripting tutorial: From Noob to Pro

05-02-2012, 04:04 AM
Find Reply




Users browsing this thread: 1 Guest(s)