Movement by input blocker

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,038
Reaction score
10,250
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
179
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
38,258
Reaction score
11,862
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,038
Reaction score
10,250
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
38,258
Reaction score
11,862
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,038
Reaction score
10,250
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,038
Reaction score
10,250
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
56
Reaction score
7
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,038
Reaction score
10,250
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: 2)

Latest Threads

Latest Posts

Latest Profile Posts

TFW: You get a text from someone and a long conversation--but you have no idea who this person is and don't wanna be that guy that asks "Who is this by the way?" I have no clue who this person is... but they seem to know me quite well. :rswt
You know, after all these years of using RM I've never played To The Moon. With being busy with life and then after my mom died I was too emotionally fragile to play something that heavy. Has anyone played the Switch version? Is there any big differences between that and the RM version?
Today I finished my Lets Play. Gonna have the videos scheduled for daily uploads now. Woo I finished something ^^
*tries to study Emergence of Bangladesh: Ancient Bengal* Matsyanyayam- When the law of punishment is kept in abeyance... okay what? *searches dictionary* oh! Ok. In abeyance, it gives rise to such disorders as is implied in the proverb of fishes i.e the larger fish swallows a small one- wait fishes eat each other!? Is that like... fishy cannibalism!?...Oh! It's 8:30! Time for dinner! *throws book on floor*
Babbaditch Finster and the Seven-Sided Cube has got to be one of my favorite classic games that didn't exist when I was kid, or ever

Forum statistics

Threads
93,398
Messages
911,982
Members
122,904
Latest member
Vandso
Top