isaias20

Regular
Regular
Joined
Aug 21, 2021
Messages
38
Reaction score
12
First Language
english
Primarily Uses
RMVXA
hello i am trying to save mouse position in variables x,y and then assign it to a variables in game but i get this error.

JavaScript:
 TouchInput._onMouseMove = function(event)
{
        var x = Graphics.pageToCanvasX(event.pageX);
        var y = Graphics.pageToCanvasY(event.pageY);
        $gameVariables.SetValue(10,x);
        $gameVariables.SetValue(11,y);
 };

10 and 11 are the variables in the game.

error.png


any solution?
 

ct_bolt

Creator
Regular
Joined
May 3, 2012
Messages
1,367
Reaction score
990
First Language
Javascript
Primarily Uses
RMMZ
hello i am trying to save mouse position in variables x,y and then assign it to a variables in game but i get this error.

JavaScript:
 TouchInput._onMouseMove = function(event)
{
        var x = Graphics.pageToCanvasX(event.pageX);
        var y = Graphics.pageToCanvasY(event.pageY);
        $gameVariables.SetValue(10,x);
        $gameVariables.SetValue(11,y);
 };

10 and 11 are the variables in the game.

error.png


any solution?
A couple things...

Because your modifying a core file, the "_onmouseMove" function/event occurs before $gameVariables is ever declared ...so the easiest fix was just to simply add an if statement to check whether $gameVariables exists before trying to set a value to a game variable

the second issue would be the capital 'S' on the "setValue" function of $gameVariables it is a lowercase 's'

Made a plugin for you though :)
Should do exactly as you need :)
1651623321082.png
Seems to work perfectly with the little bit of testing I just did.

Hope that helps.
 
Last edited:

isaias20

Regular
Regular
Joined
Aug 21, 2021
Messages
38
Reaction score
12
First Language
english
Primarily Uses
RMVXA
A couple things...

Because your modifying a core file, the mouseMove event occurs before $gameVariables is ever declared and then the second issue would be the capital 'S' on the "setValue" function of $gameVariables. It is a lowercase

Made a plugin for you though :)
Should do exactly as you need :)

I already solved it, the s of setValue should be lowercase haha, how silly.
 

isaias20

Regular
Regular
Joined
Aug 21, 2021
Messages
38
Reaction score
12
First Language
english
Primarily Uses
RMVXA
I already solved it, the s of setValue should be lowercase haha, how silly.

thanks, I want to use those variables to move an object with the mouse from one tile to another but it doesn't work for me because the script assigns values to the mouse outside the map (when the map is very small).

How do I assign values to the mouse that are inside the map? not game window but the map in the game.
 

isaias20

Regular
Regular
Joined
Aug 21, 2021
Messages
38
Reaction score
12
First Language
english
Primarily Uses
RMVXA
that is, I must convert pixels to tiles, how do I do that?
 

ct_bolt

Creator
Regular
Joined
May 3, 2012
Messages
1,367
Reaction score
990
First Language
Javascript
Primarily Uses
RMMZ
thanks, I want to use those variables to move an object with the mouse from one tile to another but it doesn't work for me because the script assigns values to the mouse outside the map (when the map is very small).

How do I assign values to the mouse that are inside the map? not game window but the map in the game.
Made an update to allow you to only choose to store to variables on maps/specific maps via notetags

1651626723887.png

If using the map note tag feature it would be setup like this:
1651626925476.png
<Touch_To_Variables:true>

that is, I must convert pixels to tiles, how do I do that?

@isaias20
That would be like this
JavaScript:
$gameMap.canvasToMapX($gameVariables.value(10))
$gameMap.canvasToMapY($gameVariables.value(11))

that works perfectly :)
 
Last edited:

isaias20

Regular
Regular
Joined
Aug 21, 2021
Messages
38
Reaction score
12
First Language
english
Primarily Uses
RMVXA
Made an update to allow you to only choose to store to variables on maps/specific maps via notetags

View attachment 225047

If using the map note tag feature it would be setup like this:
View attachment 225048
<Touch_To_Variables:true>



@isaias20
That would be like this
JavaScript:
$gameMap.canvasToMapX($gameVariables.value(10))
$gameMap.canvasToMapY($gameVariables.value(11))

that works perfectly :)


In which line of the plugin should I place those two lines?
 

isaias20

Regular
Regular
Joined
Aug 21, 2021
Messages
38
Reaction score
12
First Language
english
Primarily Uses
RMVXA
Another update for ya ;)
View attachment 225049


Should work exactly as needed :cutesmile:


works perfect, thanks.

Now I am trying to move an event with mouse by placing these options on page 2 in parallel processing.

move item.png

But the event passes through other events and walls. Is there a way to move the event so that it collides with the other events? I don't want it through the wall either.

Thank you.
 
Last edited:

ct_bolt

Creator
Regular
Joined
May 3, 2012
Messages
1,367
Reaction score
990
First Language
Javascript
Primarily Uses
RMMZ
works perfect, thanks.
Wooo no prob. Glad to hear it's working as needed. :cutesmile:

Now I am trying to move an event with mouse by placing these options on page 2 in parallel processing.

View attachment 225050

But the event passes through other events and walls. Is there a way to move the event so that it collides with the other events? I don't want it through the wall either.

Thank you.
You can do something like this...
1651629059275.png

That will make it so the event will not move to any place that is an obstacle.

...for border walls since they aren't marked as non passable.. I had to use a region ID
in the example I chose to use region ID #5

...soo the setup for that was like this:
1651629076169.png
& this is the conditional script code used:
JavaScript:
$gameMap.isPassable($gameVariables.value(10),$gameVariables.value(11)) && $gameMap.regionId($gameVariables.value(10),$gameVariables.value(11)) !== 5

Here's what that looks like in-game:
 
Last edited:

isaias20

Regular
Regular
Joined
Aug 21, 2021
Messages
38
Reaction score
12
First Language
english
Primarily Uses
RMVXA
Wooo no prob. Glad to hear it's working as needed. :cutesmile:


You can do something like this...
Though I'm not certain that will still give you the exact result your hoping for
but it will not move the event to any place that is an obstacle.

...for border walls since they aren't marked as non passable.. I had to use a region ID
in the example I chose to use region ID #5

...soo the setup for that was like this:
& this is the conditional script code used:
JavaScript:
$gameMap.isPassable($gameVariables.value(10),$gameVariables.value(11)) && $gameMap.regionId($gameVariables.value(10),$gameVariables.value(11)) !== 5

Here's what that looks like in-game:


Maybe that's at least somewhat helpful?


works perfect, thank you very much!
 

DarkFenix

Regular
Regular
Joined
Dec 3, 2018
Messages
82
Reaction score
21
First Language
Portuguese
Primarily Uses
RMMZ
Hello, is there a way to do this in mz?
 

Latest Threads

Latest Posts

Latest Profile Posts

1701891367101.png
it continues in baby steps xD
want to optimize the new cover completely, before I rework the rest of the game^^
Knight Name.gif
Any guess as to this brave knight's name?
I am new to rpg maker mz and currently working on a project currently under the name Neo fantasy
Watch out all you musicky people out there! I was able to find and add 4...count them...4 music pieces for the beginning of my game. I am feeling positively Mozarty at the moment. NO RTP background music for my Game Jam entry! Mwah ha ha! MUZAK!

Forum statistics

Threads
136,791
Messages
1,269,998
Members
180,544
Latest member
neurosith
Top