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
525
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,933
Reaction score
13,570
First Language
English
Primarily Uses
RMMV
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Just got two Switch E-Shop 20$ gift cards... Is 3D All-Stars worth it? Or should I get something like Celeste? I'd love to know your opinion!
I’m looking at the MZ full body images and I think Priscilla is taller than Reid...
Ami
--- Music Selection ---

M.Archer: It's Music Station,You can Change the Music as you like.
F.Healer: i want to hear the Romantic Music.
M.Fighter: Then,i want the Hard-Rock one!
(the Troll Song has played)
M.Archer: Hey,i hear this Music.
F.Healer: It's popular from Internet Music,i wonder who change it?
Hero: I change it.
Entire Party: YOU????
Had a soda for the first time in two months at my nephew's birthday party...it's amazing how once you are no longer addicted to soda, they actively taste like poison when you try to drink them. Couldn't even finish it.

Forum statistics

Threads
103,040
Messages
996,888
Members
134,514
Latest member
TheGeneral50
Top