Xyphien Forums

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Resource icon

MV 1.3 umapi - Event Click API! 1.0

No permission to download
Hi everyone! I'm back with another plugin. This plugin lets you use a parallel process to handle click events on the map or screen.

Instructions:
---PLUGIN COMMANDS---

There are 2 plugin commands.

enableTtm - Enabels touch-to-move

disableTtm - Disables touch-to-move



--- SCRIPT FUNCTIONS ---

This plugin lets you enable or disable the default touch

to move in game, as well as allows you to create events

that detect mouse clicks! If you're making a game with

no playable character for example, you can make pictures

clickable using this API.



Written Guide:

There are several functions you can use. First off,

we'll be creating an event! So, go ahead and make

a blank event somewhere. Make sure to set it's

trigger to parallel. Now, create a "Conditional Branch",

and select the 4th tab to select "Script".



The conditions you can use for this are:

umapi.touch(x, y, width, height) -

this determines if a part of the screen

has been clicked. (Not linked to map location)



umapi.mtouch(x, y, width, height) -

The same as before, but is linked to map

location, so you can use this to have a hotspot

on the map. for example, you can select where

a house is (in pixels, not tiles), and have that

house be clickable.



umapi.gtouch(x, y) -

This will happen when you click or touch a tile

specified by the x/y coords.



---



Useful functions:

You can get an events location

by typing umapi.eventX()/eventY() inside of the condition.

In addition, there's realEventX()/realEventY(), which will

tell the true x/y of the event instead of tile based.

For example, if you wanted to make a taller event

(such as a crystal) clickable, you can use this following

condition in the conditional branch:



-

umapi.mtouch(umapi.realEventX(4), umapi.realEventY(4)-umapi.tileHeight(), umapi.tileWidth(), umapi.tileHeight()*2)

-



4 would be the event id of the crystal graphic. It'd be different for you.

Notice how we subtract the y position by umapi.tileHeight(),

this grabs the height of the tile (even if it's changed by another plugin).

Same goes for umapi.tileWidth();. We also multiply umapi.tileHeight()*2,

meaning the clickable section are 2 tiles thick in height.



---



Additional function List:

umapi.mapX() - gets the X position of the map.

umapi.mapY() - gets the Y position of the map.

umapi.tileWidth() - returns the default tile width.

umapi.tileHeight() - returns the default tile height.

umapi.eventX(id) - gets the X tile of the event specified

umapi.eventY(id) - gets the Y tile of the event specified

umapi.realEventX(id) - gets the real x position of the event specified.

umapi.realEventY(id) - gets the real y position of the event specified.

umapi.block() - Stops the ability to touch-to-move on the map.

umapi.restore() - Re-enables the ability to touch-to-move on the map.



Using block/restore should be done via the event command "script",

optionally, there are plugin commands you can use as well.
Example event:
Code:
◆Comment:Disable movement when click/touched
◆Plugin Command:disableTtm
◆Comment:Random click region on map
◆If:Script:umapi.mtouch(umapi.realEventX(2), umapi.realEventY(2), umapi.tileWidth(), umapi.tileHeight())
  ◆Show Animation:EV002, Cure One 1 (Wait)
  ◆
:End
◆Comment:Person click
◆If:Script:umapi.mtouch(umapi.realEventX(3), umapi.realEventY(3), umapi.tileWidth(), umapi.tileHeight())
  ◆Set Movement Route:EV003 (Wait)
  :                  :◇Turn at Random
  :                  :◇Jump:+0, +0
  :                  :◇SE:Jump1 (90, 100, 0)
  ◆
:End
◆Comment:crystal click
◆If:Script:umapi.mtouch(umapi.realEventX(4), umapi.realEventY(4)-umapi.tileHeight(), umapi.tileWidth(), umapi.tileHeight()*2)
  ◆Open Save Screen
  ◆
:End
on this map setup:
upload_2017-4-28_22-1-29.png
Author
TheUnproPro
Downloads
238
Views
593
First release
Last update
Rating
5.00 star(s) 1 ratings

More resources from TheUnproPro

Latest reviews

This is incredibly helpful and opens up a ton of functionality. It is not quite plug and play but is certainly not hard to use.

A note for new users if you get a nodejs error there is a good chance you missed a parenthesis. Cheers!
Top