Jump to Label

Jump to Label
2018.01.14
by Shaz

Introduction
This plugin provides a more flexible Jump to Label command, where the label can be the result of a formula.

How to use
Add plugin to your js/plugins folder - name must be Shaz_JumpToLabel.js.
Add to plugin manager and set parameter for case sensitivity.
Enter JumpToLabel as a plugin command, followed by the label, which can be the result of a formula.
I suggest adding some sort of catch-all after the plugin command, just in case the label couldn't be found - another JumpT o Label (actual event command) to go back to a previous point, or an Exit Event Processing command.

Example
JumpToLabel $this._mapId - searches for a label with the current map number
JumpToLabel $gameParty.leader().name() - searches for a label with actor names
JumpToLabel $gameVariables.value(3) + $gameVariables.value(4) - searches for a label with the sum of whatever is in variables 3 and 4

Plugin
Download from pastebin
make sure to save it as Shaz_JumpToLabel.js

Credit
- Shaz

Terms
- free for use in commercial games
- do not post elsewhere - link back to this page

Notes
Hey there!
I'm just curious what can i do with this plugin. I also use the command Label in a test game that i made. I use it in for of substitute for changing pages of an event. Its not the same thing, but, i'm just curious.
What ideas you have while you are making this plugin?
Sure, I'll give you a couple of examples ...

I have two common events that are set up for all maps - one of them runs when you first enter a map, and one of them runs when you're about to exit. They do things like moving events to certain positions, changing the BGM or the screen tint or the weather depending on what's happened in the game. I do a JumpToLabel this._mapId so it goes to the block of code to be run for the current map. If I don't have any commands for the current map, nothing gets executed. Previously I would create individual events on each map to do this, but sometimes it wasn't convenient to put them all in a default location and I'd lose them, and sometimes I'd get confused between all the pages they had, and sometimes I'd have to have more than one on a map. Putting them all in a single common event means there is ONE place where I have to look for them.

Another one I've come across a few times is where I want to do a Show Choices, but my choice options are variable, or if I want to check if a group of conditions are met, but want to do different things depending on which are, and which aren't. Let's say I have a quest to bring an apple, a fish and a puppy to a single NPC, and if I've only brought one thing, they will say I need the other two, and if I've brought two things, they'll say I need the other one. I could do this by using a bucketload of IF tests for all the different combinations, or I could do one IF test for each item, and build a string based on the results of the test (something like Apple if I have the apple, then concatenate Fish if I have the fish, then concatenate Puppy if I have the puppy). Using just 3 tests, I'll end up with Apple, Fish, Puppy, AppleFish, ApplePuppy, FishPuppy, or AppleFishPuppy, and can then do a JumpToLabel with the variable I've built. A 3-way check may not be so bad, done with conditional branches, but what if you have 5 or 6 items? Gets a lot more complicated and messy then. But I can do it with just the addition of two or three extra tests, appending to the variable for each one. Then I just create one label for each combination with the appropriate commands.
HHHHMMMMMMM!!!!
Makes sense!! I already have come to this difficult making a lot of conditional branches to chek something. Then this will be come in handy! When i make something i will show here!
With Shaz's permission I am posting a crash report on behalf of this plugin.

My aim is to have a conversation take place using Yanfly's gab window plugin (works under normal circumstances) when entering a specific room while inside the boat vehicle.
Entering either the two rooms hands the player a variable related to said room (oriental corner)(North Reno Strip)

This is handled via a common event so this can take place across several maps after passing through the maps that begin this sequence.
1.png


These conditions are met without error. But when using the labeling plugin it brings up this crash report.
2.png


I cannot find anything in yanfly's plugins or the bind picture to map plugin mentioned in the crash report relating to the labeling function.
As mentioned the erase event is there as a fail safe but even so removed it still reports the same crash result.

I have been looking through this thing for quite some time and I cannot figure it out.
oh - okay, can you try putting the label name in quotes?

JumpToLabel 'LIZ1'
It crashes 🙁
UPD. Resolved, I renamed the file but I ended up with two Jump to Label plugins, which caused this crash.

Very nice plugin, thanks 🙂

1624487563477.png
@KotoYama Just delete the incorrectly-named one from your plugin manager, then from the plugins folder.
Is it possible to make this work in MZ with common events called during battle? I'm using Visustella BattleCore if it makes a difference. Right now I have a common event that randomly picks from one of 209 "Add Text" plugin commands, and while the way I set up the conditional branches doesn't seem to have much performance impact (21 checks at most), I imagine labels would be more efficient. I already added the labels in so that part isn't an issue, lol.
Is it possible to make this work in MZ with common events called during battle?
I'd expect all of the involved code to be the same - what doesn't work correctly when you try?

