Movement by input blocker

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,062
Reaction score
10,363
First Language
Czech
Primarily Uses
RMMV
Introduction
This plugin does what it says, blocks movement by input. No mouse movement, no arrow movement, no joypad movement... All it requires is a single switch.
Simply choose a switch through parameters and as long as it's off, the player can move. As long as it's on, the player can't move at all.

Download the plugin here
https://raw.githubusercontent.com/Poryg1/RPG-maker-MV-plugins/master/POR_InputBlock.js

License
This plugin is shared under MIT License. That means:
Free for commercial/non-commercial games
Free to edit
Free to share & repost, but not free to claim as your own work!

Credit would be nice, but is not required.
 

cji3bp62000

Tsukimi
Veteran
Joined
Oct 25, 2017
Messages
66
Reaction score
181
First Language
Japanese
Primarily Uses
RMMV
Great plugin!
When creating a small game(with clickable picture) by Parallel Process, I don't want player to move, and this is what I need!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,138
Reaction score
12,413
First Language
English
Primarily Uses
RMMV
Based on what I saw when I played with this, I expect I wouldn't be able to use $gameTemp.setDestination(x,y) to do pathfinding while the input is blocked? I expect Scene_Map would clear the destination. Can you confirm?
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,062
Reaction score
10,363
First Language
Czech
Primarily Uses
RMMV
@Shaz $gameTemp.setDestination(x,y) is not the function that does pathfinding. Therefore it's completely redundant to call that one.

The function that does pathfinding is $gamePlayer.findDirectionTo (goalX, goalY).

You can of course use
Code:
$gameTemp.setDestination(x,y);
$gamePlayer.findDirectionTo ($gameTemp.destinationX(), $gameTemp.destinationY());
if you call these two inside one function, but it's completely useless. Instead it would be better to save these coordinates in a variable or something.
After all,
Code:
$gamePlayer.findDirectionTo ($gameVariables.value(1), $gameVariables.value(2));
might offer you much more flexibility and you can be sure that the $gameTemp will not clear that in next tick.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,138
Reaction score
12,413
First Language
English
Primarily Uses
RMMV
$gameTemp.setDestination(x,y) is what does pathfinding when you click with the mouse.

But yes, I already discovered findDirectionTo. My script is sorted now, with mouse/keyboard and menu access being blocked, but still being able to pathfind for the player.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,062
Reaction score
10,363
First Language
Czech
Primarily Uses
RMMV
It doesn't do pathfinding, it only sets the coordinates. Actual pathfinding is always done via $gamePlayer.findDirectionTo.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,062
Reaction score
10,363
First Language
Czech
Primarily Uses
RMMV
Just a small update:
I've uploaded a plugin that allows you to choose if you want to disable only the keyboard/gamepad movement, the mouse movement or both. It's called InputBlockerKM.
 

palatkorn

Veteran
Veteran
Joined
Nov 1, 2019
Messages
159
Reaction score
41
First Language
thai
Primarily Uses
RMMV
Hello can you help me
I am a beginner for js
I want to block the operation of two fingers on my phone. I still find a way to Will manage well
I found the link code, but I can't handle it properly. Can you recommend me?
Thanks for the reply

Code:
/**
* @static
* @method _onTouchStart
* @param {TouchEvent} event
* @private
*/
TouchInput._onTouchStart = function(event) {
    for (var i = 0; i < event.changedTouches.length; i++) {
        var touch = event.changedTouches[i];
        var x = Graphics.pageToCanvasX(touch.pageX);
        var y = Graphics.pageToCanvasY(touch.pageY);
        if (Graphics.isInsideCanvas(x, y)) {
            this._screenPressed = true;
            this._pressedTime = 0;
            if (event.touches.length >= 1) {
                this.___onCancel(x, y);
            } else {
                this._onTrigger(x, y);
            }
            event.preventDefault();
        }
    }
    if (window.cordova || window.navigator.standalone) {
        event.preventDefault();
    }
};
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,062
Reaction score
10,363
First Language
Czech
Primarily Uses
RMMV
This would be what you're searching for inside of that function.
Code:
if (event.touches.length >= 1) {
                this.___onCancel(x, y);
            }
If you want to deactivate it via switch, it's easy.
Code:
if (event.touches.length >= 1 && !$gameSwitches.value(1)) {
                this.___onCancel(x, y);
            }
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

BCj
Ew, why does my blogpost on the rpgmaker.net site look like a garbled mess? Are html codes disabled or something?
I feel that I should cut down on my order queue so I can get some more time for my projects, its been quite a longggg while since I worked on them LOL
I friend of mine insisted on practicing dubbing things with him... and its quite funny, yet, it really takes a huge amount of practice!
Gotta save this for my next thread later...
Finsh all of the walking dead game in a week, such an amazing emotional trip

Forum statistics

Threads
97,877
Messages
947,572
Members
129,111
Latest member
mariominestrone
Top