[EDIT: Ok, so the problem (at least one of them) is that the TouchInput.isCancelled() can't be used like that to detect a mouse right button press...but then how do I detect a right mouse click? I tried googling some javascript and it talks about a mouse event taking a value of 2 or something, but I can't make anything up with that, LOL.]
So I want the left mouse button to imitate pressing keyboard "c" and the right mouse button to imitate pressing keyboard "a" and also play an animation on the player. I googled old threads here and came up with this (no idea what I'm doing). It seems like the left button is working, but the right button only does its job once and then stops responding(?) If what I have tried to come up with by googling looks like sh*t, can someone suggest some easier solution? (I'm using RMMZ and playing around with the ARPG plugin).
Disable mouse movement and mouse menu access with scripts (seems to be working?):
Bind the keyboard keys to the mouse buttons (+ play animation on right click). Like I said above, there's a problem with the right button.
So I want the left mouse button to imitate pressing keyboard "c" and the right mouse button to imitate pressing keyboard "a" and also play an animation on the player. I googled old threads here and came up with this (no idea what I'm doing). It seems like the left button is working, but the right button only does its job once and then stops responding(?) If what I have tried to come up with by googling looks like sh*t, can someone suggest some easier solution? (I'm using RMMZ and playing around with the ARPG plugin).
Disable mouse movement and mouse menu access with scripts (seems to be working?):
Code:
Game_Temp.prototype.setDestination = function(x, y) {
};
Code:
Scene_Map.prototype.isMenuCalled = function() {
return Input.isTriggered('menu');
};
Bind the keyboard keys to the mouse buttons (+ play animation on right click). Like I said above, there's a problem with the right button.
LEFT BUTTON
IF script: TouchInput.isPressed()
RIGHT BUTTON
IF script: TouchInput.isCancelled()
IF script: TouchInput.isPressed()
Code:
TouchInput._onLeftButtonDown = function(event) {
document.dispatchEvent(
new KeyboardEvent("keydown", {
key: "c",
keyCode: 67,
code: "c",
which: 67
})
);
setTimeout(() => {
document.dispatchEvent(new KeyboardEvent("keyup", {
key: "c",
keyCode: 67,
code: "c",
which: 67
}));
}, 250);
};
RIGHT BUTTON
IF script: TouchInput.isCancelled()
Code:
TouchInput._onRightButtonDown = function(event) {
document.dispatchEvent(
new KeyboardEvent("keydown", {
key: "a",
keyCode: 97,
code: "a",
which: 97
})
);
setTimeout(() => {
document.dispatchEvent(new KeyboardEvent("keyup", {
key: "a",
keyCode: 97,
code: "a",
which: 97
}));
}, 250);
};
$gameTemp.requestAnimation([$gamePlayer], 21);