Or you can just skip the plugin intermediary and use the Jump to Label code from the pinned MZ Script Call List.
I'd expect all of the involved code to be the same - what doesn't work correctly when you try?

Or you can just skip the plugin intermediary and use the Jump to Label code from the pinned MZ Script Call List.
For some reason it just doesn't seem to jump to the corresponding variable no matter what method I try. Here's a screenshot of the Common Event and how I have it set up to test — I think this is the way I'm supposed to do it based on the list document?
1735086054529.png
I think this is the way I'm supposed to do it based on the list document?
Okay, you're combining a few things here and none of them are quite right 😛

For one thing, forget that "jump to label" thing - I said in my previous post you can use the script call instead of this plugin, so I'm not sure why you're still trying to shoehorn syntax from the plugin into your event.

You can't just take plugin commands and put them into a Script box, that won't do anything.

The script call portion you have the right idea, but when you type '$gameVariables.value(13)' that is the words $gameVariables.value(13).

If you want to run the code $gameVariables.value() and turn the result into a string because that's what command119() expects, you'd use the String() casting function. So:
Code:
this.command119([String($gameVariables.value(13))])
Okay, you're combining a few things here and none of them are quite right 😛

For one thing, forget that "jump to label" thing - I said in my previous post you can use the script call instead of this plugin, so I'm not sure why you're still trying to shoehorn syntax from the plugin into your event.

You can't just take plugin commands and put them into a Script box, that won't do anything.

The script call portion you have the right idea, but when you type '$gameVariables.value(13)' that is the words $gameVariables.value(13).

If you want to run the code $gameVariables.value() and turn the result into a string because that's what command119() expects, you'd use the String() casting function. So:
Code:
this.command119([String($gameVariables.value(13))])
Hell yeah, this works perfectly! Thanks so much Turan! I swear the solutions to half of my RPG Maker problems come from you 😛
Just pointing out, if you have 'ignore case' set to false, this will not work with variables that are just numerical values, even if the value matches the label. Setting the variable manually via the script option in quotes (ie, "1") it interprets it as a string and does work, but otherwise any value including those resulting from an evaluation will fail the check.

For example, with 'ignore case' turned OFF and Variable 25 set to 1 (not by Script), where Label: 1 exists within the event page:
JumpToLabel 1 does not work
JumpToLabel 1 + 0 does not work
JumpToLabel $gameVariables.value(25) does not work
JumpToLabel "'" + $gameVariables.value(25) + "'" does not work

Setting Variable 25 to "1" (as a Script, quotes included) does work, but will fail as just 1 (without quotes). With 'ignore case' set to true, evals and numerical values work as intended, regardless of how they are set.

In case this doesn't get fixed or cannot be fixed, just thought anyone who finds the thread might like to know so they can try to plan around it.

Additionally, the following Script calls
JavaScript:
this.command119([String($gameVariables.value(25))])
JavaScript:
this.command119(["1"])
JavaScript:
this.command119([1])
and several other variations have all failed to recognize the Label: 1 (no quotes) in my MV project, which is what led me to this plugin. They are supposedly the same as the ones in MZ and tested to work in MV, but if anyone can provide information to the contrary, it would be appreciated. This plugin is a great alternative in the meantime.
@emogal - for Shaz's plugin, did you try JumpToLabel "1", or maybe JumpToLabel String(1)?

Re the MV / MZ Script Call List - for reference, here's a screenshot:

screenshot-scl-119.png
👋 Notice the checkboxes on the left? Those indicate the engine for each script call. You have tried to use the MZ call in MV, that's why it's not working. You could try this instead:
JavaScript:
this._params = ["1"];
this.command119();
@caethyril "1" in quotes works yes, but the issue is while using 'ignore case', JumpToLabel [myvariablehere] will be unable to call values from variables, which I was trying to use to jump to different labels based on the value of a party member index. So if you know the label offhand it's not a problem, but in that case you could just use the default engine call anyway, defeating the purpose of needing this plugin.

I have that script call list bookmarked and used it a lot in the beginning, but it tends to freeze up my very old laptop, so I kinda just have to Google things as needed and then save them to my own reference Notepad doc. In my comment was referring to this reply on another similar thread claiming the call is the same between MZ and MV, as well as some on Reddit/Steam threads quoting that MZ script in MV posts, but I guess that isn't true after all! Thank you for the correction~

Original thread: https://forums.rpgmakerweb.com/threads/jump-to-label.89885/