EvilDeadPunk 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 3 
	Threads: 1 
	Joined: Jul 2013
	
 Reputation: 
0
		
	 | 
	
		
			
Scripting help 
			 
			
				So I'm incredibly new at scripting and I can't help but jump right in - I've been working on the same issue for a few hours now and searched the web to no avail - if anyone can figure out why I'm getting the "Unexpected Token" error, I would be greatly appreciative. 
 
Here is the full script: 
//////////////////////////// 
// Run when the map starts 
void OnStart() 
{ 
	AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);  
} 
 
void MonsterFunction(string &in asParent, string &in asChild, int alState) 
{ 
	AddEnemyPatrolNode("brute_1", "PathNodeArea_1", 0, ""); 
	AddEnemyPatrolNode("brute_1", "PathNodeArea_5", 0, ""); 
	AddEnemyPatrolNode("brute_1", "PathNodeArea_10", 0, ""); 
	SetEntityActive("brute_1", true); 
} 
 
{ 
AddUseItemCallback("", "cellar_key_1", "cellar_1", "UsedKeyOnDoor", true); 
} 
void FUNCTION(string &in asItem, string &in asEntity) 
{ 
SetSwingDoorLocked("cellar_1", false, true); 
PlaySoundAtEntity("", "unlock_door", "cellar_1", 0, false); 
RemoveItem("cellar_key_1"); 
} 
 
 
EDIT: I figured out what was wrong...there were some things mixed up everywhere, including in the bit of script that I didn't think was essential or doing anything. 
 
void FUNCTION(string &in asItem, string &in asEntity) was supposed to be 'void UsedKeyOnDoor(string &in asItem, string &in asEntity)
			 
			
			
			
				
(This post was last modified: 07-19-2013, 04:58 PM by EvilDeadPunk.)
 
				
			 
		 |  
	 
 | 
 
	| 07-19-2013, 03:36 AM  | 
	
		
	 | 
 
 
	
		
		Tomato Cat 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 287 
	Threads: 2 
	Joined: Sep 2012
	
 Reputation: 
20
		
	 | 
	
		
			
RE: Scripting help 
			 
			
				This is also an issue: 
{ AddUseItemCallback("", "cellar_key_1", "cellar_1", "UsedKeyOnDoor", true); } 
 
 
A callback needs to be declared in another function (onstart, etc) for it to work. 
 
I don't think writing it like above generates a compiler error (provided there are no curly braces), but the AddUseItemCallback function itself won't ever be called.
			  
			
			
			
		 |  
	 
 | 
 
	| 07-19-2013, 05:05 AM  | 
	
		
	 | 
 
 
	
		
		EvilDeadPunk 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 3 
	Threads: 1 
	Joined: Jul 2013
	
 Reputation: 
0
		
	 | 
	
		
			
RE: Scripting help 
			 
			
				 (07-19-2013, 05:05 AM)Tomato Cat Wrote:  This is also an issue: 
 
{ AddUseItemCallback("", "cellar_key_1", "cellar_1", "UsedKeyOnDoor", true); } 
 
  
A callback needs to be declared in another function (onstart, etc) for it to work.  
 
I don't think writing it like above generates a compiler error (provided there are no curly braces), but the AddUseItemCallback function itself won't ever be called. 
It was actually not a part of the coding that I posted, except I was missing a function. The error was being caused by a semi-colon and missing braces in the "OnEnter" section.
			  
			
			
			
				
(This post was last modified: 07-19-2013, 07:46 AM by EvilDeadPunk.)
 
				
			 
		 |  
	 
 | 
 
	| 07-19-2013, 07:42 AM  | 
	
		
	 | 
 
 
	
		
		No Author 
 
 
		
			Posting Freak 
			
			
			
 
			
	Posts: 962 
	Threads: 10 
	Joined: Jun 2012
	
 Reputation: 
13
		
	 | 
	
		
			
RE: Scripting help 
			 
			
				Is this thread is solved already ?
			 
			
			
 
			
		 |  
	 
 | 
 
	| 07-19-2013, 10:21 AM  | 
	
		
	 | 
 
 
	
		
		EvilDeadPunk 
 
 
		
			Junior Member 
			
			
			
 
			
	Posts: 3 
	Threads: 1 
	Joined: Jul 2013
	
 Reputation: 
0
		
	 | 
	
		
			
RE: Scripting help 
			 
			
				 (07-19-2013, 10:21 AM)No Author Wrote:  Is this thread is solved already ? 
Yes
			  
			
			
			
		 |  
	 
 | 
 
	| 07-19-2013, 04:57 PM  | 
	
		
	 | 
 
 
	 
 |