Help me with buttons please!!

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
Sosolol261
Party member
Posts: 125
Joined: Wed Nov 26, 2014 6:43 am

Help me with buttons please!!

Post by Sosolol261 »

Hello guys (or girls what ever you feminists!!)

I have a little problem in my code...
I have made a file which should make bunch of buttons.
And it does that perfectly well!!! But the real problem is, that some buttons can't be pressed.

To be exact: the 'Show FPS' button in the options, and every button in the pause menu(yes EVERY SINGLE ONE OF THEM).

Since the code is WAY too long, I'll simply put a love file under this post :)
There are no libraries used and the code is commented(more or less) but if you have something to ask, fell free to tell me!!!

Thanks :D

P.S. I hate to do this.. can't even solve a basic bug on my own :cry:
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: Help me with buttons please!!

Post by Kingdaro »

The FPS button issue is due to a logic error in boolean checks, specifically this code under the "option_button_click" function in menu.lua:

Code: Select all

function option_button_click(button)
	-- ...
				if fpsMode then
					if fpsMode then
						fpsMode = false
					else
						fpsMode = true
					end
				end
	-- ...
end
It only toggles fpsMode if fpsMode is already true. The fix is simple:

Code: Select all

function option_button_click(button)
	-- ...
				fpsMode = not fpsMode
	-- ...
end
The pause menu issue is because the "pause_button_click" doesn't accept the button parameter.

Code: Select all

function pause_button_click() -- whoops!
	for i,v in ipairs(pauseBtnDta) do
		if v.float and button == 'l' then
			mainstate = v.ID
		end
	end
end
Sosolol261
Party member
Posts: 125
Joined: Wed Nov 26, 2014 6:43 am

Re: Help me with buttons please!!

Post by Sosolol261 »

Kingdaro wrote: The pause menu issue is because the "pause_button_click" doesn't accept the button parameter.

Code: Select all

function pause_button_click() -- whoops!
	for i,v in ipairs(pauseBtnDta) do
		if v.float and button == 'l' then
			mainstate = v.ID
		end
	end
end
EDIT: Nope just got it... stupid me :(

I am really sorry but what do you mean with "doesn't accept the buttton parameter"
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: Help me with buttons please!!

Post by Kingdaro »

A parameter or more commonly called 'argument' is a variable a function accepts between its parentheses. In this example:

Code: Select all

function foo(a, b, c)
   return a + b - c
end
'a', 'b', and 'c' are all arguments to this function.

So all you'll want to do is edit that line:

Code: Select all

function pause_button_click(button)
Last edited by Kingdaro on Wed Mar 04, 2015 9:09 am, edited 1 time in total.
Sosolol261
Party member
Posts: 125
Joined: Wed Nov 26, 2014 6:43 am

Re: Help me with buttons please!!

Post by Sosolol261 »

Kingdaro wrote:

Code: Select all

function pause_button_click(button)
Yes I got that before your reply but thanks :D
Post Reply

Who is online

Users browsing this forum: Google [Bot], MaxGamz and 5 guests