[RM2K3] DYNRPG MOUSE PLUGIN
Posts
Pages:
1
I already downloaded Cherry's Mouse and Keyboard DynRPG plugin, and I do know how to use it except for the "mouse clicking on events" thing.
In other words, I don't understand how to make the mouse able to click on events and activate their event scripts with this plugin. Can anyone help me please?
In other words, I don't understand how to make the mouse able to click on events and activate their event scripts with this plugin. Can anyone help me please?
Because I saw nobody answered here, I will answer anyway, even though I told you in the DM that I don't want to teach basic event scripting. Because the problem is that you asked the wrong question. I guess what you really should ask is not "How do I detect a click on an event using DynRPG's mouse plugin", because this will only be looked at by people who know the plugin, but instead "How do I determine if coordinates are within an event's boundaries" and maybe "How do I determine whether a switch's value changed".
Again, hints from my end:
- To determine whether a switch changed (which is the way to determine whether the left mouse button changed from the OFF to the ON state) is by saving the old value, and every time you check the button, compare the old to the new value. In this specific case, it should be enough to check whether the old value was OFF and the new value is ON, before setting the old to the new value. This way, you know that the mouse button was just pressed down.
- To determine whether coordinates are within an event's boundaries, you first have to get the screen position of the event (using Change Variable -> Event). The coordinates returned by this command (X and Y) are specifying the position of the a specific pixel, which is vertically the first pixel below the event's tile and horizontally the right middle one of the tile (there are two middle ones because the width is even).
It's the one marked in red here, assuming that the stairs represent the tile the event is standing on:

Then the question is how big the area of interest is which you want to check. Remember that tiles occupy 16x16 pixels, but events can occupy up to 24x32 pixels. Let's call the mouse coordinates mouseX and mouseY, and the event coordinates (middle bottom) eventX and eventY. Let's assume for now that you are only interested in a tile sized area, then you would have check whether mouseX >= eventX - 8 and mouseX < eventX + 8 and also whether mouseY >= eventY - 16 and mouseY < eventY. If you were interested in the full 24x32 area, it would be - 12, + 12 and - 32 respectively.
As for how to activate the event script: Just call them using "Call Event".
EDIT: I just realized that maybe what you want is some kind of universal script which calls whatever event the user clicks on? Because the right way to do this would be:
Find out what the tile coordinates of the mouse click are. That's a bit tricky since you would have to add the camera position to the mouse position and then divide it by 16, and there is no straight-forward built-in way to get the camera position. What you can do instead is putting a dummy event on a tile, let's say the upper-left one, and checking its screen coordinates. As explained before, you will get the position of the "red pixel" and in this case, because you know the event is in the upper-left corner, you just have to subtract 8 from X and 16 from Y and you'll have the camera position.
Now that you have the camera position, you can continue as I said before: Add the mouse coordinates and then divide everything by 16. Then you'll have the coordinates of the tile the mouse is currently hovering over. You can then use the "Get Event ID" command to get the ID of the event under the mouse cursor (or 0 if there is none), and then you can use "Call Event" to call the event (provided it's not 0).
Again, hints from my end:
- To determine whether a switch changed (which is the way to determine whether the left mouse button changed from the OFF to the ON state) is by saving the old value, and every time you check the button, compare the old to the new value. In this specific case, it should be enough to check whether the old value was OFF and the new value is ON, before setting the old to the new value. This way, you know that the mouse button was just pressed down.
- To determine whether coordinates are within an event's boundaries, you first have to get the screen position of the event (using Change Variable -> Event). The coordinates returned by this command (X and Y) are specifying the position of the a specific pixel, which is vertically the first pixel below the event's tile and horizontally the right middle one of the tile (there are two middle ones because the width is even).
It's the one marked in red here, assuming that the stairs represent the tile the event is standing on:

Then the question is how big the area of interest is which you want to check. Remember that tiles occupy 16x16 pixels, but events can occupy up to 24x32 pixels. Let's call the mouse coordinates mouseX and mouseY, and the event coordinates (middle bottom) eventX and eventY. Let's assume for now that you are only interested in a tile sized area, then you would have check whether mouseX >= eventX - 8 and mouseX < eventX + 8 and also whether mouseY >= eventY - 16 and mouseY < eventY. If you were interested in the full 24x32 area, it would be - 12, + 12 and - 32 respectively.
As for how to activate the event script: Just call them using "Call Event".
EDIT: I just realized that maybe what you want is some kind of universal script which calls whatever event the user clicks on? Because the right way to do this would be:
Find out what the tile coordinates of the mouse click are. That's a bit tricky since you would have to add the camera position to the mouse position and then divide it by 16, and there is no straight-forward built-in way to get the camera position. What you can do instead is putting a dummy event on a tile, let's say the upper-left one, and checking its screen coordinates. As explained before, you will get the position of the "red pixel" and in this case, because you know the event is in the upper-left corner, you just have to subtract 8 from X and 16 from Y and you'll have the camera position.
Now that you have the camera position, you can continue as I said before: Add the mouse coordinates and then divide everything by 16. Then you'll have the coordinates of the tile the mouse is currently hovering over. You can then use the "Get Event ID" command to get the ID of the event under the mouse cursor (or 0 if there is none), and then you can use "Call Event" to call the event (provided it's not 0).
Pages:
1














