Browse files

Merge pull request #175 from natrim/patch-4

E2: toAngle can now have optional parameter vector
  • Loading branch information...
2 parents 52de415 + 6e3d726 commit cbf418309fc188e09ed97823756768b08b445b67 @Nebual Nebual committed Dec 7, 2012
Showing with 7 additions and 0 deletions.
  1. +7 −0 lua/entities/gmod_wire_expression2/core/vector.lua
View
7 lua/entities/gmod_wire_expression2/core/vector.lua
@@ -658,6 +658,13 @@ registerFunction("toAngle", "v:", "a", function(self, args)
return { angle.p, angle.y, angle.r }
end)
+registerFunction("toAngle", "v:v", "a", function(self, args)
+ local op1, op2 = args[2], args[3]
+ local rv1, rv2 = op1[1](self, op1), op2[1](self, op2)
+ local angle = Vector(rv1[1], rv1[2], rv1[3]):AngleEx(Vector(rv2[1], rv2[2], rv2[3]))
+ return { angle.p, angle.y, angle.r }
+end)
+
/******************************************************************************/
local contents = {}

7 comments on commit cbf4183

@Divran

What does this function do?

EDIT: Nevermind, found this "which it uses as the 'up' for the returned angle" ( #175 )

@TomyLobo

better question: why are you not using e2function?

@natrim

almost all of that file uses registerFunction, so i just followed it

and i think e2function does not allow function overriding

@Divran

Doesn't really matter which one you use. In fact, registerFunction is slightly faster because you're retrieving the values manually instead of it using unpack.

and i think e2function does not allow function overriding

It's not overriding if the arguments are different.

@TomyLobo

do you really think this matters with luajit? i'd bet it optimizes that out

@TomyLobo

actually, extpp doesnt emit unpack unless you use ellipses(...)

@Divran

Oh ok. And no it wouldn't have mattered either way.

Please sign in to comment.