Movement by input blocker

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
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.
 

Tsukimi-neko

Tsukimi
Veteran
Joined
Oct 25, 2017
Messages
101
Reaction score
278
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
40,098
Reaction score
13,704
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,125
Reaction score
10,639
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
40,098
Reaction score
13,704
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,125
Reaction score
10,639
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,125
Reaction score
10,639
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
267
Reaction score
192
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,125
Reaction score
10,639
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

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,863
Messages
1,017,053
Members
137,571
Latest member
grr
Top