| Author | Message | 
        
			| Neutrality 
					Joined: Thu May 12, 2011 5:35 am
 Posts: 11
   |   Help with LUAThis is probably just a noob problem as I am very inexperienced with lua, what I'm trying to do is make an actor that gibs when it gets a certain distance to an enemy actor. Code: function Update(self)for actor in MovableMan.Actors do
 local distcheck = SceneMan:shortestDistance(self.Pos,actor.Pos,true).Magnitude
 if distcheck < 20 then
 self.ignoreteam = actor.Team
 self:GibThis()
 break
 end
 end
 end
 
I'm just getting silent crashes when CC loads my .rte, can anyone help with this?
 
 | 
		
			| Thu May 12, 2011 5:43 am | 
					
					   | 
	
	
		|  | 
	
			| Roast Veg Data Realms Elite 
					Joined: Tue May 25, 2010 8:27 pm
 Posts: 4522
 Location: Constant motion
   |   Re: Help with LUALua does not cause silent crashes on startup as a general rule, but I can correct some errors for you. Code: function Update(self)for actor in MovableMan.Actors do
 local distcheck = SceneMan:shortestDistance(self.Pos,actor.Pos,true);
 if distcheck <= 20 then
 self.ignoreteam = actor.Team;
 self:GibThis()
 break
 end
 end
 end
 
 | 
		
			| Thu May 12, 2011 4:26 pm | 
					
					   | 
	
	
		|  | 
	
			| Grif REAL AMERICAN HERO 
					Joined: Sat Jan 27, 2007 10:25 pm
 Posts: 5655
   |   Re: Help with LUARoast Veg wrote: Lua does not cause silent crashes on startup  as a general rule, but I can correct some errors for you. Code: function Update(self)if self.timer then
 if self.timer:IsPastSimMS(500) then
 self.timer:Reset();
 for actor in MovableMan.Actors do
 local distcheck = SceneMan:ShortestDistance(self.Pos,actor.Pos,true);
 if distcheck.Magnitude <= 20 and self.Team ~= actor.Team then
 self:GibThis();
 break;
 end
 end
 else
 self.timer = Timer();
 end
 end
FTFY the timer code will make the game not lag so horrendously; looping through all actors every frame is terribly inefficient.
 
 | 
		
			| Thu May 12, 2011 4:52 pm | 
					
					   | 
	
	
		|  | 
	
			| zalo 
					Joined: Sat Feb 03, 2007 7:11 pm
 Posts: 1496
   |   Re: Help with LUATo fix the silent startup crashes, you'll probably want to try grafting the Lua script onto a default actor and seeing if that works.
 
 If it does, then your problem is in your actor's .ini code.
 
 If it doesn't, check to make sure your "ScriptFile" leads to the proper location.
 
 
 | 
		
			| Thu May 12, 2011 6:24 pm | 
					
					     | 
	
	
		|  | 
	
			| Asklar Data Realms Elite 
					Joined: Fri Jan 07, 2011 8:01 am
 Posts: 6211
 Location: In your office, earning your salary.
   |   Re: Help with LUAWasn't it ScriptPath? 
 
 | 
		
			| Fri May 13, 2011 2:59 am | 
					
					   | 
	
	
		|  | 
	
			| Neutrality 
					Joined: Thu May 12, 2011 5:35 am
 Posts: 11
   |   Re: Help with LUAIt was the code causing the crashes, the script path was fine, problem now is: it loads fine, doesnt work and the console says error 'end' expected at line 16 'eof' even though there is an end at the eof... 
 
 | 
		
			| Fri May 13, 2011 4:23 am | 
					
					   | 
	
	
		|  | 
	
			| Asklar Data Realms Elite 
					Joined: Fri Jan 07, 2011 8:01 am
 Posts: 6211
 Location: In your office, earning your salary.
   |   Re: Help with LUAThat means that you have to add another end.If that doesn't work, remove the end.
 
 
 | 
		
			| Fri May 13, 2011 4:29 am | 
					
					   | 
	
	
		|  | 
	
			| Neutrality 
					Joined: Thu May 12, 2011 5:35 am
 Posts: 11
   |   Re: Help with LUAWell the script loads without any errors now, sadly it doesn't work, any ideas? Thanks for all the help btw. 
 
 | 
		
			| Fri May 13, 2011 4:38 am | 
					
					   | 
	
	
		|  | 
	
			| Xery 
					Joined: Sat Feb 26, 2011 10:29 am
 Posts: 163
   |   Re: Help with LUANeutrality wrote: Well the script loads without any errors now, sadly it doesn't work, any ideas? Thanks for all the help btw.The script no more runs after its loader disappeared...right?
 
 | 
		
			| Fri May 13, 2011 4:55 am | 
					
					   | 
	
	
		|  | 
	
			| Neutrality 
					Joined: Thu May 12, 2011 5:35 am
 Posts: 11
   |   Re: Help with LUAI'm not sure what you mean? the script is exactly the same as the code grif posted... 
 
 | 
		
			| Fri May 13, 2011 5:05 am | 
					
					   | 
	
	
		|  | 
	
			| Xery 
					Joined: Sat Feb 26, 2011 10:29 am
 Posts: 163
   |   Re: Help with LUAIs there any example of this in other mods? 
 
 | 
		
			| Fri May 13, 2011 5:58 am | 
					
					   | 
	
	
		|  | 
	
			| Neutrality 
					Joined: Thu May 12, 2011 5:35 am
 Posts: 11
   |   Re: Help with LUAnot sure, it should work just like a landmine of sorts except that its an ahuman actor 
 
 | 
		
			| Fri May 13, 2011 6:00 am | 
					
					   | 
	
	
		|  | 
	
			| Asklar Data Realms Elite 
					Joined: Fri Jan 07, 2011 8:01 am
 Posts: 6211
 Location: In your office, earning your salary.
   |   Re: Help with LUAThat's wierd.
 It's not showing any errors at all?
 Could you post the code to check it, please.
 
 
 | 
		
			| Fri May 13, 2011 8:55 pm | 
					
					   | 
	
	
		|  | 
	
	
		|  |