Is there any way to "jump to label", but the label is a string?

EthanFox

Veteran
Veteran
Joined
Oct 15, 2018
Messages
410
Reaction score
319
First Language
English
Primarily Uses
RMMV
In my game, I have many sequences where I use the Jump to Label command, where I'm calling...

Jump to Label "Label4"
Jump to Label "Label5"
Jump to Label "Label6"
etc.

Now, in MV, these are all Jump to Label statements where I've typed in the name of the label. However, it would be better if these segments did something like this...

Segment = 4
... stuff happens here ...
Jump to Label: CONCATENATE("Label",Segment);

or maybe

Jump to Label: CONCATENATE("Label",Segment+1);

Is it possible to do something like this, via JavaScript?
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
845
First Language
English
Primarily Uses
RMMV
Hmm, could do somesuch like this :

Code:
var OssraQuickEdit_GameInterpreter_command119 = Game_Interpreter.prototype.command119;

Game_Interpreter.prototype.command119 = function() {

  var isEval = /evalJumpTo\[(.+)\]/.test(this._params[0]);

  if (isEval) {
    var params = JsonEx.makeDeepCopy(this._params[0]);

    this._params[0] = eval(RegExp.$1);
  }

  var value = OssraQuickEdit_GameInterpreter_command119.call(this);

  if (isEval) {
    this._params[0] = params;
  }

  return value;

};
Then you could have a 'Jump to Label' that has the following :

Code:
// In a script somewhere ...
$gameVariables.setValue(25, 4);

// Jump to Label Command
evalJumpTo['Marple' + $gameVariables.value(25)]



EDIT: Actually, this looks a bit more presentable :

Code:
var OssraQuickEdit_GameInterpreter_command119 = Game_Interpreter.prototype.command119;

Game_Interpreter.prototype.command119 = function() {

  var isConcat = /concatTo\((.+)\)/.test(this._params[0]);

  if (isConcat) {
    var args = RegExp.$1.split(',');

    if (args.length === 2) {
      var params = JsonEx.makeDeepCopy(this._params[0]);
      var variable = $gameVariables.value(Number(args[1]));

      this._params[0] = args[0] + variable;
    } else {
      isConcat = false;
    }
  }

  var value = OssraQuickEdit_GameInterpreter_command119.call(this);

  if (isConcat) {
    this._params[0] = params;
  }

  return value;

};
Code:
concatTo(text, variableId)
// Example :

// Set Variable
$gameVariables.setValue(25, 4);

// Jump to Label Command :
concatTo(Marple, 25)
 
Last edited:

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
523
Reaction score
230
First Language
English
Primarily Uses
RMMV
That may be just a quick edit, but I quite like the idea. I don't expect to need it in my project, mind you; I'd probably switch to scripting before I made something so complicated as that.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,930
Reaction score
13,567
First Language
English
Primarily Uses
RMMV
 

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

Latest Threads

Latest Posts

Latest Profile Posts

I started really going in on my project April of last year... I'm just now making starting the actual game... making assets (and not even all of them), whoooo... TIME SINK.


Imagine being a pleb and using --------------------.js :LZSwink:
Ami
--- Survival For RPGist Part 2 ---

Survivalist: Now,I going to Test you: Fishing with Spear
M.Spear Knight: Leave it to me.
(M.Spear Knight Spearing the Fish with His Battle Spear)
M.Spear Knight: How it is?
Survivalist: I know you did it,but...Is that the Spear for Battle,not for Fishing?
M.Spear Knight: But,is that same?
Survivalist: (Sigh)...Whatever

Forum statistics

Threads
102,944
Messages
996,176
Members
134,408
Latest member
SosukeTheBro
Top