## Goo misunderstating

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.
NeoTheFox
Prole
Posts: 5
Joined: Sat Aug 13, 2011 8:15 am

### Goo misunderstating

Hi, I started making my game like a few weeks ago. I am having problems with goo buttons - I cant call onClick function, every time I tried external function I am having an "Attempt to index global 'button' (a nill value), and if I placing this function in my mainMenu() function, there all the buttons are creating it just don't work Help plz!
(and sorry if my english forces you to facepalm)

T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

### Re: Goo misunderstating

Goo buttons?

NeoTheFox
Prole
Posts: 5
Joined: Sat Aug 13, 2011 8:15 am

### Re: Goo misunderstating

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Goo misunderstating

Like the Rules say: could you upload a .love of your project to the forum? Otherwise it will be hard or even impossible to help you.
Help us help you: attach a .love.

NeoTheFox
Prole
Posts: 5
Joined: Sat Aug 13, 2011 8:15 am

### Re: Goo misunderstating

Here you go
Attachments
game.love

T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

### Re: Goo misunderstating

You don't seem to call goo.mousepressed()... I've never used goo but I guess you should add like

Code: Select all

function love.mousepressed(x,y,button)
goo:mousepressed(x,y,button)
end
or something.

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Goo misunderstating

Thanks.

Hm, I can't reproduce the error you're getting. Could you say exactly what you do to get the error? And are you sure this is the exact same version that errors?
Help us help you: attach a .love.

NeoTheFox
Prole
Posts: 5
Joined: Sat Aug 13, 2011 8:15 am

### Re: Goo misunderstating

I want buttons to do something, so i am adding

Code: Select all

function exbutton:onClick(x, y, button)
love.event.push("q")
end

to the bottom and TA DA - error
Am i doing it wrong? Because if i adding this function at the mainMenu it just does nothing
Снимок.PNG (288.96 KiB) Viewed 1582 times

thelinx
The Strongest
Posts: 848
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

### Re: Goo misunderstating

That function is defined in the global scope, which means Lua tries to create it before love.load has been run.
At this point, exbutton has not been created yet, and trying to create a new value in a table that doesn't exist results in an error.

Try moving function exbutton:onclick ... end to line 56.

NeoTheFox
Prole
Posts: 5
Joined: Sat Aug 13, 2011 8:15 am

### Re: Goo misunderstating

At line 56 it does absolutely nothing, but the game starts normally

### Who is online

Users browsing this forum: No registered users and 85 guests