how use LABEL in script call ?

hi guys how use Label in script call ???


I would like to jump to a dynamic label.
Example:


// Get de file name of picture


A = $gameScreen._pictures[$gameVariables.value(2)]._name;


// Convert A to string


A=String(A);


// and now jump to label A


$jumpTo(A);
Look at the game interpreter. That's what processes all commands so that's how you can see how to do it. I don't remember offhand but I think it just moved the current index and indent values in the interpreter until it found a matching label. 
I wanted to do the same thing a while ago, so I took the original, modified it and created a function:


Game_Interpreter.prototype.jump_to_label = function(label) {
for (var i = 0; i < this._list.length; i++) {
var command = this._list;
if (command.code === 118 && command.parameters[0] === label) {
this.jumpTo(i);
return;
}
}
return true;
}
//the script call will be
jump_to_label(label)


You can find the original functions in Game_Interpreter, just as zalerinian said. I put it in spoilers below for convenience.

Spoiler
Code:
// Jump to Label
Game_Interpreter.prototype.command119 = function() {
    var labelName = this._params[0];
    for (var i = 0; i < this._list.length; i++) {
        var command = this._list[i];
        if (command.code === 118 && command.parameters[0] === labelName) {
            this.jumpTo(i);
            return;
        }
    }
    return true;
};

Game_Interpreter.prototype.jumpTo = function(index) {
    var lastIndex = this._index;
    var startIndex = Math.min(index, lastIndex);
    var endIndex = Math.max(index, lastIndex);
    var indent = this._indent;
    for (var i = startIndex; i <= endIndex; i++) {
        var newIndent = this._list[i].indent;
        if (newIndent !== indent) {
            this._branch[indent] = null;
            indent = newIndent;
        }
    }
    this._index = index;
};
Look at the game interpreter. That's what processes all commands so that's how you can see how to do it. I don't remember offhand but I think it just moved the current index and indent values in the interpreter until it found a matching label. 

yes i look it but am nothing understant how to use in script call.

Code:
// Jump to Label
Game_Interpreter.prototype.command119 = function() {
    var labelName = this._params[0];
    for (var i = 0; i < this._list.length; i++) {
        var command = this._list[i];
        if (command.code === 118 && command.parameters[0] === labelName) {
            this.jumpTo(i);
            return;
        }
    }
    return true;
};
Well, one thing you can probably do is directly set the parameters array to the label name you want, an then call "this.command119();", which will run that code. I didn't test it, it's just the first thing I'd think to try if I needed to do this.
Modern Programming language usually don't use labels or goto's anymore due to ineffectiveness and other problems, the label is purely on the event level of execution.


Please describe exactly what you want to do, then we can point you into the direction on how to solve your problem.

Original thread: https://forums.rpgmakerweb.com/threads/how-use-label-in-script-call.64996/