main.lua:7: attempt to perform arithmetic on field 'getWidth' (a function value)

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
dawdejw
Prole
Posts: 4
Joined: Sat Nov 04, 2017 9:39 pm

main.lua:7: attempt to perform arithmetic on field 'getWidth' (a function value)

Post by dawdejw »

So, when i was making a game (well, a program anyway), this lovely message popped up:

Code: Select all

main.lua:7: attempt to perform arithmetic on field 'getWidth' (a function value)
This, is the line in question:

Code: Select all

scale = love.graphics.getWidth / 320
I don't know, am I dumb or what, but I couldn't find more about this error, so I'm asking - what the heck is wrong with this line? All I want to do is a simple division - to divide window width by 320, and I can't see anything wrong with that line. Also, I don't know should I post .love or not, but I'll include it anyway.
Attachments
imagesomething.love
(127.62 KiB) Downloaded 125 times
User avatar
Ulydev
Party member
Posts: 445
Joined: Mon Nov 10, 2014 10:46 pm
Location: Paris
Contact:

Re: main.lua:7: attempt to perform arithmetic on field 'getWidth' (a function value)

Post by Ulydev »

dawdejw wrote: Mon Jan 29, 2018 3:47 pm So, when i was making a game (well, a program anyway), this lovely message popped up:

Code: Select all

main.lua:7: attempt to perform arithmetic on field 'getWidth' (a function value)
This, is the line in question:

Code: Select all

scale = love.graphics.getWidth / 320
I don't know, am I dumb or what, but I couldn't find more about this error, so I'm asking - what the heck is wrong with this line? All I want to do is a simple division - to divide window width by 320, and I can't see anything wrong with that line. Also, I don't know should I post .love or not, but I'll include it anyway.
love.graphics.getWidth is a function. You need to call it to retrieve a value.

Code: Select all

love.graphics.getWidth()
dawdejw
Prole
Posts: 4
Joined: Sat Nov 04, 2017 9:39 pm

Re: main.lua:7: attempt to perform arithmetic on field 'getWidth' (a function value)

Post by dawdejw »

Ulydev wrote: Mon Jan 29, 2018 3:50 pm
dawdejw wrote: Mon Jan 29, 2018 3:47 pm So, when i was making a game (well, a program anyway), this lovely message popped up:

Code: Select all

main.lua:7: attempt to perform arithmetic on field 'getWidth' (a function value)
This, is the line in question:

Code: Select all

scale = love.graphics.getWidth / 320
I don't know, am I dumb or what, but I couldn't find more about this error, so I'm asking - what the heck is wrong with this line? All I want to do is a simple division - to divide window width by 320, and I can't see anything wrong with that line. Also, I don't know should I post .love or not, but I'll include it anyway.
love.graphics.getWidth is a function. You need to call it to retrieve a value.

Code: Select all

love.graphics.getWidth()
OHH, I see, Thank you very much, I didn't know it makes a diffrence!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest