Attempt to call a number... [Solved]

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
User avatar
Person
Prole
Posts: 39
Joined: Thu Jun 18, 2009 2:35 am

Attempt to call a number... [Solved]

Post by Person »

So, I was chugging along, coding my project. I have a bad habit of coding huge amounts and then deciding to check to see if it works. So I wrote 2 huge functions and a little one all without checking to see if they work and what do you know, I can't get the biggest one to work for the life of me. It keeps telling me that I'm attempting to call a number on line 43, which means (according to my internet searching) that lua expected a function and got a number instead. So what's the deal? The entire line looks like this:

Code: Select all

ua_num	= ((l_x2 - l_x1)(a_y1 - l_y1)) - ((l_y2 - l_y1)(a_x1 - l_x1))	-- The  numerator and denomenator are calculated seperately
So I don't see any problem, all the variables in question were set before the call, so I'm very confused...
I uploaded the whole code for your guys to check if you feel like it. Please halp? :brows:
Last edited by Person on Thu Aug 26, 2010 6:39 pm, edited 1 time in total.
"Here's another curse for you, may all your bacon burn."
User avatar
knorke
Party member
Posts: 239
Joined: Wed Jul 14, 2010 7:06 pm
Contact:

Re: Attempt to call a number...

Post by knorke »

missing multiplication signs?
ua_num = ((l_x2 - l_x1) * (a_y1 - l_y1)) - ((l_y2 - l_y1) * (a_x1 - l_x1))
User avatar
Person
Prole
Posts: 39
Joined: Thu Jun 18, 2009 2:35 am

Re: Attempt to call a number...

Post by Person »

:shock:
your kidding?
*revises code*
*facedesk* I feel very stupid right now... I thought that the brackets implied multiplication, my bad!
"Here's another curse for you, may all your bacon burn."
User avatar
Luiji
Party member
Posts: 396
Joined: Mon May 17, 2010 6:59 pm

Re: Attempt to call a number... [Solved]

Post by Luiji »

Sadly the mathematical idea that the brackets imply multiplication is rarely implemented by programming languages. Interestingly, Lua, unlike most programming languages, is resolved the syntax as a function call as supposed to raising syntax errors.
Good bye.
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Attempt to call a number... [Solved]

Post by thelinx »

I bet you could do some metatable magic to make it multiply stuff in cases like this.
User avatar
Luiji
Party member
Posts: 396
Joined: Mon May 17, 2010 6:59 pm

Re: Attempt to call a number... [Solved]

Post by Luiji »

Mmm...metatables...
Good bye.
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Attempt to call a number... [Solved]

Post by thelinx »

A quick visit to #lua later...
21:17 < krka> debug.setmetatable(0, {__call = function(x, y) return x * y end})
21:17 < krka> return (5)(6+7)
21:17 < krka> --> 65
21:18 < thelinx> heh, awesome
21:18 < krka> return 5(6+7) is a syntax error however
Post Reply

Who is online

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