| Author | Message | 
        
			| Mind 
					Joined: Thu Mar 06, 2008 10:54 pm
 Posts: 1360
 Location: USA
   |   Lua TermsJust wondering what these terms mean (not what tangent means, what the variables mean).  Like what the forumla, i guess, is stating. Code: math.sqrt(math.pow((actor.Pos.X-self.Pos.X),2) + math.pow((actor.Pos.Y - self.Pos.Y),2))
 
 actor.Vel.Y = actor.Vel.Y - (100 / diff * math.sin(ang))
 
 
 actor.Vel.X = actor.Vel.X - (100 / diff * math.cos(ang))
 
Thanks a lot!  
 
 | 
		
			| Sun Jun 07, 2009 1:49 am | 
					
					   | 
	
	
		|  | 
	
			| Grif REAL AMERICAN HERO 
					Joined: Sat Jan 27, 2007 10:25 pm
 Posts: 5655
   |   Re: Lua Terms
 
 | 
		
			| Sun Jun 07, 2009 1:51 am | 
					
					   | 
	
	
		|  | 
	
			| Mind 
					Joined: Thu Mar 06, 2008 10:54 pm
 Posts: 1360
 Location: USA
   |   Re: Lua TermsSo like tangent and sine and cosine......are all trig stuff with triangles, so when you use those functions, does it create an imaginary triangle?  I'm just confused as to how its actaully used.  I get how to find them and such, but im confused as to how they are used in CC. 
 
 | 
		
			| Sun Jun 07, 2009 2:42 am | 
					
					   | 
	
	
		|  | 
	
			| 411570N3 
					Joined: Wed Jan 07, 2009 10:26 am
 Posts: 4074
 Location: That quaint little British colony down south
   |   Re: Lua TermsThey're mathematical functions.You can use them to find the direction of something in degrees from their relative co-ordinates.
 You can also use them to make snazzy curve lines.
 
 
 | 
		
			| Sun Jun 07, 2009 5:03 am | 
					
					     | 
	
	
		|  | 
	
			| Roon3 
					Joined: Sun May 11, 2008 12:50 pm
 Posts: 899
   |   Re: Lua TermsCode: math.sqrt(math.pow((actor.Pos.X-self.Pos.X),2) + math.pow((actor.Pos.Y - self.Pos.Y),2))Gets the distance between two actors, I think. (Pythagorean theorem thingamabob)  Can't help you with the other stuff, I haven't learned trig yet.  
 
 | 
		
			| Sun Jun 07, 2009 3:02 pm | 
					
					     | 
	
	
		|  | 
	
			| Grif REAL AMERICAN HERO 
					Joined: Sat Jan 27, 2007 10:25 pm
 Posts: 5655
   |   Re: Lua TermsRoon3 wrote: Code: math.sqrt(math.pow((actor.Pos.X-self.Pos.X),2) + math.pow((actor.Pos.Y - self.Pos.Y),2))Gets the distance between two actors, I think. (Pythagorean theorem thingamabob)  Can't help you with the other stuff, I haven't learned trig yet. :(You're exactly right so don't feel bad. math.sqrt (so the entire rest of the statement is the square root) and then math.pow (exponent/power) of the x distance between the two actors squared, then the same for the y distance.
 
 | 
		
			| Sun Jun 07, 2009 5:43 pm | 
					
					   | 
	
	
		|  | 
	
			| Mind 
					Joined: Thu Mar 06, 2008 10:54 pm
 Posts: 1360
 Location: USA
   |   Re: Lua TermsYeah, so its obviously the distance formula,  
 {[(square root of(((x2-x1)^2) + (y2-y1)^2)] or like [sqaure root of the change in x sqyared plus the change in y squared]}
 
 just in lua terms between point a and point b.  I get that part.  Just dont get how like piipu gets his vortex gun to work like it does.
 
 
 
    							Last edited by Mind on Sun Jun 07, 2009 7:25 pm, edited 1 time in total. 
 
 | 
		
			| Sun Jun 07, 2009 7:22 pm | 
					
					   | 
	
	
		|  | 
	
			| Grif REAL AMERICAN HERO 
					Joined: Sat Jan 27, 2007 10:25 pm
 Posts: 5655
   |   Re: Lua TermsWhat's diff defined as? Let me guess here: the distance between the target and the vortex.
 It's the same thing as my teleporter code; just in a different way.
 
 
 | 
		
			| Sun Jun 07, 2009 7:24 pm | 
					
					   | 
	
	
		|  | 
	
			| Mind 
					Joined: Thu Mar 06, 2008 10:54 pm
 Posts: 1360
 Location: USA
   |   Re: Lua TermsCode: function Update(self)local diff = math.sqrt(math.pow((actor.Pos.X-self.Pos.X),2) + math.pow((actor.Pos.Y - self.Pos.Y),2)) <-- distance between vortex and actor i know.
 if diff < 30 then  <---- if the distance between the two is less than 30 then
 diff = 30 <--- the distance is 30
 actor.Health = 0  <--- actor hp is 0
 end
 if (diff < 400) and actor.PinStrength == 0 then  <---- obvious
 local diffx = actor.Pos.X - self.Pos.X  <-----the lengthdir_x
 local diffy = actor.Pos.Y - self.Pos.Y <-----the lengthdir_x
 local ang = math.atan2(diffy,diffx)  *** **why is it finding the opposite tangent of the two sides?
 actor.Vel.Y = actor.Vel.Y - (100 / diff * math.sin(ang))  <----the y velocity is 100 divided by the distance between the two times the sin of the second tangent of the two sides of the triangle (lengthdir_x,lengthdir_y)
 actor.Vel.X = actor.Vel.X - (100 / diff * math.cos(ang))  same cept x
 end
 
 
 
 end
I just dont get what the starred areas do, and correct me if im wrong with the others  
 
 | 
		
			| Sun Jun 07, 2009 7:31 pm | 
					
					   | 
	
	
		|  | 
	
			| Grif REAL AMERICAN HERO 
					Joined: Sat Jan 27, 2007 10:25 pm
 Posts: 5655
   |   Re: Lua TermsThe diff is the difference between the two positions. math.atan2 determines the root angle of a triangle based on the diffy and diffx.
 So what the entire script does is this:
 
 if an actor is within a distance of 400 pixels
 if the actor is within 30 pixels of the vortex, kill them
 
 if the difference is less than 400 and the actor is not pinned
 find the opposite and adjacent of a triangle
 find the root angle of the same triangle
 then set the velocity of the actor to 100 divided by the hypotenuse of that triangle, resulting in an inward suction effect
 
 
 | 
		
			| Sun Jun 07, 2009 7:37 pm | 
					
					   | 
	
	
		|  | 
	
			| Mind 
					Joined: Thu Mar 06, 2008 10:54 pm
 Posts: 1360
 Location: USA
   |   Re: Lua TermsGrif wrote: The diff is the difference between the two positions. math.atan2 determines the root angle of a triangle based on the diffy and diffx.
 So what the entire script does is this:
 
 if an actor is within a distance of 400 pixels
 if the actor is within 30 pixels of the vortex, kill them
 
 if the difference is less than 400 and the actor is not pinned
 find the opposite and adjacent of a triangle
 find the root angle of the same triangle
 then set the velocity of the actor to 100 divided by the hypotenuse of that triangle, resulting in an inward suction effect
Oh..... ok.  Im trying to make something along the lines of that, cept its not.  Ill post if i can't get it :3
 
 | 
		
			| Sun Jun 07, 2009 7:47 pm | 
					
					   | 
	
	
		|  | 
	
	
		|  |