RMMZ About the new RMMZ TouchInput functions...

Raith

Squire
Veteran
Joined
Oct 28, 2019
Messages
61
Reaction score
50
First Language
Indonesian
Primarily Uses
RMMZ
The new TouchInput in rmmz_core.js is highly similar with the old one inRMMV rpg_core.js.

The difference that in the TouchInput.clear function now there are _newState and _currentState properties, and TouchInput.update function is rewritten radically thanks to the new _createNewState() function.

Compared to RMMV, well, this is nice.

However, problems start appearing when you create plugin with anything related to TouchInput: Whether you use isClicked, isTriggered, isPressed, or isReleased function, all of them will produce "event activation loop effect"

To demonstrate what I mean, make and activate this plugin:

JavaScript:
(function() {

Game_Player.prototype.triggerButtonAction = function() {
if (Input.isTriggered('ok') || TouchInput.isTriggered()) {
if (this.getOnOffVehicle()) {
return true;
}
this.checkEventTriggerHere([0]);
if ($gameMap.setupStartingEvent()) {
return true;
}
this.checkEventTriggerThere([0,1,2]);
if ($gameMap.setupStartingEvent()) {
return true;
}
}
return false
};

})();
That small plugin make you able to activate event by clicking anywhere, just by standing adjacent to the event without directly clicking them (just like in Stardew Valley game).

To test the plugin, try making a talking NPC with an event, and try to talk to them by creating Text Message command. You will see the "event activation loop effect", in which the NPC will never stop talking after you try to end the message by clicking, by skipping the message or not.

The plugin, if used in RMMV will not produce the same problem.

Anyone care to explain about this? is this a supposed new touch input behavior? And does anyone know workaround for this?

EDITED: small edit on how to clarify how you should test the plugin
 
Last edited:

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,529
Reaction score
3,680
First Language
Java's Crypt
Primarily Uses
RMMZ
isTriggered should not cause that. How did you test it?

Edit: Sorry, missed the part about the Text Message command.
It's probably triggering the event again because you clicked to skip the message, try also checking if there's no event running before activating a new event.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,608
Reaction score
968
First Language
Portuguese - Br
Primarily Uses
RMMV
Hi! ^^
I think I know what's going on. MAYBE. xD
When I was making my mobile pad plugin, I have this issue with messages too.
When I clicked on a button on the screen, he activates the event, but it keeping activating it and I was not able to close the message.
I mean. when I closed the message, it opened again(like, activating the event again).
I know it's a little bit different than your context because I create a button that simulates the 'ok' input.

But I manage to solve my problem in this function:

JavaScript:
Scene_Map.prototype.isAnyButtonPressed = function() {
    return this._menuButton && this._menuButton.isPressed();
};
JavaScript:
Eli.MobilePad.Scenemap_isAnyButtonPressed = Scenemap.isAnyButtonPressed;
Scenemap.isAnyButtonPressed = function() {
    const alias = Eli.MobilePad.Scenemap_isAnyButtonPressed.call(this);
    return alias || this._mobilePad && this._mobilePad.isPressed();
};
I think you have to add here a condition for the scene map knows that a 'button' is pressed too. In your case, "TouchInput.isTriggered()" ?
Hope It helps ^^''
 

Raith

Squire
Veteran
Joined
Oct 28, 2019
Messages
61
Reaction score
50
First Language
Indonesian
Primarily Uses
RMMZ
FYI the code I modified (by adding || isTriggered) is the one controlling "Action Button" choice for activating event.

isTriggered should not cause that. How did you test it?

Edit: Sorry, missed the part about the Text Message command.
It's probably triggering the event again because you clicked to skip the message, try also checking if there's no event running before activating a new event.
@Hudell I highly agree with your opinion, since I've used the very same code for RMMV - isTriggered, isReleased, etc should not exhibit such behavior. And I've tested it without skipping the message. About checking if an event is still running, I'll try that.

Hi! ^^
I think I know what's going on. MAYBE. xD
When I was making my mobile pad plugin, I have this issue with messages too.
When I clicked on a button on the screen, he activates the event, but it keeping activating it and I was not able to close the message.
I mean. when I closed the message, it opened again(like, activating the event again).
I know it's a little bit different than your context because I create a button that simulates the 'ok' input.

But I manage to solve my problem in this function:

JavaScript:
Scene_Map.prototype.isAnyButtonPressed = function() {
    return this._menuButton && this._menuButton.isPressed();
};
JavaScript:
Eli.MobilePad.Scenemap_isAnyButtonPressed = Scenemap.isAnyButtonPressed;
Scenemap.isAnyButtonPressed = function() {
    const alias = Eli.MobilePad.Scenemap_isAnyButtonPressed.call(this);
    return alias || this._mobilePad && this._mobilePad.isPressed();
};
I think you have to add here a condition for the scene map knows that a 'button' is pressed too. In your case, "TouchInput.isTriggered()" ?
Hope It helps ^^''
It is very similar! There you use isPressed instead. As far as I know, isPressed is the most affected. I've seen the same thing with caethyril's plugin. Gotta try your method too and see which one that is better suited.


EDIT:
I found the temporary solution regarding to the "event activation loop effect", however, I'm not satisfied with this finding:

As far as I tested in vanilla project, the spam-click behavior only affect events/common events using Text Message command. Events which only play SE, change variables/switches, add items, and open shop/menu scene are not affected.
Hence, logically any function involving Game_Interpreter, Game_Player, Window_Message, or TouchInput can be the culprit.

So by changing this piece of codes from the original:

JavaScript:
Window_Message.prototype.isTriggered = function() {
    return (
        Input.isRepeated("ok") ||
        Input.isRepeated("cancel") ||
        TouchInput.isTriggered()
    );
};
Into this....

JavaScript:
Window_Message.prototype.isTriggered = function() {
    return (
        Input.isRepeated("ok") ||
        Input.isRepeated("cancel") ||
        TouchInput.isReleased()
    );
};
Will solve the current issue.

However, It still doesn't explain why I need to do such change while in MV I don't have to. I still don't believe that Window_Message is the cause of this problem.

I'll left this thread open for further discussion if needed.
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

Woke up on an awful nightmare of being banned here because some mod didn't liked me in a super-heroes freeform round robin RP where I used throwing normal hammer as power and it was qualified being too OP. XD Nice to read you all guys. Will not wait next nightmares.
Staring at all the RPG Maker versions I have and realizing that my project has been a long time coming. But, I finally feel like I have the knowledge and experience to make it into something good.
We're almost done with the jam game! :D

Forum statistics

Threads
104,321
Messages
1,005,561
Members
135,844
Latest member
andrewshetty123
Top