bad argument #1 to 'cos' (number expected, got nil)
Posted: Thu Nov 01, 2018 9:39 pm
Hello all.
Call me stupid, but I now simplified my failure condition to a point where I cant understand the problem at all. You're my last help with this physics test project!
If I run the attached love file, I get the following printout:
if I place a print(Angle) before the rotate() function call inside main.lua, Angle contains 0, which is as expected.
A print(phi) inside the rotate function within vec2.lua prints "nil".
How can that be? is the argument not passed for some reason?
What did I do wrong?
Call me stupid, but I now simplified my failure condition to a point where I cant understand the problem at all. You're my last help with this physics test project!
If I run the attached love file, I get the following printout:
Code: Select all
main.lua:81 Angle = 0
vec2.lua:96 phi =
nil
Error: vec2.lua:98: bad argument #1 to 'cos' (number expected, got nil)
stack traceback:
[string "boot.lua"]:637: in function <[string "boot.lua"]:633>
[C]: in function 'cos'
vec2.lua:98: in function 'rotate'
main.lua:81: in function 'update'
[string "boot.lua"]:509: in function <[string "boot.lua"]:493>
[C]: in function 'xpcall'
A print(phi) inside the rotate function within vec2.lua prints "nil".
How can that be? is the argument not passed for some reason?
What did I do wrong?