Once again, my Lua stuff gets errors for no apparent reason. I made a simple script to push stuff around with particles, and yet it doesn't work. I mean, at least not the way I wanted it to. Here's the thing:
Code:
function Create(self)
self.timer = Timer();
self.newmag = 0
end
function Update(self)
for actor in MovableMan.Actors do
local avgx = actor.Pos.X - self.Pos.X;
local avgy = actor.Pos.Y - self.Pos.Y;
local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
if dist < 20 and self.timer:IsPastRealMS(10) then
self.newmag = self.Vel.Magnitude + actor.Vel.Magnitude - (((actor.Pos.X - self.Pos.X) + (actor.Pos.Y - self.Pos.Y))/2) - (actor.Mass/2);
actor.Vel = actor.Vel + self.Vel;
print (self.newmag);
actor.Vel:SetMagnitude(self.newmag);
end
end
end
So, basically, I wanted it to set the actor's vel magnitude based on several parameters, such as mass, previous vel, etc. The "print" line returns a number based on such parameters. And yet, the console doesn't accept that as a SetMagnitude command, and keeps returning "no overload of actor:setmagnitude matches parameters...". I fear that something weird and unbeknownst to me is happening there. Anyone knows why?