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

Post by NeoTheFox »

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)
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Goo misunderstating

Post by T-Bone »

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

Re: Goo misunderstating

Post by NeoTheFox »

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

Re: Goo misunderstating

Post by Robin »

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

Post by NeoTheFox »

Here you go :3
Attachments
game.love
(3.42 MiB) Downloaded 171 times
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Goo misunderstating

Post by T-Bone »

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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Goo misunderstating

Post by Robin »

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

Post by NeoTheFox »

Thanks for replying :awesome:

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 :roll:
Снимок.PNG
Снимок.PNG (288.96 KiB) Viewed 4757 times
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Goo misunderstating

Post by thelinx »

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

Post by NeoTheFox »

At line 56 it does absolutely nothing, but the game starts normally :cry:
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests