Mousepressed not working?

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.
xpali2
Prole
Posts: 38
Joined: Thu Apr 05, 2018 4:47 pm

Re: Mousepressed not working?

Post by xpali2 »

pedrosgali wrote: Wed Oct 17, 2018 6:26 pm The main.lua file should look like this:

Code: Select all

local menu = require "menu"

function love.load()
  menu_load()
end

function love.mousepressed(x, y, b)
  menu_mousepressed(x, y, b)
end

function love.update(dt)
  
end

function love.draw()
  menu_draw()
end
Well I'm sure there will be other things in there but that's the minimum you need to get your code working. Once you do your positioning is off :P You're drawing a box 400 wide with the text but checking a box 200 wide for clicks.
I changed this. Thanks for your help.
pedrosgali
Party member
Posts: 107
Joined: Wed Oct 15, 2014 5:00 pm
Location: Yorkshire, England

Re: Mousepressed not working?

Post by pedrosgali »

No problem, next time if you post a .love file like I did it'll be a lot easier to help you as all the code will be there for us to look at.

Code: Select all

if not wearTheseGlasses() then
  chewing_on_trashcan = true
end
xpali2
Prole
Posts: 38
Joined: Thu Apr 05, 2018 4:47 pm

Re: Mousepressed not working?

Post by xpali2 »

pedrosgali wrote: Wed Oct 17, 2018 6:39 pm No problem, next time if you post a .love file like I did it'll be a lot easier to help you as all the code will be there for us to look at.
Forgive my noobiness, how do I change my seperate lua files into a .love file?
pedrosgali
Party member
Posts: 107
Joined: Wed Oct 15, 2014 5:00 pm
Location: Yorkshire, England

Re: Mousepressed not working?

Post by pedrosgali »

just zip them up and rename from .zip to .love

Code: Select all

if not wearTheseGlasses() then
  chewing_on_trashcan = true
end
xpali2
Prole
Posts: 38
Joined: Thu Apr 05, 2018 4:47 pm

Re: Mousepressed not working?

Post by xpali2 »

pedrosgali wrote: Wed Oct 17, 2018 7:02 pm just zip them up and rename from .zip to .love
There it is. A .love file of my project with the directories that it uses. I have tested it on my PC and it works exactly the same as it would in my IDE. So the buttons don't actually seem to print anything.
Attachments
Project.love
(49.59 KiB) Downloaded 132 times
mastermarkus
Prole
Posts: 10
Joined: Sun Jun 25, 2017 5:29 pm

Re: Mousepressed not working?

Post by mastermarkus »

In your main.lua you have "love.mouspressed" it should be "love.mousepressed" you were missing an ("e").
User avatar
pgimeno
Party member
Posts: 3674
Joined: Sun Oct 18, 2015 2:58 pm

Re: Mousepressed not working?

Post by pgimeno »

xpali2 wrote: Wed Oct 17, 2018 6:14 pm I'll tell you it's just as frustrating on my end. If I am not giving you something you think you need to see to solve the issue then ask away, I am not an experienced coder so I can't guess what you need to hear. I have to say that I don't get what you mean with "two mousepressed events" if you could explain. I have checked the console many times by putting a print outside of the basic callbacks in main.lua that print to the console I am viewing: https://ibb.co/f6LEaf. I have tried "LoveMousepressed = love.mousepressed" but nothing changes, no errors or anything. Btw, mousemoved does work, so I reckon the mouse isn't the problem, meaning the mouse module is also not the issue.
It's not about what I need to hear. It's about offering the code for us to look. As pedrosgali has demonstrated, the issue is not in main.lua or in the snippet you have pasted, therefore if you want us to help, we need to look elsewhere. But we can't unless we have enough code to allow us to reproduce the problem.

Edit: It seems you have provided the code and mastermarkus has identified the problem.
xpali2
Prole
Posts: 38
Joined: Thu Apr 05, 2018 4:47 pm

Re: Mousepressed not working?

Post by xpali2 »

mastermarkus wrote: Wed Oct 17, 2018 8:39 pm In your main.lua you have "love.mouspressed" it should be "love.mousepressed" you were missing an ("e").
Ah, I am a real idiot... Thanks and sorry for wasting your time to all.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 7 guests