Status
Not open for further replies.

Wittlog

Villager
Member
Joined
Jan 22, 2017
Messages
10
Reaction score
2
First Language
English
Primarily Uses
RMMV
What I'm looking for is a way to store the X position of the mouse cursor to one variable and the Y position of the mouse cursor to another. Not the coordinates of where the mouse has clicked, just the coordinates of where the cursor currently is.

I've seen this question asked like a million times before with slight variations and tried scouring through all of those threads for a working solution, but I personally have never found anything that has even begun to function for me in any of them. Any help would be appreciated because at this rate it's driving me nuts how hard it has been to find a way to do this!
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
3,123
Reaction score
2,394
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi there!
See if this little snippet will help you.
Open the file with any text editor and:
  • Replace IDX with the variable ID you will store the X coordinate.
  • Replace IDY with the variable ID you will store the Y coordinate.
 

Attachments

  • mouseCoords.js
    300 bytes · Views: 63

Wittlog

Villager
Member
Joined
Jan 22, 2017
Messages
10
Reaction score
2
First Language
English
Primarily Uses
RMMV
Oh my god that worked like a charm! Thank you @Eliaquim, you're a life saver!
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
45,064
Reaction score
16,090
First Language
English
Primarily Uses
RMMV
Note, the above will give you the mouse coordinates in pixels relative to the top left of the screen. So the top left will be 0,0 and the bottom right will be 768,512 if that is your window size.

If you wanted the actual map coordinates, more would be required.
 

Wittlog

Villager
Member
Joined
Jan 22, 2017
Messages
10
Reaction score
2
First Language
English
Primarily Uses
RMMV
I'm fine with having the mouse position in pixels, but if I ever need to change it over to tiles I feel like I could make something work with this.
 

darklugia1997

Veteran
Veteran
Joined
Dec 3, 2018
Messages
65
Reaction score
15
First Language
Portuguese
Primarily Uses
RMMZ
Hi there!
See if this little snippet will help you.
Open the file with any text editor and:
  • Replace IDX with the variable ID you will store the X coordinate.
  • Replace IDY with the variable ID you will store the Y coordinate.

Hello Eliaquim, I'm using this plugin in my rpg maker mz project, it's working, but when I start the game test and move the mouse across the screen it gives me the following error: "Uncaught TypeError: Cannot read property 'setValue' of null ".

Screenshot_5.pngScreenshot_4.png

But if I start moving the mouse on the title screen or inside the game this error does not appear, only when I move when I start the playtest even in the first seconds that the screen opens, Do you have a solution to solve this 'small' problem? I really don't know how.
Screenshot_6.png
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
3,123
Reaction score
2,394
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hello Eliaquim, I'm using this plugin in my rpg maker mz project, it's working, but when I start the game test and move the mouse across the screen it gives me the following error: "Uncaught TypeError: Cannot read property 'setValue' of null ".

View attachment 246497View attachment 246496

But if I start moving the mouse on the title screen or inside the game this error does not appear, only when I move when I start the playtest even in the first seconds that the screen opens, Do you have a solution to solve this 'small' problem? I really don't know how.
View attachment 246499
Hi there!
I guess it's because the $gameVariables are not created yet.
On line 5, insert the following:
if($gameVariables){
// Put here the two lines of game variables(Line 5 and line 6).
}
 

darklugia1997

Veteran
Veteran
Joined
Dec 3, 2018
Messages
65
Reaction score
15
First Language
Portuguese
Primarily Uses
RMMZ
Hi there!
I guess it's because the $gameVariables are not created yet.
On line 5, insert the following:
if($gameVariables){
// Put here the two lines of game variables(Line 5 and line 6).
}
It worked perfectly, thank you :D
 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Now that I have linklists on large trees and cars, is there any theme that would interest you?
Debugging multiplayer issues... I'm having fun, right?
yay_streaming.jpg

For just starting streaming on the 10th... Definitely not the worst. :LZScheeze:

Granted I need 333.34 hours a month on average to achieve money. So I don't really expect that, but it sure has helped my game dev go much faster.
Proud on how this map turned out.

FnmhDLIXgAAOvIC
I just finally fixed a huge problem that wouldn’t let my game load and would crash it.. I thought that I was gonna have to trash the project and start over lol

Forum statistics

Threads
128,329
Messages
1,193,665
Members
168,817
Latest member
Clust3rPepis
Top