bad argument #1 to 'cos' (number expected, got nil)

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
manolo0185
Prole
Posts: 2
Joined: Thu Nov 01, 2018 9:14 pm

bad argument #1 to 'cos' (number expected, got nil)

Post by manolo0185 »

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:

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'
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?
Attachments
Physics.love
(111.8 KiB) Downloaded 147 times
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: bad argument #1 to 'cos' (number expected, got nil)

Post by veethree »

Line 81 in main.lua is

Code: Select all

Force.rotate(Angle)
but should be

Code: Select all

Force:rotate(Angle)
manolo0185
Prole
Posts: 2
Joined: Thu Nov 01, 2018 9:14 pm

Re: bad argument #1 to 'cos' (number expected, got nil)

Post by manolo0185 »

Oops! I fell in once again!
Thanks!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 3 guests