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
Error: 'asEntity' and 'asItem' is Not Declared
Author Message
Kyle Offline
Posting Freak

Posts: 910
Joined: Sep 2010
Reputation: 7
Post: #1
Error: 'asEntity' and 'asItem' is Not Declared
There are so many bad things that can happen to any script, I guess I just don't completely understand it... Sad

But anyways, "asEntity" and "asItem" is not declared:


void OnStart()

{
AddEntityCollideCallback("Player" , "ScriptArea_2" , "CollideRoomFour" , true, 1);
AddEntityCollideCallback("CellarDoor2" , "ScriptArea_2" , "CollideRoomThree" , true, 1);
AddEntityCollideCallback("Player" , "ScriptArea_1" , "CollideRoomTwo" , true, 1);
AddUseItemCallback("", "CastleKey" , "CastleDoor" , "UsedKeyOnDoor2" , true);
AddUseItemCallback("", "Cellar Key" , "CellarDoor" , "UsedKeyOnDoor" , true);
}

void CollideRoomTwo(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("cellar_wood01_1", true, true);
GiveSanityDamage(25, true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{

SetSwingDoorLocked(asEntity, false, true);
SetLevelDoorLocked(asEntity, false);

PlaySoundAtEntity("unlocksound", "unlock_door.snt", asEntity, 0.0f, false);

RemoveItem(asItem);
}
void CollideRoomThree(string &in asParent, string &in asChild, int alstate)
{
GiveSanityDamage(10, true);
SetEntityActive("servant_grunt_1" , true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_15", 5.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_17", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_23", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_34", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_33", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_35", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_49", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_55", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_57", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_65", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_66", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_70", 0.0f, "");

}
void CollideRoomFour(string &in asParent, string &in asChild, int alstate)
{

}
void UsedKeyOnDoor2(string &in asParent, string &in asChild, int alState)
{
SetLevelDoorLocked(asEntity, false);
RemoveItem(asItem);
}

void OnEnter()
{

}

void OnLeave()
{

}

10-12-2010 03:33 AM
Find all posts by this user Quote this message in a reply
Entih Offline
Junior Member

Posts: 47
Joined: Sep 2010
Reputation: 0
Post: #2
RE: Error: 'asEntity' and 'asItem' is Not Declared
Double check your arguments for "UsedKeyOnDoor2" there, I think you might have copied something wrong! You need to be cautious when you write a function, as the wrong parameters can easily throw it off.

Remember, when the compiler tells you something is wrong with your script, it often tells you where, in the form of a line number. If you use Notepad++, finding a line number is pretty easy (Lower right, Ln #).
10-12-2010 04:14 AM
Find all posts by this user Quote this message in a reply
DamnNoHtml Offline
Senior Member

Posts: 386
Joined: Sep 2010
Reputation: 11
Post: #3
RE: Error: 'asEntity' and 'asItem' is Not Declared
void UsedKeyOnDoor2(string &in asParent, string &in asChild, int alState)
{
SetLevelDoorLocked(asEntity, false);
RemoveItem(asItem);
}

You are trying to reference "asEntity" when your function parameters are asParent, asChild, and alState. You're getting the error because asEntity doesn't exist.

The parameters should be
void UsedKeyOnDoor2(string &in asItem, string &in asEntity)
10-12-2010 04:16 AM
Find all posts by this user Quote this message in a reply
Kyle Offline
Posting Freak

Posts: 910
Joined: Sep 2010
Reputation: 7
Post: #4
RE: Error: 'asEntity' and 'asItem' is Not Declared
Okay, so I updated my map, and it works nicely, except I'm trying to get a sound to play when you collide with an area. It says, "(2,1):ERR :Unexpected token '{' "

I don't know what "(2,1)" means and also I don't know what "{" I should remove... Sad

void OnStart();
{
AddEntityCollideCallback("Player" , "ScriptArea_2" , "CollideRoomFour" , true, 1);
AddEntityCollideCallback("CellarDoor2" , "ScriptArea_2" , "CollideRoomThree" , true, 1);
AddEntityCollideCallback("Player" , "ScriptArea_1" , "CollideRoomTwo" , true, 1);
AddUseItemCallback("", "CastleKey" , "CastleDoor" , "UsedKeyOnDoor2" , true);
AddUseItemCallback("", "Cellar Key" , "CellarDoor" , "UsedKeyOnDoor" , true);
}
void CollideRoomTwo(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("cellar_wood01_1", true, true);
GiveSanityDamage(25, true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
SetLevelDoorLocked(asEntity, false);
PlaySoundAtEntity("unlocksound", "unlock_door.snt", asEntity, 0.0f, false);
RemoveItem(asItem);
}
void CollideRoomThree(string &in asParent, string &in asChild, int alstate)
{
GiveSanityDamage(10, true);
SetEntityActive("servant_grunt_1" , true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_15", 5.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_17", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_23", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_34", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_33", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_35", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_49", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_55", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_57", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_65", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_66", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_70", 0.0f, "");
}
void CollideRoomFour(string &in asParent, string &in asChild, int alstate)
{
PlaySoundAtEntity("Babycry","scare_baby_cry2.ogg","Player", 0.0f, false);
}
void UsedKeyOnDoor2(string &in asItem, string &in asEntity)
{
PlaySoundAtEntity("unlocksound", "unlock_door.snt", asEntity, 0.0f, false);
SetLevelDoorLocked(asEntity, false);
RemoveItem(asItem);
}
void OnEnter()
{

}

void OnLeave()
{

}

10-12-2010 11:34 AM
Find all posts by this user Quote this message in a reply
Chilton Offline
Member

Posts: 138
Joined: Sep 2010
Reputation: 0
Post: #5
RE: Error: 'asEntity' and 'asItem' is Not Declared
(10-12-2010 11:34 AM)Kyle Wrote:  Okay, so I updated my map, and it works nicely, except I'm trying to get a sound to play when you collide with an area. It says, "(2,1):ERR :Unexpected token '{' "

I don't know what "(2,1)" means and also I don't know what "{" I should remove... Sad

void OnStart()
{
AddEntityCollideCallback("Player" , "ScriptArea_2" , "CollideRoomFour" , true, 1);
AddEntityCollideCallback("CellarDoor2" , "ScriptArea_2" , "CollideRoomThree" , true, 1);
AddEntityCollideCallback("Player" , "ScriptArea_1" , "CollideRoomTwo" , true, 1);
AddUseItemCallback("", "CastleKey" , "CastleDoor" , "UsedKeyOnDoor2" , true);
AddUseItemCallback("", "Cellar Key" , "CellarDoor" , "UsedKeyOnDoor" , true);
}

void CollideRoomTwo(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("cellar_wood01_1", true, true);
GiveSanityDamage(25, true);
}

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

void CollideRoomThree(string &in asParent, string &in asChild, int alstate)
{
GiveSanityDamage(10, true);
SetEntityActive("servant_grunt_1" , true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_15", 5.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_17", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_23", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_34", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_33", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_35", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_49", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_55", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_57", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_65", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_66", 0.0f, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_70", 0.0f, "");
}

void CollideRoomFour(string &in asParent, string &in asChild, int alstate)
{
PlaySoundAtEntity("Babycry","scare_baby_cry2.ogg","Player", 0.0f, false);
}

void UsedKeyOnDoor2(string &in asItem, string &in asEntity)
{
PlaySoundAtEntity("unlocksound", "unlock_door.snt", asEntity, 0.0f, false);
SetLevelDoorLocked(asEntity, false);
RemoveItem(asItem);
}

void OnEnter()
{
}

void OnLeave()
{
}




Try it now (Copy the edited quote and make it your files contents) - You had a ; next to void OnStart() which screws up the Syntax

2,11 means line 2, letter/number/symbol 11
Edit: Or 2,1 in this case
10-12-2010 11:41 AM
Find all posts by this user Quote this message in a reply
Kyle Offline
Posting Freak

Posts: 910
Joined: Sep 2010
Reputation: 7
Post: #6
RE: Error: 'asEntity' and 'asItem' is Not Declared
Thank you very much! Big Grin

10-12-2010 04:40 PM
Find all posts by this user Quote this message in a reply
Chilton Offline
Member

Posts: 138
Joined: Sep 2010
Reputation: 0
Post: #7
RE: Error: 'asEntity' and 'asItem' is Not Declared
(10-12-2010 04:40 PM)Kyle Wrote:  Thank you very much! Big Grin

Any time - Glad i could help
10-12-2010 06:02 PM
Find all posts by this user Quote this message in a reply
Post Reply 




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