Data Realms Fan Forums http://45.55.195.193/ |
|
Problems with SetMagnitude... Again. http://45.55.195.193/viewtopic.php?f=73&t=18994 |
Page 1 of 1 |
Author: | Areku [ Tue Jun 15, 2010 11:14 pm ] |
Post subject: | Problems with SetMagnitude... Again. |
OK, frankly, I'm pretty sure this should work: Code: function Create(self) self.VelMag = 0; self.VelMag = self.Vel.Magnitude; self.NewV = Vector(0,0); end function Update(self) if self.Vel.Magnitude < 80 then self.NewV = self.Vel; self.NewV:SetMagnitude(self.VelMag); self.Vel = Self.NewV; end end And yet it doesn't. When run, the console just returns "No overload of Vector:SetMagnitude(const.Vector,number) matched the arguments Vector:SetMagnitude(custom[float])". I also tried just typing self.NewV:SetMagnitude(80); , but that doesn't work either. Any thoughts on the reason? |
Author: | CaveCricket48 [ Tue Jun 15, 2010 11:25 pm ] |
Post subject: | Re: Problems with SetMagnitude... Again. |
That's the same as this: Code: 80 You need a variable. Code: numberofsheep = 80 Like that. |
Author: | Areku [ Wed Jun 16, 2010 1:04 am ] |
Post subject: | Re: Problems with SetMagnitude... Again. |
Eh, no? I changed the code to Code: function Create(self) self.NewMag = 80; self.NewV = Vector(0,0); end function Update(self) if self.Vel.Magnitude < 80 then self.NewV = self.Vel; self.NewV:SetMagnitude(self.NewMag); self.Vel = Self.NewV; end end And it still doesn't work. |
Author: | TheLastBanana [ Wed Jun 16, 2010 1:28 am ] |
Post subject: | Re: Problems with SetMagnitude... Again. |
What CaveCricket48 means is this: Code: self.NewV:SetMagnitude(self.NewMag); This doesn't actually change the variable; it returns a copy of the variable with the magnitude changed. You want this: Code: self.NewV = self.NewV:SetMagnitude(self.NewMag); |
Author: | Areku [ Wed Jun 16, 2010 1:34 am ] |
Post subject: | Re: Problems with SetMagnitude... Again. |
Gee, you're right! ...Even so, Code: function Create(self) self.NewMag = 80; self.NewV = Vector(0,0); end function Update(self) if self.Vel.Magnitude < 80 then self.NewV = self.Vel; self.NewV = self.NewV:SetMagnitude(self.NewMag); self.Vel = Self.NewV; end end Still doesn't work. Same error as before. |
Author: | Kyred [ Wed Jun 16, 2010 2:47 am ] |
Post subject: | Re: Problems with SetMagnitude... Again. |
You capitalized the "S" in the last self. (ie. change Self.NewV to self.NewV) |
Author: | Areku [ Wed Jun 16, 2010 2:50 am ] |
Post subject: | Re: Problems with SetMagnitude... Again. |
You're right about that. What doesn't affect the fact that the error appears on the SetMagnitude function, not on that line. |
Author: | CaveCricket48 [ Wed Jun 16, 2010 2:55 am ] |
Post subject: | Re: Problems with SetMagnitude... Again. |
Try, instead of Code: self.NewV = self.Vel do Code: self.NewV = Vector(self.Vel.X,self.Vel.Y)) Do the same with all vector calling/setting. While both should have the same results, I've had instances where that's not the case. |
Author: | Areku [ Wed Jun 16, 2010 3:09 am ] |
Post subject: | Re: Problems with SetMagnitude... Again. |
That just did the trick. Which is kind of creepy, actually. Many thanks to ye all. |
Author: | Kyred [ Wed Jun 16, 2010 3:29 am ] |
Post subject: | Re: Problems with SetMagnitude... Again. |
I'm still curious why using SetMagnitude didn't work out right. Anyone know why? |
Author: | TheLastBanana [ Wed Jun 16, 2010 3:38 am ] |
Post subject: | Re: Problems with SetMagnitude... Again. |
It's an issue in the actual engine, which is written in C++. The function doesn't take a constant value, but apparently the variables are stored as constant values, while creating a new Vector is a different story. |
Author: | Kyred [ Wed Jun 16, 2010 6:52 am ] |
Post subject: | Re: Problems with SetMagnitude... Again. |
That's really odd, but that does sort of make sense. Now I'm just wondering when the engine considers a Lua variable a constant and when it doesn't? |
Author: | Grif [ Wed Jun 16, 2010 8:04 pm ] |
Post subject: | Re: Problems with SetMagnitude... Again. |
Presumably, at completely batshit insane times that are wholly unpredictable. Remember, this is Cortex Command. |
Author: | Areku [ Wed Jun 16, 2010 8:54 pm ] |
Post subject: | Re: Problems with SetMagnitude... Again. |
Grif wrote: Presumably, at completely batshit insane times that are wholly unpredictable. Remember, this is Cortex Command. Because Data obviously coded it using the Miracle File System. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |