bkrstirregular
Junior Member
Posts: 17
Threads: 2
Joined: May 2012
Reputation:
0
|
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 |
|
Cranky Old Man
Posting Freak
Posts: 986
Threads: 20
Joined: Apr 2012
Reputation:
38
|
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.
Actually, no: You just wrote the wrong kind of bracket after OnStart(): { should be }
(This post was last modified: 05-02-2012, 02:48 AM by Cranky Old Man.)
|
|
05-02-2012, 02:47 AM |
|
bkrstirregular
Junior Member
Posts: 17
Threads: 2
Joined: May 2012
Reputation:
0
|
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 |
|
Cranky Old Man
Posting Freak
Posts: 986
Threads: 20
Joined: Apr 2012
Reputation:
38
|
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");
}
(This post was last modified: 05-02-2012, 03:09 AM by Cranky Old Man.)
|
|
05-02-2012, 03:08 AM |
|
bkrstirregular
Junior Member
Posts: 17
Threads: 2
Joined: May 2012
Reputation:
0
|
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 |
|
Cranky Old Man
Posting Freak
Posts: 986
Threads: 20
Joined: Apr 2012
Reputation:
38
|
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.
|
|
05-02-2012, 03:42 AM |
|
bkrstirregular
Junior Member
Posts: 17
Threads: 2
Joined: May 2012
Reputation:
0
|
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 |
|
Cranky Old Man
Posting Freak
Posts: 986
Threads: 20
Joined: Apr 2012
Reputation:
38
|
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?
(This post was last modified: 05-02-2012, 03:52 AM by Cranky Old Man.)
|
|
05-02-2012, 03:51 AM |
|
bkrstirregular
Junior Member
Posts: 17
Threads: 2
Joined: May 2012
Reputation:
0
|
RE: Expected Identifier Error
Yep
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 |
|
Cranky Old Man
Posting Freak
Posts: 986
Threads: 20
Joined: Apr 2012
Reputation:
38
|
RE: Expected Identifier Error
(05-02-2012, 03:55 AM)bkrstirregular Wrote: Yep
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?
|
|
05-02-2012, 04:04 AM |
|
|