Store mouse coordinate XY in variables [Solved]

Hello there i'm trying to store in 2 varabiles the XY mouse coordinate, something like that, but i receive result as Zero, they are the wrong variable?

Spoiler
screen.jpg
Also, how can i identify the "Mouse Press" button?
I need that in order to define some clickable areas, like a menù in pictures.
Best.

EDIT: Ok it Works!
It's case sensitive, so the X and Y must be x y no Uppercase.
How can i define IF CLICK?
I see you found out it's case sensitive, nicely done 🙂

For checking if the player has clicked, you'll probably want to try TouchInput.isTriggered(), which will return true if the mouse was just pressed down, or a touch screen was just pressed. This only is true once per time, so click and holding the mouse button will only return true once.

To see if the player is holding the mouse down, or their finger on a touch screen, use TouchInput.isPressed().

Please note that in both cases, you will need to check the mouse position to see specifically where it was pressed, as this only returns true or false, not the position it was pressed.
I see you found out it's case sensitive, nicely done 🙂

For checking if the player has clicked, you'll probably want to try TouchInput.isTriggered(), which will return true if the mouse was just pressed down, or a touch screen was just pressed. This only is true once per time, so click and holding the mouse button will only return true once.

To see if the player is holding the mouse down, or their finger on a touch screen, use TouchInput.isPressed().

Please note that in both cases, you will need to check the mouse position to see specifically where it was pressed, as this only returns true or false, not the position it was pressed.
Perfect it works!!!

If anyonw need is like this

Spoiler
screen3.jpg
Best

Lakaroth
Thanks Lakaroth for asking this because I had a similar issue.

I'm trying to build a custom menu, and I want to make some portions of the screen trigger an event while the mouse is there.

For that I'm now using the mouse coordinates thanks to you.

But I have one problem.

If I click on the desired area the event is triggered, but I want it to activate while hovering the mouse on that area

The problem is that the coordinates of the variable are only updated when the mouse is clicked

So, the question is: How do I make the variables update without the need of the mouse click, or else how do I create a conditional branch that triggers when the mouse hovers over an area of the screen?

PD: Sorry to ask this here, but I think you have this answer.
Thanks Lakaroth for asking this because I had a similar issue.

I'm trying to build a custom menu, and I want to make some portions of the screen trigger an event while the mouse is there.

For that I'm now using the mouse coordinates thanks to you.

But I have one problem.

If I click on the desired area the event is triggered, but I want it to activate while hovering the mouse on that area

The problem is that the coordinates of the variable are only updated when the mouse is clicked

So, the question is: How do I make the variables update without the need of the mouse click, or else how do I create a conditional branch that triggers when the mouse hovers over an area of the screen?

PD: Sorry to ask this here, but I think you have this answer.
 Humm... i see, this is really out of my range i'm not a Javascript programmer, but i want let you think about this:

Are you planning for a mobile version too?

Because even if you find a way to updates mouse position coordinates, this work on PC or Web etc etc

BUT think a mobile game, you don't have the cursor so how can you do that?

I don't know if u'r planning for a commercial game, in that case you need to realize how many "clients" you can lost without a mobile porting.

Anyway, i think there ust be a way to update mouse cordinates maybe with mouse system ex i tryi some variable but dont work, ask to the guy who made the plugin!

Best!
this method stores pixel coordinates, how do you store grid coordinates??
Necro-post notice: Member
In addition this is a different query. Please post a new thread.

Original thread: https://forums.rpgmakerweb.com/threads/store-mouse-coordinate-xy-in-variables-solved.46956/