Simulating an explosion in Lua

I have a problem. I’m making my way into simulations and vectors. I’d like to ask why isn’t my code doing anything, how can I improve it?

[lua]function _R.Vector:Explode( vec )
local time = SysTime()
for k, v in pairs(ents.FindInSphere( self, vec )) do
local pos = v:GetPos()
v:SetVelocity( pos:GetNormal() / self:Distance(pos) )
end
print(tostring(SysTime() - time ))
end[/lua]

You need a direction vector for the SetVelocity. You get a direction vector by subtracting your target position by your start position.
[lua]function _R.Vector:Explode( vec ) local time = SysTime()
for k, v in pairs(ents.FindInSphere( self, vec )) do
local pos = v:GetPos()
local dir = (pos - self:GetPos()):GetNormal()
v:SetVelocity( dir * (500 / self:Distance(pos)) )
end
print(tostring(SysTime() - time ))
end
[/lua]
Try that

Thanks but why did you do self:GetPos() since “self” should be a vector?
Will test the code tomorrow cause it’s 00:20 here an I’m half dead.

Uh, oh, uh, I thought you had an entity, wasn’t even looking at that, I guess you could remove :GetPos() there then.

Yeah, I did already. Thanks again, and as i said, will post results tomorrow.