[B]Problem[/B]
This function seems to turn the vector into nil.
[B]How to reproduce:[/B]
[i]print(Vector(4,3,2):Normalize())[/i] //Should print "0.7428 0.5571 0.3714." but doesn't print anything.
or
[i]print(Vector(4,3,2):Normalize().."lol")[/i] //Errors: attempt to concatenate a nil value
Normalize doesn't return anything, it normalizes the vector
He's looking for GetNormal.
[QUOTE=garry;38170795]Normalize doesn't return anything, it normalizes the vector[/QUOTE]
I thought that print(v:Normalize()) would print it after it got normalized, but now that you say it this makes more sense.
My bad :)
I was porting code to gmod13 and suddenly the normalize construction that had always been working errored out, and with the small test up there I figured it was broken.
[QUOTE=COBRAa;38171628]He's looking for GetNormal.[/QUOTE]
Thanks!
This thread can be locked.
Why not make Normalize work like setmetatable or ffi.gc where it returns the object you use it on as well as normalizing it? Then we could still use it in most equations without splitting it into different statements.
or you can just do
local a = Vector(2,2,2)
a:Normalize()
print(a)
Normalize is a function to improve your script performance wise, it would be dumb if it yielded another vector, we have GetNormal() for that.
Sorry, you need to Log In to post a reply to this thread.