Page 1 of 2

Goo misunderstating

Posted: Sat Aug 13, 2011 9:48 am
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)

Re: Goo misunderstating

Posted: Sat Aug 13, 2011 9:59 am
by T-Bone
Goo buttons?

Re: Goo misunderstating

Posted: Sat Aug 13, 2011 10:01 am
by NeoTheFox

Re: Goo misunderstating

Posted: Sat Aug 13, 2011 10:14 am
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.

Re: Goo misunderstating

Posted: Sat Aug 13, 2011 10:37 am
by NeoTheFox
Here you go :3

Re: Goo misunderstating

Posted: Sat Aug 13, 2011 11:22 am
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.

Re: Goo misunderstating

Posted: Sat Aug 13, 2011 11:23 am
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?

Re: Goo misunderstating

Posted: Sat Aug 13, 2011 12:10 pm
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 1669 times

Re: Goo misunderstating

Posted: Sat Aug 13, 2011 12:29 pm
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.

Re: Goo misunderstating

Posted: Sat Aug 13, 2011 12:35 pm
by NeoTheFox
At line 56 it does absolutely nothing, but the game starts normally :cry: