| 
		
	
		| TheGreatCthulhu   Member
 
 Posts: 213
 Threads: 10
 Joined: Oct 2010
 Reputation: 
32
 | 
			| RE: Script/area problem. 
 
				Are you sure there isn't a bug in the script itself? The fact that AddPropForce() works only means that OnStart() get's called, it doesn't tell you anything about the other functions. There could be other subtle errors. 
For example, here:
 AddEntityCollideCallback("Player", "area", "cake", false, 0); 
Are you sure that the first script area is named "area" in the editor?
 
You can use AddDebugMessage() to check which functions get called when. If a callback should be called but isn't, then it means that it wasn't hooked up correctly. Something along these lines:
 // Debugging using AddDebugMessage()
 void OnStart()
 {
 AddDebugMessage("In OnStart().", false);   // The message will be displayed in the lower left corner
 
 AddPropForce ("rope_beam02_Body_1", 500, 0, 0, "world");
 PlayMusic("12_amb.ogg", true, 0.8, 1, 1, true);
 AddEntityCollideCallback("Player", "area", "cake", false, 0);
 }
 
 void cake(string &in asParent, string &in asChild, int alState)
 {
 AddDebugMessage("In cake().", false);
 
 SetEntityActive("suitor", true);
 AddEnemyPatrolNode("suitor", "PathNode1", 0, "");
 AddEnemyPatrolNode("suitor", "PathNode2", 0, "");
 AddEntityCollideCallback("suitor", "ScriptArea_1", "cake1", false, 1);
 }
 
 void cake1(string &in asParent, string &in asChild, int alState)
 {
 AddDebugMessage("In cake1().", false);
 SetEntityActive("suitor", false);
 }
 
 |  |  
	| 01-07-2013, 02:28 PM |  |  
	
		| The chaser   Posting Freak
 
 Posts: 2,486
 Threads: 76
 Joined: Jun 2012
 Reputation: 
113
 | 
			| RE: Script/area problem. 
 
				Delete map_cache if there is.
			 
                               THE OTHERWORLD (WIP) ![[Image: k6vbdhu]](http://tinyurl.com/k6vbdhu)  
Aculy iz dolan. |  |  
	| 01-07-2013, 02:38 PM |  |  
	
		| TheGreatCthulhu   Member
 
 Posts: 213
 Threads: 10
 Joined: Oct 2010
 Reputation: 
32
 | 
			| RE: Script/area problem. 
 
				 (01-07-2013, 02:46 PM)Robosprog Wrote:  I did not notice a debug message at any rate, when running through the area, so that means that it is being called, yes? 
For a function, if the corresponding message was shown (each should be different, so that you can tell which one is it), then yes.
  (01-07-2013, 02:46 PM)Robosprog Wrote:  Done that, noticed it after second test but it still doesn't work. 
Hm... If all checks out, then I'm not sure what's going on. Gotta go now, but I'm going to try and test the code later on, if the issue isn't resolved. For now, when you say it doesn't work, you mean that everything compiles, no errors are shown, but enemy doesn't patrol the area? What exactly  happens, and what did you expect to happen?
 
Also, do you happen to use CreateEntityAtArea() anywhere in the script file (in parts not shown here, if any)? It says in the wiki:
 Quote:When creating an enemy [using this function], it cannot chase properly along PathNodes(using for example ShowEnemyPlayerPosition).  |  |  
	| 01-07-2013, 02:57 PM |  |  
	
		| FlawlessHappiness   Posting Freak
 
 Posts: 3,980
 Threads: 145
 Joined: Mar 2012
 Reputation: 
171
 | 
			| RE: Script/area problem. 
 
				Have you been to the properties of the area and unchecked "AutoRemoveAtLookAt" or something like that?
			 
 Trying is the first step to success. |  |  
	| 01-07-2013, 04:06 PM |  |  
	
		| Adrianis   Senior Member
 
 Posts: 620
 Threads: 6
 Joined: Feb 2012
 Reputation: 
27
 | 
			| RE: Script/area problem. 
 
				Does the enemy appear, and not walk along the path, or does the enemy just not appear at all?
			 |  |  
	| 01-07-2013, 04:08 PM |  |  
	
		| NaxEla   Senior Member
 
 Posts: 415
 Threads: 5
 Joined: Dec 2012
 Reputation: 
28
 | 
			| RE: Script/area problem. 
 
				Try AddEntityCollideCallback("Player", "area", "cake", true, 1); 
 |  |  
	| 01-07-2013, 04:08 PM |  |  
	
		| FlawlessHappiness   Posting Freak
 
 Posts: 3,980
 Threads: 145
 Joined: Mar 2012
 Reputation: 
171
 | 
			| RE: Script/area problem. 
 
				 (01-07-2013, 04:08 PM)NaxEla Wrote:  Try
 AddEntityCollideCallback("Player", "area", "cake", true, 1); 
 
That shouldn't change anything. 
What you change there is that the scripts isn't able to call again, and only calls when the player enters the area. 
Though it's a little strange to have it set to "...false, 0);"
			 
 Trying is the first step to success. |  |  
	| 01-07-2013, 05:03 PM |  |  
	
		| TheGreatCthulhu   Member
 
 Posts: 213
 Threads: 10
 Joined: Oct 2010
 Reputation: 
32
 | 
			| RE: Script/area problem. 
 
				Another guess at what could be happening - if you add code to the script file and just hit "Quick Reload", only OnEnter() is called, if it exists, and OnStart() is not. OnStart() is only called when the player enters the map for the first time, or during development, only on full reload. 
 If the handler assignment code was added to preexisting code after you started the map (which would explain why rope swinging works), but you've only used quick reload, the updated OnStart() function is never called, so the cake() callback is never hooked up.
 
Edit: Apparently, that's not the case. Both OnStart() and OnEnter() get called on quick reload... God dammit. XD
 
P.S.
  (01-07-2013, 05:03 PM)beecake Wrote:  Though it's a little strange to have it set to "...false, 0);" Nah. It may not be used so often, but it isn't strange if the collision needs to be detected only once.
			 |  |  
	| 01-07-2013, 06:35 PM |  |  
	
		| FlawlessHappiness   Posting Freak
 
 Posts: 3,980
 Threads: 145
 Joined: Mar 2012
 Reputation: 
171
 | 
			| RE: Script/area problem. 
 
				 (01-07-2013, 06:35 PM)TheGreatCthulhu Wrote:   (01-07-2013, 05:03 PM)beecake Wrote:  Though it's a little strange to have it set to "...false, 0);"Nah. It may not be used so often, but it isn't strange if the collision needs to be detected only once. 
But if the detection should be only once then it should be true, and not false.
 
If it's false the monster will keep being set active, and be assigned patrol nodes everytime the function calls, and that's at least 2 times since the next value is 0
			 
 Trying is the first step to success. |  |  
	| 01-07-2013, 07:10 PM |  |  
	
		| TheGreatCthulhu   Member
 
 Posts: 213
 Threads: 10
 Joined: Oct 2010
 Reputation: 
32
 | 
			| RE: Script/area problem. 
 
				Oh, sry - you are correct; I completely misread that code snippet. Didn't even notice the value of the last param.
			 |  |  
	| 01-07-2013, 07:16 PM |  |  |