Video

This Plugin requires Yanfly’s Battle Engine Core and Yanfly’s Action Sequences (#1)  (#2)  (#3)

Sequence Input
Version 1.00
SomeRanDev

This Plugin requires Yanfly's Battle Engine:

Yanfly's Battle Engine Core
(http://yanfly.moe/2015/10/10/yep-3-battle-engine-core/)

Yanfly's Action Sequences
(http://yanfly.moe/2015/10/11/yep-4-action-sequence-pack-1/)
(http://yanfly.moe/2015/10/12/yep-5-action-sequence-pack-2/)
(http://yanfly.moe/2015/10/12/yep-6-action-sequence-pack-3/)

This Plugin allows you to check for Input within Yanfly's Action Sequences.

Here's a list of all the available Actions added through this Plugin that
can be used in the Action Sequences:

==========================================================================
START SEQUENCE INPUT
==========================================================================

In order to begin, let's look at this Action:

START SEQUENCE INPUT: input, varId

This Action starts a check for an Input.
The first parameter, 'input', is the Input that is checked for.
There are a couple built in Inputs in RPG Maker MV:

ok - Z, ENTER, SPACE
escape - X, ESC, INSERT
shift - SHIFT
tab - TAB
control - CTRL, ALT
right - RIGHT ARROW
left - LEFT ARROW
up - UP ARROW
down - DOWN ARROW

You can use any of these or any others added through external Plugins.

The 'varId' parameter represents the Variable ID that will store the
result of the Input.
The value that is stored is the number of frames it took for the Input
condition to become true after the check for Input started.

Examples:

START SEQUENCE INPUT: ok, 3
START SEQUENCE INPUT: escape, 5
START SEQUENCE INPUT: shift, 23

==========================================================================
END SEQUENCE INPUT
==========================================================================

If you wish to stop the check for Input, use:

END SEQUENCE INPUT

This will simply stop the Input check.
If no Input was detected from the start to the end, then the Variable
will be set to 0.

Example:

END SEQUENCE INPUT

==========================================================================
WAIT FOR SEQUENCE INPUT
==========================================================================

Using this Action, the Action Sequence will wait until the Input has been
preformed:

WAIT FOR SEQUENCE INPUT

This will simply keep things waiting until the Input happens.

However, say for example, you wish to have a maximum amount of time that
will be waited before the Sequence Input is just skipped altogether?

WAIT FOR SEQUENCE INPUT: maxFrames

Using this Action, the Actions will still wait for the Input to occur.
However, if 'maxFrames' have passed, and the Input has not occured, then
the wait will end and the Variable will be set to 0.

Examples:

WAIT FOR SEQUENCE INPUT
WAIT FOR SEQUENCE INPUT: 5
WAIT FOR SEQUENCE INPUT: 30

==========================================================================
End of Help File
==========================================================================

Welcome to the bottom of the Help file.

Thanks for reading!
If you have questions, or if you enjoyed this Plugin, please check
out my YouTube channel!

https://www.youtube.com/c/SumRndmDde

Until next time,
~ SomeRanDev
var SRD = SRD || {};
SRD.SequenceInput = SRD.SequenceInput || {};

var Imported = Imported || {};
Imported["SumRndmDde Sequence Input"] = 1.00;

if(Imported.YEP_BattleEngineCore) {

(function(_) {

var params = PluginManager.parameters('SRD_SequenceInput');

_.customInputs = [];
for(var i = 1; i <= 50; i++) {
	var name = String(params['Name Input 1']);
	var input = String(params['Condition Input 1']);
	if(name.trim().length > 0 && input.trim().length) {
		_.customInputs[i] = {};
		_.customInputs[i].name = name.trim().toLowerCase();
		_.customInputs[i].input = input;
	}
}

_.getInput = function(name) {
	for(var i = 1; i < _.customInputs.length; i++) {
		if(_.customInputs[i] && _.customInputs[i].name === name) {
			return _.customInputs[i].input;
		}
	}
	return null;
}

//-----------------------------------------------------------------------------
// BattleManager
//-----------------------------------------------------------------------------

var _BattleManager_initMembers = BattleManager.initMembers;
BattleManager.initMembers = function() {
	_BattleManager_initMembers.call(this);
	this._isSequenceChecking_Input = false;
	this._sequenceInputCheckingFrame = 0;
	this._sequenceInputWaitLimit = 0;
	this._sequenceInputIsComplete = false;
};

var _BattleManager_processActionSequence =  BattleManager.processActionSequence;
BattleManager.processActionSequence = function(actionName, actionArgs) {
	if(actionName === 'START SEQUENCE INPUT') {
		return this.startSequenceInput(actionArgs);
	}
	if(actionName === 'END SEQUENCE INPUT') {
		return this.endSequenceInput();
	}
	if(actionName === 'WAIT FOR SEQUENCE INPUT') {
		return this.waitForSequenceInput(actionArgs);
	}
	return _BattleManager_processActionSequence.call(this, actionName, actionArgs);
};

var _BattleManager_update = BattleManager.update;
BattleManager.update = function() {
	_BattleManager_update.call(this);
	this.checkSequenceInput();
};

BattleManager.checkSequenceInput = function() {
	if(!!this._isSequenceChecking_Input) {
		this._sequenceInputCheckingFrame++;
		if(eval(this._isSequenceChecking_Input[0]) && !this._sequenceInputIsComplete) {
			$gameVariables.setValue(this._isSequenceChecking_Input[1], this._sequenceInputCheckingFrame);
			this._sequenceInputIsComplete = true;
			if(this._logWindow._waitMode === 'sequence-input') {
				this.endSequenceInput();
			}
		} else if(this._logWindow._waitMode === 'sequence-input' && this._sequenceInputWaitLimit != 0 && 
			this._sequenceInputWaitLimit <= this._sequenceInputCheckingFrame) {
			$gameVariables.setValue(this._isSequenceChecking_Input[1], 0);
			this.endSequenceInput();
		}
	}
};

BattleManager.startSequenceInput = function(stuff) {
	var input = String(stuff[0]).trim().toLowerCase();
	var varib = parseInt(stuff[1]);
	this._isSequenceChecking_Input = [];
	this._isSequenceChecking_Input[0] = _.getInput(input) || "Input.isTriggered('" + input + "')";
	this._isSequenceChecking_Input[1] = varib;
	$gameVariables.setValue(this._isSequenceChecking_Input[1], 0);
};

BattleManager.endSequenceInput = function() {
	this._isSequenceChecking_Input = false;
	this._sequenceInputCheckingFrame = 0;
	this._sequenceInputWaitLimit = 0;
	this._sequenceInputIsComplete = false;
};

BattleManager.waitForSequenceInput = function(frameLimit) {
	this._logWindow.waitForSequenceInput();
	if(frameLimit && frameLimit[0]) this._sequenceInputWaitLimit = parseInt(frameLimit[0])
};

BattleManager.isCheckingForSequenceInput = function() {
	return !!this._isSequenceChecking_Input;
};

//-----------------------------------------------------------------------------
// Window_BattleLog
//-----------------------------------------------------------------------------

var _Window_BattleLog_updateWaitMode = Window_BattleLog.prototype.updateWaitMode;
Window_BattleLog.prototype.updateWaitMode = function() {
	if(this._waitMode === 'sequence-input') {
		if(BattleManager.isCheckingForSequenceInput()) return true;
	}
	return _Window_BattleLog_updateWaitMode.call(this);
};

Window_BattleLog.prototype.waitForSequenceInput = function() {
	this.setWaitMode('sequence-input');
};

})(SRD.SequenceInput);

} else alert('HEY! You\'re using SRD_SequenceInput, but that Plugin requires YEP_BattleEngineCore!');